Changes between Version 3 and Version 4 of kernel_locks
- Timestamp:
- Dec 2, 2014, 7:11:01 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
kernel_locks
v3 v4 3 3 [[PageOutline]] 4 4 5 The [source:soft/giet_vm/giet_common/ utils.c utils.c] and [source:soft/giet_vm/giet_common/utils.h util.h] files define the functions used to take & release a kernel lock.5 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. 6 6 7 The yare prefixed by "_" to remind that they can only be executed by a processor in kernel mode.7 The lock access functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode. 8 8 9 The '' giet_lock_t'' structure is defined in the ''utils.h'' file to have one single lock in a 64 bytes cache line. Itshould be aligned on a cache line boundary.9 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. 10 10 11 === void _get_lock( giet_lock_t lock ) ===12 Takes a lock with a blocking ll/sc atomic access.13 * If the cache coherence is granted by the hardware, the first read is a standard (cacheable) lw, as the local copy can be polled when the lock is already taken by another task, reducing trafic on the interconnect. When the lock is released by the owner task, the local copy is updated or invalidated by the coherence protocol.14 * If there is no hardware cache coherence a pseudo random delay is introduced between two successive retry.15 11 16 === void _release_lock( giet_lock_t lock ) === 17 Releases (or initializes) a lock. 12 === unsigned int '''_atomic_increment'''( unsigned int * shared , unsigned int increment ) === 13 This blocking function use a LL/SC to atomically increment a shared variable. 14 * '''shared''' : pointer on the shared variable 15 * '''increment''' : increment value 16 17 === void '''_lock_init( spin_lock_t * lock ) === 18 This function initializes the spin lock ticket allocator. 19 20 === void '''_lock_acquire'''( spin_lock_t * lock ) === 21 This blocking function uses the atomic_increment() function, and returns only when the lock as been granted. 22 23 === void '''_lock_release'''( giet_lock_t * lock ) === 24 Releases the spin-lock. This must always be called after a successful _lock_acquire().