Changes between Version 3 and Version 4 of kernel_locks


Ignore:
Timestamp:
Dec 2, 2014, 7:11:01 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • kernel_locks

    v3 v4  
    33[[PageOutline]]
    44
    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.
     5The [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.
    66
    7 They are prefixed by "_" to remind that they can only be executed by a processor in kernel mode.
     7The lock access functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode.
    88
    9 The ''giet_lock_t'' structure is defined in the ''utils.h'' file to have one single lock in a 64 bytes cache line. It should be aligned on a cache line boundary.
     9The ''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.
    1010
    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.
    1511
    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 ) ===
     13This 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 ) ===
     18This function initializes the spin lock ticket allocator.
     19
     20 === void '''_lock_acquire'''( spin_lock_t * lock ) ===
     21This 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 ) ===
     24Releases the spin-lock. This must always be called after a successful _lock_acquire().