wiki:kernel_locks

Version 1 (modified by alain, 10 years ago) (diff)

--

GIET-VM / Locks access functions

The utils.c and util.h files define the functions used to take & release a kernel lock.

They are prefixed by "_" to remind that they can only be executed by a processor in kernel mode.

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.

void _get_lock( giet_lock_t lock )

Takes a lock with a blocking ll/sc atomic access. 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. If there is no hardware cache coherence a pseudo random delay is introduced between two successive retry.

void _release_lock( giet_lock_t lock )

Releases (or initializes) a lock.