summaryrefslogtreecommitdiff
path: root/arch/i386/kernel/spinlock.s
blob: c8235ca54ff09227d876402159e9cd6a83a43fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.section .text

.global aquire_lock
.type aquire_lock, @function
aquire_lock:
        pushl %ebp
        movl %esp, %ebp
locked:
        movl 8(%esp), %eax
        lock incl (%eax)
        jc spin_wait

        popl %ebp
        ret
spin_wait:
        test %eax, 1
        jnz spin_wait
        jmp locked

.global release_lock
.type release_lock, @function
release_lock:
        pushl %ebp
        movl %esp, %ebp

        movl 8(%ebp), %eax
        lock decl (%eax)

        popl %ebp
        ret