| 45 | When the DEBUG_BUSYLOCK parameter is set in the kernel_config.h file, an optional debug mechanism is activated, thanks to conditional compilation. |
| 46 | |
| 47 | Each thread contains - besides the ''busylocks'' counter - an optional ''busylocks_root'' field, that is the root of the embedded xlist of (local or remote) busylocks hold by a given thread at a given time. This list is implemented by an optional ''xlist'' field in the busy lock descriptor. It is dynamically updated by the ''busylock_acquire()'' and ''busylock_release()'' functions. The set of taken busylocks is printed in the error message, when the scheduler detects that a descheduling thread is holding one or several busylocks. This list can also be be printed through the ''idbg" interactive debugger, for any thread identified by its (pid,trdid). |
| 48 | |
| 49 | == F) Barriers == |
| 50 | |
| 51 | The kernel initialization is done in parallel in all clusters, by the kernel idle threads, where there is one idle thread per core. These threads allocate and initialize shared and distributed data structures, such as the cluster managers, the cores schedulers, or the Virtual File System. This requires synchronization barriers. |
| 52 | |
| 53 | ALMOS-MKH implements both local barriers and global barriers. |
| 54 | * The local barriers are used to synchronize all idle threads in a given cluster K. The number of expected threads is defined by the number of cores in cluster K, that is registered in the local boot_info structure. |
| 55 | * The global barrier is used to synchronize all threads running on the first core (Core 0) of each cluster. The number of expected threads is defined by the total number of active clusters (containing one kernel instance), that is also registered in each local boot_info structure. |
| 56 | |
| 57 | These barriers being used only during kernel initialization implement a simple busy-waiting policy. They are implemented as global variables, in the kdata segment. These toggle barriers can be used several times, and don't need to be explicitly initialized. For the global barrier (''xbarrier''), the client threads use remote_read() remote_write(), & remote_atomic_add() primitives, to access the barrier located in cluster 0. |
| 58 | |
| 59 | |