Changes between Version 15 and Version 16 of processus_thread


Ignore:
Timestamp:
Jul 11, 2016, 1:05:27 PM (6 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v15 v16  
    7676The parent process P is running on a core in cluster K, and execute the fork() system call to create a new process F on a remote cluster Z. The target cluster Z will become the owner of the F process. It is selected by the kernel using the DQDT. Cluster K will contain the reference process descriptor. The fork() sys call execute the following steps:
    7777
    78  1. the process P in cluster K allocates memory in K to store the reference process descriptor of F, and get a pointer on this process descriptor using the process_alloc() function.
    79  1. the process P  in cluster K ask to kernel Z to allocate a PID for the F process, and to register the process descriptor extended pointer in PREF_TBL(Z) of cluster Z manager. This is done by the RPC_PROCESS_PID_ALLOC that takes the process descriptor pointer as argument and returns the PID.
    80  1. the process P in kernel K initializes the F process descriptor from informations found in the P parent process descriptor. This includes the inherited ...
    81  1. the process P in kernel K creates locally the main thread of process F, and register this thread in the TH_TBL(K,P),
    82  1. the process P in kernel K register this new thread in the scheduler of the core executing the fork() system call, an return.
     78 1. the cluster K allocates memory in K to store the reference process descriptor of F, and get a pointer on this process descriptor using the process_alloc() function.
     79 1. the cluster K ask to kernel Z to allocate a PID for the F process, and to register the process descriptor extended pointer in PREF_TBL(Z) of cluster Z manager. This is done by the RPC_PROCESS_PID_ALLOC that takes the process descriptor pointer as argument and returns the PID.
     80 1. after RPC completion, the kernel K initializes the F process descriptor from informations found in the P parent process descriptor. This includes the inherited ...
     81 1. the kernel K creates locally the main thread of process F, and register this thread in the TH_TBL(K,P),
     82 1. the kernel K register this new thread in the scheduler of the core executing the fork() system call, an return.
    8383
    8484At the end of the fork(), the owner cluster for the F process is cluster Z, and the reference cluster is K. This F process contains one single thread running on K.
     
    101101Le code binaire (segments code et data) sera chargé dans la mémoire du cluster cible, lors du traitement des défauts de page.
    102102
    103 == __4) New thread creation__ ==
     103== __4) Thread creation__ ==
    104104
    105 Any thread T of any process P, running in any cluster K, can create a new thread NT, on any cluster M, using the pthread_create() system call. The new thread NT will be placed on a core of the M cluster. If the M cluster does not
    106 contain a process descriptor copy for process P (because the NT thread is the first thread of process P in cluster M),
    107 a new process descriptor must be created in cluster M.
     105Any thread T of any process P, running in any cluster K, can create a new thread NT, that will execute on any core in any cluster M. This creation is driven by the pthread_create() system call. The M cluster is called the host cluster. If the M cluster does not contain a process descriptor copy for process P (because the NT thread is the first thread of process P in cluster M), a new process descriptor must be created in cluster M.
    108106 * The target cluster M can be specified by the user application, using the CXY field of the pthread_attr_t argument. If the CXY is not defined (value larger than the max number of cluster), the target cluster M is selected by the kernel K, using the DQDT.
    109107 * The Target core in cluster M can be specified by the user application, using the CORE_LID field of the pthread_attr_t argument. If the CORE_LID is not defined (value larger than the max number of cores in a cluster), the target core is selected by the M kernel.
    110108
    111 Only the local kernel can create or destroy a thread in cluster M for process P, and modify the TH_TBL(M,P).
    112 
    113109=== 4.1) phase 1 ===
    114110
    115 Le noyau du cluster K connait l'identifiant du cluster Z propriétaire de P, puisque cet identifiant est contenu dans le PID.  le noyau de K envoie une RPC_THREAD_USER_CREATE au cluster Z propriétaire. L'argument est une structure pthread_attr_t contenant le PID, le TRDID, la fonction à exécuter et ses arguments, et optionnellement le cluster cible et le core cible.
    116 Le noyau du cluster Z propriétaire de P, ne répond pas immédiatement au cluster demandeur K, mais envoie au cluster cible M une RPC_THREAD_USER_CREATE, avec les mêmes arguments.
     111The kernel K select a target cluster M, and send a RPC_THREAD_USER_CREATE request to cluster M. The argument is a complete structure pthread_attr_t (defined in the ''thread.h'' file in ALMOS-MK), containing the PID, the function to execute and its arguments, and optionally, the target cluster and target core. This RPC should return a the thread TRDID.
    117112
    118113=== 4.2) phase 2 ===
    119114
    120 Le noyau du cluster M vérifie s’il possède une copie du descripteur du processus P.
    121 Si ce n’est pas le cas il crée et un nouveau descripteur du processus P dans M, et alloue les structures PT(P,M), VSL(P,M), FDT(P,M), TRDL(P,M).
    122 Il initialise les structures VSL et FDT en utilisant des remote_memcpy() depuis le cluster Z vers le cluster M.
    123 La structure PT(P,M) reste vide, et se remplira à la demande lors du traitement des défauts de page.
    124 Quand il est sûr de posséder une copie du descripteur de processus P, il sélectionne un coeur charger d’exécuter le nouveau thread T’, Il attribue un TRDID au thread à T’, crée un descripteur de thread et l’enregistre dans la TRDL(P,M).
    125 Finalement, il enregistre T’ dans l’ordonnanceur du coeur sélectionné, et renvoie le TRDID dans la réponse RPC au cluster Z.
     115To execute this RPC, the kernel M will make a local copy of the pthread_attr_t structure, and execute the following steps:
     116 1. The kernel M checks if it contains a copy of the P process descriptor.
     117 1. If not, the kernel M creates a process descriptor copy from the reference P process descriptor, using a remote_memcpy(), and using the cluster_get_reference_process_from_pid() to get the extended pointer on reference cluster. It allocates memory for the associated structures PG_TBL(M,P), VSEG_LIST(M,P), FD_TBL(M,P). It initializes (partially) these structures by using remote_memcpy() from the reference cluster. The PG_TBL structure will be filled by the page faults.
     118 1. The kernel M register this new process descriptor in the COPIES_LIST and LOCAL_LIST.
     119 1. When the local process descriptor is set, the kernel M select the core that will execute the thread, allocates a TRDID to this thread, and creates the thread descriptor for NT.
     120 1. The kernel M registers the thread descriptor in the local process descriptor  TH_TBL(M,P), and in the selected core scheduler.
     121 1. The kernel M returns the TRDID to the client cluster K, and acknowledge the RPC.
    126122
    127 === 4.3) Phase 3 ===
     123== __5) Thread destruction__ ==
    128124
    129 Le noyau du cluster Z propriétaire de P alloue un descripteur de thread et l’enregistre dans sa TRDL(P,Z).
    130 Cette TRDL(P,Z)  doit en effet contenir la totalité des descripteurs de threads du processus P.
    131 Puis le noyau de Z renvoie une réponse RPC au cluster K.
    132 
    133 == __5) Destruction d’un thread__ ==
    134 
    135 La destruction d’un thread TRDID s’exécutant sur un cluster K est déclenchée :
    136 - soit par le thread lui-même (appel système pthread_exit() ),
    137 - soit par le noyau du cluster hôte K où s’exécute le thread,
    138 - soit par un signal provenant d’un autre cluster.
    139 Dans tous les cas, c’est le noyau du cluster hôte K, qui pilote cette destruction.
     125The destruction of a thread TRDID 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.
    140126
    141127=== 5.1) phase 1 ===
    142128
    143 Le noyau du cluster K envoie une THREAD_EXIT_RPC au cluster Z propriétaire du processus P,
    144 pour qu’il mette à jour la TRDL(P,Z) qui contient tous les thread de P. Les arguments sont le PID et le TRDID.
     129
    145130
    146131=== 5.2) phase 2 ===
    147132
    148 Le noyau du cluster Z propriétaire de P met à jour sa TRDL(P,Z), en supprimant le thread TRDID, puis envoie la réponse RPC au cluster K.
     133
    149134
    150135=== 5.3) phase 3 ===
     
    155140
    156141== __5) Destruction d’un processus__
    157 
    158 La destruction d’un processus P est déclenchée :
    159 - soit par un thread du processus P s’exécutant sur un cluster X quelconque (appel système exit() ),
    160 - soit par le noyau du cluster Z propriétaire P,
    161 - soit par un signal provenant d’un autre cluster
    162 Dans tous les cas, c’est le noyau du cluster Z propriétaire de P, qui pilote cette destruction.
    163142
    164143=== 5.1) phase 1 ===