Changes between Version 48 and Version 49 of processus_thread


Ignore:
Timestamp:
Dec 6, 2017, 7:43:37 PM (7 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v48 v49  
    7676=== 3.1) fork() ===
    7777
    78 The fork() system call is the only method to create a new process. A thread of parent process P, running in a cluster X,  executes the fork() system call to create a child process C on a remote cluster Y, that will  become both the owner and the reference cluster for the C process. A new process descriptor, and a new thread descriptor must be created and initialized in target cluster Y for the child process.
    79 The calling thread  can run in any cluster. If the target cluster Y is different from the calling thread cluster X, the calling thread must use a RPC to ask the target cluster Y to do the work, because only the target cluster Y can allocate memory for the new process and thread descriptor.
     78The fork() system call is the only method to create a new process. A thread of parent process P, running in a cluster X,  executes the fork() system call to create a child process C on a remote cluster Y, that will  become both the owner and the reference cluster for the C process. A new process descriptor, and a new thread descriptor are created and initialized in target cluster Y for the child process.
     79The calling thread  can run in any cluster. If the target cluster Y is different from the calling thread cluster X, the calling thread uses a RPC to ask the target cluster Y to do the work, because only the target cluster Y can allocate memory for the new process and thread descriptor.
    8080
    81 Regarding the process descriptor, a new PID must be allocated in cluster Y.  The child process C inherit the vsegs registered in the parent process reference VSL, but the ALMOS-MKH replication policy depends on the vseg type:
     81Regarding the process descriptor, a new PID is allocated in cluster Y.  The child process C inherit the vsegs registered in the parent process reference VSL, but the ALMOS-MKH replication policy depends on the vseg type:
    8282 * for the '''DATA, MMAP, REMOTE''' vsegs (containing shared, non replicated data), all vsegs registered in the parent reference VSL(Z,P) are registered in the child  reference VSL(Y,C), and all valid GPT entries in the reference parent GPT(Z,P) are copied in the child reference GPT(Y,C). For all pages, the WRITABLE flag is reset and the COW flag is set, in both (parent and child) GPTs. This require to update all corresponding entries in the parent GPT copies (in clusters other than the reference).
    8383 * for the '''STACK''' vsegs (that are private), only one vseg is registered in the child reference VSL(Y,C). This vseg contains the user stack of the user thread requesting the fork, running in cluster X. All valid GPT entries in the parent GPT(X,P) are copied in the child GPT(Y,C). For all pages, the WRITABLE flag is reset and the COW flag is set, in both (client and child) GPTs.
     
    8585 * for the '''FILE''' vsegs (containing shared memory mapped files), all vsegs registered in the reference parent VSL(Z,P) are registered in the child  reference VSL(Y,C), and all valid entries registered in the reference parent GPT(Z,P) are copied in the reference child GPT(Y,C). The COW flag is not set for these shared data.
    8686
    87 Regarding the thread descriptor, a new TRDID must be allocated in cluster Y, and the calling parent thread context (current values stored in the CPU and FPU registers) must be saved in the child thread CPU and FPU contexts, to be restored when the child thread will be selected for execution.
    88 Two slots corresponding to two CPU registers must be specifically initialized:
     87Regarding the thread descriptor, a new TRDID is allocated in cluster Y, and the calling parent thread context (current values stored in the CPU and FPU registers) is saved in the child thread CPU and FPU contexts, to be restored when the child thread will be selected for execution.
     88Three CPU context slots are not simple copies of the parent value:
    8989 * the '''thread pointer''' register contains the current thread descriptor address. This '''thread pointer''' register cannot have the same value for parent and child.   
    90  * the '''stack pointer''' register define the current kernel stack. ALMOS-MKH uses a specific kernel stack when an user thread enters the kernel, and this kernel stack is implemented in the thread descriptor. As parent and child cannot use the same kernel stack, the parent kernel stack content must be copied to the child kernel stack, and the '''stack pointer''' register cannot have the same value for parent and child.
    91 
     90 * the '''stack pointer''' register contains the current pointer on the kernel stack. ALMOS-MKH uses a specific kernel stack when an user thread enters the kernel, and this kernel stack is implemented in the thread descriptor. As parent and child cannot use the same kernel stack, the parent kernel stack content is copied to the child kernel stack, and the '''stack pointer''' register cannot have the same value for parent and child.
     91 * the '''page table pointer''' register contains the physical base address of the current generic page table. As the child GPT is a copy of the parent GPT in the child cluster, this '''page table
     92register''' cannot have the same value for parent and child.
    9293
    9394At the end of the fork(), cluster Y is both the owner cluster and the reference cluster for the new  C process, that contains one single thread running in the Y cluster.
     
    9697=== 3.2) exec() ===
    9798
    98 NEW SPECIFICATION
    99 
    100 After a fork() system call, any thread of the the P process can execute an exec() system call. This system call forces the P process to execute a new application, while keeping the same PID. The P process keep all open files, and the environment variables. The P process reference descriptor must be re-initialised from values found in the .elf file defining the new application. All existing threads of process P must be killed (in all clusters), and a new main thread must be created in the reference cluster. The calling thread  can run in any cluster. If the reference cluster Z for process P is different from the calling thread cluster X, the calling thread must use a RPC to ask the reference cluster Z to do the work.
    101 
    102 OLD SPECIFICATION  (DEPRECATED)
    103 
    104  1. The kernel K send an RPC_PROCESS_MIGRATE to cluster Z. The argument are the extended pointer on the C process descriptor in cluster K.
    105  1. To execute this RPC, the kernel Z allocates a new reference process descriptor in cluster Z, and initializes it from informations found in process descriptor in cluster K, using a remote_memcpy().
    106  1. The kernel Z allocates and initializes from disk the  structures contained in the process VMM: GPT(Z,C), VSL(Z,C).
    107  1. The kernel Z creates the main thread associated to process C in cluster Z, initializes it, and register it in the TH_TBL(Z,C).
    108  1. The kernel Z registers this thread in the scheduler of the core selected by the Z kernel and acknowledges the RPC.
    109  1. When receiving the RPC acknowledge, the kernel K destroy the C process descriptor and the associated thread in cluster K, that is not anymore involved in process C execution.
     99After a fork() system call, any thread of the the P process can execute an exec() system call. This system call forces the P process to execute a new application, while keeping the same PID,
     100the same parent process, all open file descriptors, and the environment variables. The existing P process descriptors (both the reference and the copies)  and all associated threads are destroyed. A new process descriptor and a new main thread descriptor are created in the reference cluster, and initialized from values found in the existing process descriptor, and from values contained in the .elf file defining the new application. The calling thread  can run in any cluster. If the reference cluster Z for process P is different from the calling thread cluster X, the calling thread must use a RPC to ask the reference cluster Z to do the work.
    110101
    111102At the end of the exec() system call, the cluster Z is both the owner and the reference cluster for process C, that contains one single thread in cluster Z.
     
    150141== __6) Process destruction__ ==
    151142
    152 The process destruction can be caused by an exit() system call, or by asignal send by another process.
     143The process destruction can be caused by an exit() system call, or by a signal send by another process.
    153144In both case, the owner cluster is in charge of the destruction.
    154145