3 | | The [source:soft/giet_vm/giet_libs/spin_lock.c spin_lock.c] and [source:soft/giet_vm/giet_libs/spin_lock.h spin_lock.h] |
4 | | files define a user-level spin-lock service to obtain exclusive access to a shared resource in a parallel multi-tasks application. |
| 3 | [[PageOutline]] |
| 4 | |
| 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. |
18 | | * '''void lock_release( giet_lock_t * lock )''' |
19 | | This function uses a simple SW to release the lock. It can be used for lock initialization. |
| 24 | === '''void lock_init'''( user_lock_t * lock ) === |
| 25 | This function should be called by one single task. |
| 26 | * '''lock''' : pointer on the user_lock_t structure. |
| 27 | |
| 28 | === '''void lock_acquire'''( giet_lock_t * lock ) === |
| 29 | This blocking function returns only when the lock has been successfully taken. |
| 30 | * '''lock''' : pointer on the user_lock_t structure. |
| 31 | |
| 32 | === '''void lock_release'''( giet_lock_t * lock ) === |
| 33 | This function releases the lock. It must be called by a task after a successful lock_acquire(). |
| 34 | * '''lock''' : pointer on the user_lock_t structure. |