Changes between Version 3 and Version 4 of library_locks


Ignore:
Timestamp:
Dec 2, 2014, 6:12:26 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • library_locks

    v3 v4  
    1 = The spin_lock library =
     1= The user_lock library =
    22
    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
     5The [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]
     6files 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.
     9The proposed spin-lock implement a waiting queue service, to enforce fairness and avoid live-lock situations.
    510Each lock (giet_lock_t object) occupies a complete 64 bytes cache line to avoid false sharing.
    6 If the hardware architecture supports hardware cache coherence, it is recommanded to store the lock in a cachable segment architecture
    711
    812 == Lock placement ==
    913
    10 The lock being shared by several tasks, is defined as a global variable in the application code.
     14The lock being shared by several tasks, should be defined as a global variable of type '''user_lock_t''' in the application code.
    1115It is possible to control precisely the placement of a specific lock by defining a specific vseg in the application mapping.
    1216
    1317 == Access functions ==
    1418
    15  * '''void lock_acquire( giet_lock_t * lock )'''
    16 This blocking function uses an atomic LL/SC mechanism to take the lock, and return only when the lock has been successfully taken.
     19 === unsigned int '''atomic_increment'''( unsigned int* shared, unsigned int increment) ===
     20This function uses a LL/SC to atomically increment a shared variable.
     21 * '''shared''' : pointer on the shared variable
     22 * '''increment''' : increment value.
    1723
    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 ) ===
     25This 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 ) ===
     29This 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 ) ===
     33This 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.