| | 1 | This section describes the ALMOS-MKH implementation of the POSIX compliant, user-level synchronisation services: mutex, condvar, barrier and semaphore. |
| | 2 | |
| | 3 | [[PageOutline]] |
| | 4 | |
| | 5 | == A) General Principles == |
| | 6 | |
| | 7 | All data structure defined by ALMOS-MKH to support the user-level, POSIX compliant, synchronization services are fully specific, and do NOT use the kernel level synchronization primitives described in section. does NOT use the |
| | 8 | |
| | 9 | == B) Mutex == |
| | 10 | |
| | 11 | This file defines an user level POSIX compliant mutex. |
| | 12 | * |
| | 13 | * It can be used by muti-threaded user applications to synchronise user threads |
| | 14 | * running in different clusters. |
| | 15 | * |
| | 16 | * A mutex is declared by a given user process as a "pthread_mutex_t" global variable. |
| | 17 | * This user type is implemented as an unsigned long, but the value is not used by the |
| | 18 | * kernel. ALMOS-MKH uses only the mutex virtual address as an identifier. |
| | 19 | * For each user mutex, ALMOS-MKH creates a kernel "remote_mutex_t" structure, |
| | 20 | * dynamically allocated in the reference cluster by the remote_mutex_create() function, |
| | 21 | * and destroyed by the remote_mutex_destroy() function, using RPC if the calling thread |
| | 22 | * is not running in the reference cluster. |
| | 23 | * |
| | 24 | * The blocking "remote_mutex_lock()" function implements a descheduling policy when |
| | 25 | * the lock is already taken by another thread : the calling thread is registered |
| | 26 | * in a waiting queue, rooted in the mutex structure, and the the calling thread |
| | 27 | * is blocked on the THREAD_BLOCKED_MUTEX condition. |
| | 28 | * The "remote_mutex_unlock()" function unblocks the first waiting thread in the queue |
| | 29 | * without releasing the mutex if queue is not empty. |
| | 30 | |
| | 31 | == C) Condvar == |
| | 32 | |
| | 33 | == D) Semaphore == |
| | 34 | |
| | 35 | == E) Barrier == |