Changes between Version 18 and Version 19 of processus_thread
- Timestamp:
- Jul 15, 2016, 6:59:09 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
processus_thread
v18 v19 1 = Dynamic process and thread creation =1 = Process and thread creation/destruction = 2 2 3 3 [[PageOutline]] 4 5 The process is the internal représentation of an user application. A process can be running as a single thread (called main thread), or can be multi-threaded. ALMOS-MK supports the POSIX thread API. 6 In this case the number of threads can be very large, and the threads of a given process can be distributed on all cores available in the shared memory architecture, for maximal parallelism. Therefore A single process can spread on all clusters. To avoid contention, the process descriptor of a P process, and the associated structures, such as the Page Table, or the Open File Descriptors Table are (partially) replicated in all clusters containing at least one thread of P. 4 7 5 8 == __1) Process__ == … … 7 10 The PID (Process Identifier) is coded on 32 bits. It is unique in the system, and has a fixed format: The 16 MSB (CXY) contain the owner cluster identifier. The 16 LSB bits (LPID) contain the local process index in owner cluster. The '''owner cluster''' is therefore defined by PID MSB bits. 8 11 9 To avoid contention, the process descriptor of a P process, and the associated structures, such as the Page Table, or the Open File Descriptors Table are (partially) replicated in all clusters containing at least one thread of P. 12 As it exists several copies of the process descriptors, ALMOS-MK defines a reference process descriptor, located in the '''reference cluster'''. The other copies are used as local caches, 13 and ALMOS-MK must guaranty the coherence betweenl the reference and the copies. 10 14 11 As it exists several copies of the process descriptors, ALMOS-MK defines a reference process descriptor, located in the '''reference cluster''', and the other copies are used as local caches. 12 13 '''Warning''' : to support process migration, the '''reference cluster''' can be different from the '''owner process'''. 15 '''Warning''' : to support process migration, the '''reference cluster''' can be different from the '''owner process''': the '''owner cluster'' cannot change (because the PID is fixed), but the '''reference 16 cluster'' can change in case of process migration. 14 17 15 18 In each cluster K, the local cluster manager (cluster_t type in ALMOS-MK) contains a process manager (pmgr_t type in ALMOS-MK) that maintains three structures for all process owned by K : … … 123 126 == __5) Thread destruction__ == 124 127 125 The destruction of a thread T RDID running in cluster K can be caused by the thread itself, with the pthread_exit() system call. It can also be caused by a signal (local or remote) requesting the thread to stop execution. In both case, the host kernel K is in charge of the destruction.128 The destruction of a thread T running in cluster K can be caused by the thread itself, with the pthread_exit() system call. It can also be caused by a kill signal, went by anothprthread, requesting the thread to stop execution. In both case, the host kernel K is in charge of the destruction. The scenario is more complex if the finishing thread T is running in ATTACH mode, because the parent thread TP must be informed of the completion of thread T, in case of pthread_join() executed by TP. 126 129 127 130 === 5.1) phase 1 === 128 131 129 132 It T is running in ATTACH mode, the host cluster K force the T state to ZOMBI, to prevent the thread to be scheduled. If the thread completion is caused by an exit, the thread T stops immediately execution. If it is caused by a kill signal, the signal is registered in the thread descriptor, and the rescheduling will only occur at the next scheduling point. 133 If T is not running in attached mode, the scenario is similar, but the T is directly forced to the DEAD state. 130 134 131 135 === 5.2) phase 2 === 132 136 133 137 This second phase is only required, in the parent thread cluster M, if T is running in ATTACH mode. The parent thread descriptor maintains a global list of all children threads running in ATTACH mode. When the parent thread execute the pthread_join() system call for a child identified by its TRDID, the M kernel scan this list to localize the selected child thread, and directly poll the child thread status using a remote_read access. When the M kernel detects the completion of T (ZOMBI state), it send a RPC_THREAD_USER_JOIN to the K cluster containing the T thread to ask the K kernel to change the state of T from ZOMBI to DEAD. 134 138 135 139 === 5.3) phase 3 === 136 140 137 Le noyau du cluster K enregistre le signal KILL dans le descripteur de thread TRDID au moyen d’une opération atomique. 138 Lors du traitement de ce signal, le thread TRDID est éliminé de l’ordonnanceur, il est éliminé de la TRDL(P,X), et la mémoire 139 allouée pour le descripteur de thread dans le cluster K est libérée. 141 In each cluster, a dedicated kernel thread is in charge of housekeeping: This thread releases the memory allocated to all DEAD threads. 140 142 141 143 == __5) Destruction d’un processus__