111 | | Any thread T of any process P, running in any cluster K, can create a new thread NT in any cluster M. This creation is initiated by the ''pthread_create'' system call. The target M cluster is called the host cluster. |
112 | | * 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 by the user, the target cluster M is selected by the kernel K, using the DQDT. |
113 | | * 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 by the user, the target core is selected by the target kernel M. |
| 111 | Any user thread T of any process P, running in any cluster K, can create a new thread NT in any cluster K'. This creation is initiated by the ''pthread_create'' system call. |
| 112 | * The target cluster K' can be specified by the user application, using the CXY field of the pthread_attr_t argument. If the CXY is not defined by the user, the target cluster K' is selected by the kernel K, using the DQDT. |
| 113 | * The target core in cluster K' 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 by the user, the target core is selected by the target kernel K'. |
115 | | If the target cluster M is different from the client cluster, the cluster K 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 the thread TRDID. |
| 115 | If the target cluster K' is different from the client cluster K, the cluster K send a RPC_THREAD_USER_CREATE request to cluster K'. 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 the thread TRDID. |
117 | | * If the target cluster M does not contain a copy of the P process descriptor, 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 GPT(M,P), VSL(M,P), FDT(M,P). These structures being used as read-only caches will be dynamically filled by the page faults. This new process descriptor is registered in the COPIES_LIST and in the LOCAL_LIST. |
118 | | * When the local process descriptor is set, the kernel M select the core that will execute the new thread, allocates a TRDID to this thread, creates the thread descritor, and registers it in the local process descriptor, and in the selected core scheduler. |
| 117 | * If the target cluster K' does not contain a copy of the P process descriptor, the kernel K' 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 GPT(M,P), VSL(M,P), FDT(M,P). These structures being used as read-only caches will be dynamically filled by the page faults. This new process descriptor is registered in the COPIES_LIST and in the LOCAL_LIST. |
| 118 | * When the local process descriptor is set, the kernel K' select the core that will execute the new thread, allocates a TRDID to this thread, creates the thread descritor, and registers it in the local process descriptor, and in the selected core scheduler. |
124 | | The unique method to destroy a thread is to set the THREAD_FLAG_REQ_KILL or THREAD_FLAG_REQ_EXIT flags in the ''flags'' field of the thread descriptor. The thread will be asynchronously deleted by the scheduler at the next scheduling point. |
125 | | It detach the thread from the scheduler, detach the thread from the local process descriptor, and releases the memory allocated to the thread descriptor. The destruction request can be done by the ''target'' thread itself (for an exit), or it can be done by another ''killer'' thread (for a kill). |
| 124 | The unique method to destroy a thread is to call the '''thread_kill()''' function, that set the THREAD_FLAG_REQ_DELETE in the ''flags'' field of the target thread descriptor. The thread will be asynchronously deleted by the scheduler at the next scheduling point, |
| 125 | that calls the ''thread_destroy()'' function. This function detach the thread from the scheduler, detach the thread from the local process descriptor, and releases the memory allocated to the thread descriptor. The '''thread_kill(''') function can be called by the ''target'' thread itself (for an exit), or it can be done by another ''killer'' thread (for a kill). |
133 | | * the killer thread sets the BLOCKED_GLOBAL bit in the target thread ''blocked'' field, |
134 | | * for an exit, the killer thread sets the THREAD_FLAG_REQ_EXIT bit in the target thread ''flags'' field, |
135 | | * for a kill, the killer thread sets the THREAD_FLAG_REQ_KILL bit in the target thread ''flags'' field, |
| 133 | * the killer thread sets the THREAD_BLOCKED_GLOBAL bit in the target thread ''blocked'' field, |
| 134 | * the killer thread sets the THREAD_FLAG_REQ_DELETE bit in the target thread ''flags'' field, |
148 | | The thread destruction is more complex if the target thread T is running in ATTACHED mode, because another - possibly remote - J thread, executing the ''pthread_join'' system call, must be informed of the termination of thread T. As the ''thread_kill()'' function, executed by the killer thread K, and the ''sys_thread_join()'', executed by the joining thread J, can be executed in any order, this requires a "rendez-vous": The first arrived thread blocks and deschedules. It will be unblocked by the other thread. |
| 147 | The thread destruction is more complex if the target thread T is running in ATTACHED mode, because another joining thread J, executing the ''pthread_join()'' system call, must be informed of the termination of thread T. As the ''thread_kill()'' function, executed by the killer thread K, and the ''sys_thread_join()'', executed by the joining thread J, can be executed in any order, this requires a "rendez-vous": The first arrived thread blocks and deschedules. It will be unblocked by the other thread. |