Changes between Version 9 and Version 10 of kernel_locks
- Timestamp:
- Dec 6, 2014, 2:14:05 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
kernel_locks
v9 v10 5 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 by the kernel to take & release locks protecting exclusive access to a shared resource. 6 6 7 The GIET_VM kernel define two types of spin-lock: 8 * The '''spin_lock_t''' implements a spin-lock 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. 9 * The '''simple_lock_t''' implements a spin-lock without waiting queue. It is only used by the TTY0 access functions, to get exclusive access to the TTY0 kernel terminal 7 The GIET_VM kernel define three types of spin-lock: 10 8 11 The lock access functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode.9 1. The '''simple_lock_t''' implements a spin-lock without waiting queue. It is only used by the TTY0 access functions, to get exclusive access to the TTY0 kernel terminal. 12 10 13 Both the '''spin_lock_t''' and '''simple_lock_t''' structures are implemented to have one single lock in a 64 bytes cache line, and should be aligned on a cache line boundary. 11 2. The '''spin_lock_t''' implements a spin-lock 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. This lock 12 must be initialised. 14 13 14 3. The '''sbt_lock_t''' spin-lock can be used when a single lock protect a unique resource that can be used by any task 15 running on a 2D mesh of clusters. The lock is implemented as a Sliced Binary Tree of ''partial'' locks distributed on all cluster 16 of a 2D mesh. It is intended to avoid contention on a single cluster when all tasks try to access the same lock. 17 18 All the lock access functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode. 19 20 The '''simple_lock_t''', '''sbt_lock_t''', and '''spin_lock_t''' structures are implemented to have one single lock in a 64 bytes cache line, and should be aligned on a cache line boundary. 21 22 == Atomic access functions == 15 23 16 24 === unsigned int '''_atomic_increment'''( unsigned int * shared , unsigned int increment ) === … … 19 27 * '''increment''' : increment value 20 28 29 == Simple lock access functions == 30 31 === void '''_simple_lock_acquire'''( simple_lock_t * lock ) === 32 This blocking function does not implement any ordered allocation, and is not distributed. It returns only when the lock as been granted. 33 34 === void '''_simple_lock_release'''( simple_lock_t * lock ) === 35 This function releases the lock, and can be used for lock initialisation. It must always be called after a successful _simple_lock_acquire(). 36 37 == Queuing Lock Access functions == 38 21 39 === void '''_lock_init'''( spin_lock_t * lock ) === 22 This function initializes the spinlock ticket allocator.40 This function initializes the lock ticket allocator. 23 41 24 42 === void '''_lock_acquire'''( spin_lock_t * lock ) === … … 28 46 This function releases the lock, but cannot be used for lock initialisation. It must always be called after a successful _lock_acquire(). 29 47 30 === void '''_simple_lock_acquire'''( simple_lock_t * lock ) === 31 This blocking function does not implement any ordered allocation. It returns only when the lock as been granted. 48 == Distributed Lock Access functions == 32 49 33 === void '''_simple_lock_release'''( simple_lock_t * lock ) === 34 This function releases the lock, and can be used for lock initialisation. It must always be called after a successful _simple_lock_acquire(). 50 === void '''sbt_lock_init'''( sbt_lock_t* lock, unsigned int ntasks ) === 51 52 === void '''sbt_lock_acquire'''( sbt_lock_t* lock ) === 53 54 === void '''sbt_lock_release'''( sbt_lock_t* lock ) === 55 56