NOVA
Stripped down NOVA kernel for the OSY course
Loading...
Searching...
No Matches
Spinlock Class Reference

Public Member Functions

NOINLINE void lock ()
ALWAYS_INLINE void unlock ()

Constructor & Destructor Documentation

◆ Spinlock()

ALWAYS_INLINE Spinlock::Spinlock ( )
inline
31: val (0) {}

Member Function Documentation

◆ lock()

NOINLINE void Spinlock::lock ( )
inline
35 {
36 uint16 tmp = 0x100;
37
38 asm volatile (" lock; xadd %0, %1; "
39 "1: cmpb %h0, %b0; "
40 " je 2f; "
41 " pause; "
42 " movb %1, %b0; "
43 " jmp 1b; "
44 "2: "
45 : "+Q" (tmp), "+m" (val) : : "memory");
46 }

◆ unlock()

ALWAYS_INLINE void Spinlock::unlock ( )
inline
50 {
51 asm volatile ("incb %0" : "=m" (val) : : "memory");
52 }

The documentation for this class was generated from the following file: