Changeset 436 for trunk/kernel/kern/thread.h
- Timestamp:
- Mar 7, 2018, 9:02:03 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.h
r428 r436 70 70 71 71 #define THREAD_FLAG_DETACHED 0x0001 /*! This thread is detached from parent */ 72 #define THREAD_FLAG_JOIN_DONE 0x0002 /*! Parent thread made a join */ 73 #define THREAD_FLAG_SCHED 0x0004 /*! Scheduling required for this thread */ 74 #define THREAD_FLAG_REQ_ACK 0x0008 /*! Acknowledge required from scheduler */ 75 #define THREAD_FLAG_REQ_DELETE 0x0010 /*! Destruction required from scheduler */ 72 #define THREAD_FLAG_JOIN_DONE 0x0002 /*! Parent thread made a join request */ 73 #define THREAD_FLAG_KILL_DONE 0x0004 /*! This thread received a kill request */ 74 #define THREAD_FLAG_SCHED 0x0008 /*! Scheduling required for this thread */ 75 #define THREAD_FLAG_REQ_ACK 0x0010 /*! Acknowledge required from scheduler */ 76 #define THREAD_FLAG_REQ_DELETE 0x0020 /*! Destruction required from scheduler */ 76 77 77 78 /*************************************************************************************** … … 88 89 #define THREAD_BLOCKED_USERSYNC 0x0100 /*! thread wait (cond/mutex/barrier) */ 89 90 #define THREAD_BLOCKED_RPC 0x0200 /*! thread wait RPC completion */ 90 #define THREAD_BLOCKED_ DEV_ISR0x0400 /*! thread DEV wait ISR */91 #define THREAD_BLOCKED_ISR 0x0400 /*! thread DEV wait ISR */ 91 92 #define THREAD_BLOCKED_WAIT 0x0800 /*! thread parent wait child termination */ 92 93 … … 153 154 154 155 remote_spinlock_t join_lock; /*! lock protecting the join/exit */ 155 void * join_value; /*! exit_value used in case of join */ 156 xptr_t join_xp; /*! extended pointer on joining thread */ 156 xptr_t join_xp; /*! joining/killer thread extended pointer */ 157 157 158 158 uint32_t * ack_rsp_count; /*! pointer on acknowledge response counter */ … … 386 386 387 387 /*************************************************************************************** 388 * This function is called to handle the "pthread_cancel" system call. 389 * It allows a killer thread to kill one single target thread. 390 * The killer thread must be running in the same cluster as the target thread. 391 * If not, the client thread must use the RPC_THREAD_KILL. 392 * - When the killer thread is running on the same core as the target thread, 393 * this function simply set the BLOCKED_ GLOBAL bit and the REQ_DELETE flag 394 * in the target thread descriptor and return. 395 * - When the killer thread is running on a different core than the target thread, 396 * the killer set the BLOCKED_GLOBAL bit and the REQ_ACK flag in target thread, 397 * to ask the scheduler to confirm that the target is blocked and not running. 398 * Then, it set the REQ_DELETE flag in the target thread and return. 399 * In both cases, the actual target thread destruction is done by the scheduler 400 * at the next scheduling point. 401 *************************************************************************************** 402 * @ thread : local pointer on the target thread. 403 **************************************************************************************/ 404 void thread_kill( thread_t * thread ); 405 406 /*************************************************************************************** 407 * This function registers a blocking cause in the target thread "blocked" bit vector. 408 * Warning : this function does not deschedule the calling thread, and the descheduling 388 * This function is called to handle the four pthread_cancel(), pthread_exit(), 389 * kill() and exit() system calls. It kills a "target" thread identified by the 390 * <thread_xp> argument. The "killer" thread can be the "target" thread, when the 391 * <is_exit> argument is true. The "killer" thread can run in any cluster, 392 * as it uses remote accesses. 393 * If the "target" thread is running in "attached" mode, and the <is_forced> argument 394 * is false, this function implements the required sychronisation with the joining 395 * thread, blocking the "killer" thread until the pthread_join() syscall is executed. 396 * To delete the target thread, this function sets the THREAD_FLAG_REQ_DELETE bit 397 * and the THREAD BLOCKED_GLOBAL bit in the target thread, and the actual destruction 398 * is asynchronously done by the scheduler at the next scheduling point. 399 *************************************************************************************** 400 * @ thread_xp : extended pointer on the target thread. 401 * @ is_exit : the killer thread is the target thread itself. 402 * @ is_forced : the killing does not depends on the attached mode. 403 **************************************************************************************/ 404 void thread_kill( xptr_t thread_xp, 405 bool_t is_exit, 406 bool_t is_forced ); 407 408 /*************************************************************************************** 409 * This function registers a blocking cause defined by the <cause> argument 410 * in a remote thread descriptor identified by the <thread_xp> argument. 411 * We need an extended pointer, because this function can be called by another thread 412 * than the target thread, executing the sys_kill() function. 413 * WARNING : this function does not deschedule the target thread, and the descheduling 409 414 * must be explicitely forced by a sched_yield(). 410 415 *************************************************************************************** 411 * @ thread : local pointer on targetthread descriptor.412 * @ cause : mask defining the cause (one hot).413 **************************************************************************************/ 414 void thread_block( thread_t * thread,415 uint32_t 416 417 /*************************************************************************************** 418 * This function resets the bit identified by the cause argument in the "blocked"419 * bit vector of a remote thread descriptor, using an atomic access.416 * @ thread_xp : extended pointer on remote thread descriptor. 417 * @ cause : mask defining the cause (one hot). 418 **************************************************************************************/ 419 void thread_block( xptr_t thread_xp, 420 uint32_t cause ); 421 422 /*************************************************************************************** 423 * This function resets the bit identified by the <cause> argument in a remote 424 * thread descriptor identified by the <thread_xp> argument. 420 425 * We need an extended pointer, because the client thread of an I/O operation on a 421 426 * given device is not in the same cluster as the associated device descriptor. 422 * W arning: this function does not reschedule the remote thread.427 * WARNING : this function does not reschedule the remote thread. 423 428 * The scheduling can be forced by sending an IPI to the core running the remote thread. 424 429 *************************************************************************************** 425 * @ thread : extended pointer onthe remote thread.426 * @ cause : mask defining the cause (one hot).430 * @ thread_xp : extended pointer the remote thread. 431 * @ cause : mask defining the cause (one hot). 427 432 * @ return non zero if the bit-vector was actually modified / return 0 otherwise 428 433 **************************************************************************************/ 429 uint32_t thread_unblock( xptr_t thread ,434 uint32_t thread_unblock( xptr_t thread_xp, 430 435 uint32_t cause ); 431 436 … … 449 454 450 455 /*************************************************************************************** 451 * This function handles all pending signals for the thread identified by the <thread>452 * argument. It is called each time the core exits the kernel, after handling an453 * interrupt, exception or syscall.454 * TODO This function is not implemented.455 ***************************************************************************************456 * @ thread : local pointer on target thread.457 **************************************************************************************/458 void thread_signals_handle( thread_t * thread );459 460 /***************************************************************************************461 456 * This function returns the extended pointer on a thread descriptor identified 462 457 * by its thread identifier, and process identifier.
Note: See TracChangeset
for help on using the changeset viewer.