Changeset 409 for trunk/kernel/kern/process.h
- Timestamp:
- Dec 20, 2017, 4:51:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/process.h
r408 r409 54 54 55 55 /********************************************************************************************* 56 * This enum defines the actions that can be executed by the process_signal() function. 57 ********************************************************************************************/ 58 59 enum process_sigactions 60 { 61 BLOCK_ALL_THREADS, 62 UNBLOCK_ALL_THREADS, 63 DELETE_ALL_THREADS, 64 }; 65 66 /********************************************************************************************* 56 67 * This structure defines an array of extended pointers on the open file descriptors 57 68 * for a given process. We use an extended pointer because the open file descriptor … … 76 87 * - The PID 16 LSB bits contain the LPID (Local Process Index) 77 88 * - The PID 16 MSB bits contain the owner cluster CXY. 78 * In each cluster, the process manager allocates LPID values for the process that are 79 * allocated to this cluster. 80 * The process descriptor for a PID process is replicated in all clusters containing 81 * at least one thread of the PID process, with the following rules : 82 * 89 * In each cluster, the process manager allocates the LPID values for the process that 90 * are owned by this cluster. 91 * The process descriptor is replicated in all clusters containing at least one thread 92 * of the PID process, with the following rules : 83 93 * 1) The <pid>, <ppid>, <ref_xp>, <vfs_root_xp>, <vfs_bin_xp> fields are defined 84 94 * in all process descriptor copies. 85 95 * 2) The <vfs_cwd_xp> and associated <cwd_lock>, that can be dynamically modified, 86 96 * are only defined in the reference process descriptor. 87 * 2) The <vmm>, containing the list of registered vsegs, and the page table, are only 88 * complete in the reference process cluster, other copies are read-only caches. 97 * 2) The <vmm>, containing the VSL (list of registered vsegs), and the GPT (generic 98 * page table), are only complete in the reference process cluster, other copies 99 * are actually use as read-only caches. 89 100 * 3) the <fd_array>, containing extended pointers on the open file descriptors, is only 90 101 * complete in the reference process cluster, other copies are read-only caches. … … 95 106 * 6) The <brothers_list>, <local_list>, <copies_list>, <th_tbl>, <th_nr>, <th_lock> fields 96 107 * are defined in all process descriptors copies. 97 * 7) The <sig_mgr> field is only defined in the reference cluster. TODO98 108 ********************************************************************************************/ 99 109 … … 130 140 131 141 remote_spinlock_t sync_lock; /*! lock protecting sem,mutex,barrier,condvar lists */ 132 133 sig_mgr_t sig_mgr; /*! embedded signal manager TODO [AG] */134 142 } 135 143 process_t; … … 137 145 /********************************************************************************************* 138 146 * This structure defines the information required by the process_make_exec() function 139 * to create a new reference process descriptor, and the associated main thread, 140 * in the parent process owner cluster. 147 * to create a new reference process descriptor, and the associated main thread. 141 148 ********************************************************************************************/ 142 149 … … 176 183 /********************************************************************************************* 177 184 * This function allocates memory and initializes the "process_init" descriptor and the 178 * associated "thread_init" descriptor in the local cluster. It is called once at the end179 * of the kernel initialisation procedure, by the local kernel process.185 * associated "thread_init" descriptor. It is called once at the end of the kernel 186 * initialisation procedure, by the kernel process in cluster_IO. 180 187 * The "process_init" is the first user process, and all other user processes will be forked 181 188 * from this process. The code executed by "process_init" is stored in a .elf file, whose 182 * pathname is defined by the CONFIG_PROCESS_INIT_PATH argument.183 * Practically, it builds the exec_info structure, and calls the process_make_exec()184 * function, that make the real job.189 * pathname is defined by the CONFIG_PROCESS_INIT_PATH configuration variable. 190 * The process_init streams are defined by the CONFIG_INIT_[STDIN/STDOUT/STDERR] variables. 191 * Its local process identifier is 1, and parent process is the local kernel process_zero. 185 192 ********************************************************************************************/ 186 193 void process_init_create(); … … 200 207 * descriptor, defined by the <model_xp> argument. The <process> descriptor, the <pid>, and 201 208 * the <ppid> arguments must be previously defined by the caller. 202 * It can be called by t hreefunctions, depending on the process type:203 * 1) if "process" is the user"process_init", the parent is the kernel process. It is209 * It can be called by two functions, depending on the process type: 210 * 1) if "process" is the "process_init", the parent is the kernel process. It is 204 211 * called once, by the process_init_create() function in cluster[xmax-1][ymax-1]. 205 212 * 2) if the caller is the process_make_fork() function, the model is generally a remote 206 213 * process, that is also the parent process. 214 207 215 * 3) if the caller is the process_make_exec() function, the model is always a local process, 208 * but the parent is the parent of the model process.209 * 216 * and the parent is the parent of the model process. DEPRECATED [AG] 217 210 218 * The following fields are initialised (for all process but process_zero). 211 219 * - It set the pid / ppid / ref_xp fields. 212 * - It initializes an empty VMM (no vsegs registered in VSL and GPT).220 * - It initializes the VMM (register the kentry, args, envs vsegs in VSL) 213 221 * - It initializes the FDT, defining the three pseudo files STDIN / STDOUT / STDERR. 214 222 * - It set the root_xp, bin_xp, cwd_xp fields. … … 251 259 252 260 /********************************************************************************************* 253 * This function kills a user process in a given cluster. 254 * It can be directly called in the reference cluster, or it can be called through the 255 * PROCESS_KILL RPC. 256 * - In a first loop, it set the THREAD_SIG_KILL signal to all threads of process. 257 * - In a second loop, it wait, for each thread the reset of the THREAD_SIG_KILL signal 258 * by the scheduler, and completes the thread descriptor destruction. 261 * This function returns a printable string defining the action for process_signa(). 262 ********************************************************************************************* 263 * @ action_type : BLOCK_ALL_THREADS / UNBLOCK_ALL_THREADS / DELETE_ALL_THREADS 264 * @ return a string pointer. 265 ********************************************************************************************/ 266 char * process_action_str( uint32_t action_type ); 267 268 /********************************************************************************************* 269 * This function allows any thread running in any cluster to block, unblock or delete 270 * all threads of a given process identified by the <process> argument, dependig on the 271 * <acion_type> argument. 272 * It can be called by the sys_kill() or sys_exit() functions to handle the "kill" & "exit" 273 * system calls, or by the process_make_exec() function to handle the "exec" system call. 274 * It must be executed in the owner cluster for the target process (using the relevant RPC 275 * (RPC_PROCESS_SIGNAL or RPC_PROCESS_EXEC) if the client thread in not running in the 276 * owner cluster. 277 * It uses the multicast, non blocking, RPC_PROCESS_KILL to send the signal to all process 278 * copies in parallel, block & deschedule when all signals have been sent, and finally 279 * returns only when all responses have been received and the operation is completed. 259 280 ********************************************************************************************* 260 281 * @ process : pointer on the process descriptor. 261 ********************************************************************************************/ 262 void process_kill( process_t * process ); 282 * @ action_type : BLOCK_ALL_THREADS / UNBLOCK_ALL_THREADS / DELETE_ALL_THREADS 283 ********************************************************************************************/ 284 void process_sigaction( process_t * process, 285 uint32_t action_type ); 286 287 /********************************************************************************************* 288 * This function blocks all threads of a given user process in a given cluster. 289 * It is always called by a local RPC thread, through the multicast RPC_PROCESS_KILL. 290 * It loop on all local threads of the process, requesting the relevant schedulers to 291 * block and deschedule these threads, using IPI if required. The threads are not detached 292 * from the scheduler, and not detached from the local process. 293 * It acknowledges the client thread in the owner cluster only when all process threads 294 * are descheduled and blocked on the BLOCKED_GLOBAL condition, using the <rsp_xp> argument. 295 ********************************************************************************************* 296 * @ process : pointer on the target process descriptor. 297 * @ rsp_xp : extended pointer on the response counter. 298 * # client_xp : extended pointer on client thread descriptor. 299 ********************************************************************************************/ 300 void process_block( process_t * process, 301 xptr_t rsp_xp, 302 xptr_t client_xp ); 303 304 /********************************************************************************************* 305 * This function unblocks all threads of a given user process in a given cluster. 306 * It is always called by a local RPC thread, through the multicast RPC_PROCESS_KILL. 307 * It loops on local threads of the process, to reset the BLOCKED_GLOBAL bit in all threads. 308 * It acknowledges directly the client thread in the owner cluster when this is done, 309 * using the <rsp_xp> argument. 310 ********************************************************************************************* 311 * @ process : pointer on the process descriptor. 312 * @ rsp_xp : extended pointer on the response counter. 313 * # client_xp : extended pointer on client thread descriptor. 314 ********************************************************************************************/ 315 void process_unblock( process_t * process, 316 xptr_t rsp_xp, 317 xptr_t client_xp ); 318 319 /********************************************************************************************* 320 * This function delete all threads descriptors, of given user process in a given cluster. 321 * It is always called by a local RPC thread, through the multicast RPC_PROCESS_KILL. 322 * It detach all process threads from the scheduler, detach the threads from the local 323 * process, and release the local memory allocated to threads descriptors (including the 324 * associated structures such as CPU and FPU context). Finally, it release the memory 325 * allocated to the local process descriptor itself, but only when the local cluster 326 * is NOT the process owner, but only a copy. It acknowledges directly the client thread 327 * in the owner cluster, using ithe <rsp_xp> argument. 328 ********************************************************************************************* 329 * @ process : pointer on the process descriptor. 330 * @ rsp_xp : extended pointer on the response counter. 331 * # client_xp : extended pointer on client thread descriptor. 332 ********************************************************************************************/ 333 void process_delete( process_t * process, 334 xptr_t rsp_xp, 335 xptr_t client_xp ); 263 336 264 337 /********************************************************************************************* … … 274 347 275 348 /********************************************************************************************* 276 * This function implements the exec() system call, and is called by the sys_exec() function. 277 * It is also called by the process_init_create() function to build the "init" process. 349 * This function implements the "exec" system call, and is called by the sys_exec() function. 278 350 * The "new" process keep the "old" process PID and PPID, all open files, and env variables, 279 351 * the vfs_root and vfs_cwd, but build a brand new memory image (new VMM from the new .elf). 280 * It actually creates a "new" reference process descriptor, saves all relevant information281 * from the "old" referenceprocess descriptor to the "new" process descriptor.352 * It actually creates a "new" reference process descriptor, and copies all relevant 353 * information from the "old" process descriptor to the "new" process descriptor. 282 354 * It completes the "new" process descriptor, from information found in the <exec_info> 283 355 * structure (defined in the process.h file), that must be built by the caller. 284 356 * It creates and initializes the associated main thread. It finally destroys all copies 285 * of the "old" process in all clusters, and all theold associated threads.357 * of the "old" process in all clusters, and destroys all old associated threads. 286 358 * It is executed in the local cluster, that becomes both the "owner" and the "reference" 287 359 * cluster for the "new" process. … … 293 365 294 366 /********************************************************************************************* 295 * This function implement the fork()system call, and is called by the sys_fork() function.367 * This function implements the "fork" system call, and is called by the sys_fork() function. 296 368 * It allocates memory and initializes a new "child" process descriptor, and the 297 369 * associated "child" thread descriptor in the local cluster. This function can involve 298 370 * up to three different clusters : 299 371 * - the local (child) cluster can be any cluster defined by the sys_fork function. 300 * - the parent cluster must be the reference cluster for the parent process.301 * - the client cluster containing the thread requesting the fork can be any cluster.372 * - the parent cluster must be the reference cluster for the parent process. 373 * - the client cluster containing the thread requesting the fork can be any cluster. 302 374 * The new "child" process descriptor is initialised from informations found in the "parent" 303 375 * reference process descriptor, containing the complete process description. … … 315 387 pid_t * child_pid, 316 388 struct thread_s ** child_thread_ptr ); 389 390 /********************************************************************************************* 391 * This function implement the "exit" system call, and is called by the sys_exit() function. 392 * It must be executed by a thread running in the calling process owner cluster. 393 * It uses twice the multicast RPC_PROCESS_SIGNAL to first block all process threads 394 * in all clusters, and then delete all thread and process descriptors. 395 ********************************************************************************************* 396 * @ process : pointer on process descriptor in owner cluster. 397 * @ status : exit return value. 398 ********************************************************************************************/ 399 void process_make_exit( process_t * process, 400 uint32_t status ); 401 402 /********************************************************************************************* 403 * This function implement the "kill" system call, and is called by the sys_kill() function. 404 * It must be executed by a thread running in the target process owner cluster. 405 * Only the SIGKILL, SIGSTOP, and SIGCONT signals are supported. 406 * User defined handlers are not supported. 407 * It uses once or twice the multicast RPC_PROCESS_SIGNAL to block, unblock or delete 408 * all process threads in all clusters, and then delete process descriptors. 409 ********************************************************************************************* 410 * @ process : pointer on process descriptor in owner cluster. 411 * @ sig_id : signal type. 412 ********************************************************************************************/ 413 void process_make_kill( process_t * process, 414 uint32_t sig_id ); 415 317 416 318 417 /******************** File Management Operations ****************************************/ … … 376 475 377 476 /********************************************************************************************* 378 * This function copies all non-zero entries from a remote <src_xp> fd_array, 379 * embedded in a process descriptor, to another remote <dst_xp> fd_array, embedded 380 * in another process descriptor. The calling thread can be running in any cluster. 477 * This function copies all non-zero entries (other than the three first stdin/stdout/stderr) 478 * from a remote <src_xp> fd_array, embedded in a process descriptor, to another remote 479 * <dst_xp> fd_array, embedded in another process descriptor. 480 * The calling thread can be running in any cluster. 381 481 * It takes the remote lock protecting the <src_xp> fd_array during the copy. 382 482 * For each involved file descriptor, the refcount is incremented.
Note: See TracChangeset
for help on using the changeset viewer.