= GIET-VM / Locks access functions = [[PageOutline]] The [source:soft/giet_vm/giet_common/locks.c locks.c] and [source:soft/giet_vm/giet_common/locks.h locks.h] files define the functions used to take & release the kernel locks. These locks are implemented as spin-locks with a waiting queue (based on a ticket allocator scheme) to enforce fairness and avoid live-lock situations. The GIET_LOCK_MAX_TICKET define the wrapping value for the ticket allocator. The lock access functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode. The ''spin_lock_t'' structure is defined to have one single lock in a 64 bytes cache line, and should be aligned on a cache line boundary. === unsigned int '''_atomic_increment'''( unsigned int * shared , unsigned int increment ) === This blocking function use a LL/SC to atomically increment a shared variable. * '''shared''' : pointer on the shared variable * '''increment''' : increment value === void '''_lock_init( spin_lock_t * lock ) === This function initializes the spin lock ticket allocator. === void '''_lock_acquire'''( spin_lock_t * lock ) === This blocking function uses the atomic_increment() function, and returns only when the lock as been granted. === void '''_lock_release'''( giet_lock_t * lock ) === Releases the spin-lock. This must always be called after a successful _lock_acquire().