| 49 | | == D) Semaphore == |
| | 49 | == D) Barrier == |
| | 50 | |
| | 51 | The user level, POSIX compliant, barrier is defined in the '''pthread''' library, implemented by the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/libs/libpthread/pthread.h pthread.h] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/libs/libpthread/pthread.c pthread.c] files. |
| | 52 | |
| | 53 | It can be used by a muti-threaded user application to implement a "rendez-vous" for a given number of threads running in different clusters. |
| | 54 | |
| | 55 | The kernel implementation of a barrier is defined in the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/libk/remote_barrier.h remote_barrier.h] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/libk/remote_barrier.c remote_barrier.c] files. |
| | 56 | |
| | 57 | For each user barrier, ALMOS-MKH creates a kernel ''remote_barrier_t'' structure, dynamically allocated in the reference cluster (i.e. in the cluster containing the reference process descriptor). |
| | 58 | * The '''remote_barrier_create()''' function allocates and initializes a barrier, using an RPC if if the calling thread is not running in the reference cluster. |
| | 59 | * The '''remote_barrier_destroy()''' function destroys a given barrier, using RPC if the calling thread is not running in the reference cluster. |
| | 60 | * The blocking '''remote_barrier_wait()''' function returns only when all expected threads (defined by the remote_barrier_create() function) reach the barrier. As the implementation uses a toggle variable, this barrier can be safely called several times, as long as the number of expected threads does not change. |
| | 61 | |
| | 62 | == E) Semaphore == |
| 63 | | |
| 64 | | == E) Barrier == |
| 65 | | |
| 66 | | The user level, POSIX compliant, barrier is defined in the '''pthread''' library, implemented by the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/libs/libpthread/pthread.h] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/libs/libpthread/pthread.c pthread.c] files. |
| 67 | | |
| 68 | | It can be used by a muti-threaded user application to implement a "rendez-vous" for a given number of threads running in different clusters. This toggle barrier can be used |
| 69 | | |
| 70 | | The kernel implementation of a barrier is defined in the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/libk/remote_barrier.h remote_barrier.h] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/libk/remote_barrier.c remote_barrier.c] files. |
| 71 | | |
| 72 | | For each user barrier, ALMOS-MKH creates a kernel ''remote_barrier_t'' structure, dynamically allocated in the reference cluster (i.e. in the cluster containing the reference process descriptor). |
| 73 | | * The '''remote_barrier_create()''' function allocates and initializes a barrier, using an RPC if if the calling thread is not running in the reference cluster. |
| 74 | | * The '''remote_barrier_destroy()''' function destroys a given barrier, using RPC if the calling thread is not running in the reference cluster. |
| 75 | | * The blocking '''remote_barrier_wait()''' function returns only when the all expected threads (defined by the remote_barrier_create() function) reach the barrier. As the implementation uses a toggle variable, this barrier can be safely called several times, as long as the number of expected threads does not change. |