Changes between Version 10 and Version 11 of library_locks
- Timestamp:
- Sep 27, 2015, 12:43:05 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
library_locks
v10 v11 4 4 5 5 The [source:soft/giet_vm/giet_libs/user_lock.c user_lock.c] and [source:soft/giet_vm/giet_libs/user_lock.h user_lock.h] 6 files define two types of services: 7 * user-level atomic access functions, to increment a shared counter. 8 * user-level spin-locks, to obtain exclusive access to a shared resource in a parallel multi-tasks application. 9 The proposed spin-lock implement a waiting queue service, to enforce fairness and avoid live-lock situations. 10 Each lock (giet_lock_t object) occupies a complete 64 bytes cache line to avoid false sharing. 6 files define two types of locks: 7 * '''user_lock_t''' : this lock uses a ticket allocation mechanism to enforce fairness and avoid live-locks. This lock is located in one single cluster, and the placement can be controlled by defining a specific vseg in the application mapping. 8 * '''sqt_lock_t''' : this distributed lock can be used to avoid quadratic latency, when the protected resource is shared by a large number or threads. The SQT (Synchronization Quad-Tree) is distributed on all clusters of the mesh. 11 9 12 The '''user_lock_t''' being shared by several tasks, should be defined as a global variable in the application code. 13 It is possible to control precisely the placement of a specific lock on a specific physical memory bank by defining a specific vseg in the application mapping. 10 Each lock (user_lock_t object, or distributed sqt_lock_node_t) occupies a complete 64 bytes cache line to avoid false sharing. 14 11 15 Distributed version are available in [source:soft/giet_vm/giet_libs/user_sqt_lock.c user_sqt_lock.c] and [source:soft/giet_vm/giet_libs/user_sqt_lock.h user_sqt_lock.h] 16 files. 12 The '''user_lock_t''' and '''sqt_lock_t''' being shared by several threads, should be defined as a global variable in the application code. 17 13 18 == Access functions == 14 == Atomic access functions == 15 16 Both types of locks use the atomic_increment() function, that can be directly used by the applications. 19 17 20 18 === unsigned int '''atomic_increment'''( unsigned int* shared, unsigned int increment) === 21 This function uses a LL/SC to atomically increment a shared variable.19 This blocking function uses a LL/SC to atomically increment a shared variable. 22 20 * '''ptr''' : pointer on the shared variable 23 21 * '''increment''' : increment value. 22 23 == Simple lock access functions 24 24 25 25 === '''void lock_init'''( user_lock_t * lock ) === … … 35 35 * '''lock''' : pointer on the user_lock_t structure. 36 36 37 == Distributed lock access functions == 37 38 38 == Distributed functions == 39 40 41 The sqt_lock can be used in multi-clusters architectures, and is implemented as a - physically distributed - Synchronisation-Quad-Tree (SQT). The SQT topology is completely defined by the (x_size / y_size) parameters, with the following constraints: 39 The SQT topology is completely defined by the (x_size / y_size) parameters, with the following constraints: 42 40 * The involved clusters form a mesh(x_size * y_size). 43 41 * The lower left involved cluster is cluster(0,0). 44 42 * All involved clusters must contain a heap_x_y vseg declared in the mapping. 45 * The number of involved tasks in a given cluster is the same for all involved clusters. 43 * The number of involved tasks in a given cluster is the same for all involved clusters. 46 44 47 45 === '''void sqt_lock_init'''( sqt_lock_t * lock ) === … … 56 54 This function releases the lock. It must be called by a task after a successful lock_acquire(). 57 55 * '''lock''' : pointer on the sqt_lock_t structure. 58