78 | | FIRST SPECIFICATION (DEPRECATED) |
| 78 | NEW SPECIFICATION |
| 79 | |
| 80 | 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. |
| 81 | 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, because only the reference cluster Z contains a complete description of the parent process VSL and GPT. |
| 82 | |
| 83 | 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 VSL, but the ALMOS-MKH replication policy depends on the vseg type: |
| 84 | * 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 replicated parent GPT copies in all cluster. |
| 85 | * for the '''STACK''' vseg(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 (parent and child) GPTs. This require to update all replicated parent GPT copies in all cluster. |
| 86 | * for the '''CODE''' vsegs (that must be replicated in all clusters containing a thread), all vsegs registered in the reference parent VSL(Z,P) are registered in the child reference VSL(Y,C), but the reference child GPT(Y,C) is not updated by the fork: It will be dynamically updated on demand in case of page fault. |
| 87 | * 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. |
| 88 | |
| 89 | 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. |
| 90 | Two slots corresponding to two CPU registers must be specifically initialized: |
| 91 | * the '''thread pointer''' register contains the current thread descriptor address. This '''thread pointer''' register cannot have the same value for parent and child. |
| 92 | * the '''stack pointer''' register define the current kernel stack. ALMOS-MLH 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. |
| 93 | |
| 94 | OLD SPECIFICATION (DEPRECATED) |
90 | | SECOND SPECIFICATION |
91 | | |
92 | | 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. |
93 | | The calling thread an 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, because only the reference cluster Z contains a complete description of the parent process VSL and GPT. |
94 | | |
95 | | 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 VSL, but the ALMOS-MKH replication policy depends on the vseg type: |
96 | | * 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 replicated parent GPT copies in all cluster. |
97 | | * for the '''STACK''' vseg(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 (parent and child) GPTs. This require to update all replicated parent GPT copies in all cluster. |
98 | | * for the '''CODE''' vsegs (that must be replicated in all clusters containing a thread), all vsegs registered in the reference parent VSL(Z,P) are registered in the child reference VSL(Y,C), but the reference child GPT(Y,C) is not updated by the fork: It will be dynamically updated on demand in case of page fault. |
99 | | * 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. |
100 | | |
101 | | 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. |
102 | | Two CPU registers must be specifically initialized: |
103 | | * the '''thread pointer''' register contains the current thread descriptor address. This '''thread pointer''' register cannot have the same value for parent and child. |
104 | | * the '''stack pointer''' register define the current kernel stack. ALMOS-MLH uses a specific kernel stack when an user thread enters the kernel, and this kernel stack is implemented in the thread descriptor. Parent and child cannot uses the same kernel stack. The parent kernel stack content must be copied to the child kernel stack, |
105 | | and the '''stack pointer''' register cannot have the same value for parent and child. |
106 | | |
109 | | After a fork() system call, the C process can execute an exec() system call. This system call forces the C process to migrate from the K cluster to the owner cluster Z, to execute a new application, while keeping the same PID. Therefore a new reference process descriptor , and the associated main thread are created in the Z cluster, and initialized from values found in the .elf file defining the new application. The Z cluster becomes both the owner and the reference cluster of the C process. The old reference process descriptor for C, and the associated thread in K are deleted. |
| 108 | NEW SPECIFICATION |
| 109 | |
| 110 | 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. |
| 111 | |
| 112 | OLD SPECIFICATION (DEPRECATED) |