Changeset 436 for trunk/kernel/syscalls/sys_exit.c
- Timestamp:
- Mar 7, 2018, 9:02:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_exit.c
r435 r436 41 41 process_t * process = this->process; 42 42 pid_t pid = process->pid; 43 trdid_t trdid = this->trdid; 43 44 44 45 #if CONFIG_DEBUG_SYS_EXIT … … 55 56 56 57 // exit must be called by the main thread 57 if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID( t his->trdid ) != 0) )58 if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID( trdid ) != 0) ) 58 59 { 59 60 60 61 #if CONFIG_DEBUG_SYSCALLS_ERROR 61 printk("\n[ERROR] %s must be called by thread 0 in process owner cluster\n" 62 " trdid = %x / pid = %x / local_cxy = %x\n", 63 __FUNCTION__, this->trdid, pid, local_cxy ); 62 printk("\n[ERROR] in %s : calling thread %x is not thread 0 in owner cluster %x\n", 63 __FUNCTION__, trdid, owner_cxy ); 64 64 #endif 65 65 this->errno = EINVAL; … … 73 73 process->term_state = status; 74 74 75 // remove TXT ownership from owner process descriptor 76 process_txt_reset_ownership( XPTR( local_cxy , process ) ); 75 #if( CONFIG_DEBUG_SYS_EXIT & 1) 76 printk("\n[DBG] %s : set exit status in process term_state\n", __FUNCTION__); 77 #endif 77 78 78 // block all process threads in all clusters79 process_ sigaction( pid , BLOCK_ALL_THREADS);79 // remove process from TXT list 80 process_txt_detach( XPTR( local_cxy , process ) ); 80 81 81 // mark all process threads in all clusters for delete 82 #if( CONFIG_DEBUG_SYS_EXIT & 1) 83 printk("\n[DBG] %s : removed from TXT list\n", __FUNCTION__); 84 #endif 85 86 // mark for delete all process threads in all clusters (but the main) 82 87 process_sigaction( pid , DELETE_ALL_THREADS ); 88 89 #if( CONFIG_DEBUG_SYS_EXIT & 1) 90 printk("\n[DBG] %s : deleted all other threads than main\n", __FUNCTION__); 91 #endif 83 92 84 93 // restore IRQs 85 94 hal_restore_irq( save_sr ); 86 95 87 // atomically update owner process descriptor term_state 96 // block the main thread itself 97 thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_GLOBAL ); 98 99 #if( CONFIG_DEBUG_SYS_EXIT & 1) 100 printk("\n[DBG] %s : blocked the main thread\n", __FUNCTION__); 101 #endif 102 103 // atomically update owner process descriptor term_state to ask 104 // the parent process sys_wait() function to delete this main thread 88 105 hal_remote_atomic_or( XPTR( local_cxy , &process->term_state ) , 89 106 PROCESS_TERM_EXIT ); 107 108 #if( CONFIG_DEBUG_SYS_EXIT & 1) 109 printk("\n[DBG] %s : set EXIT flag in process term_state\n", __FUNCTION__); 110 #endif 111 90 112 hal_fence(); 91 113 … … 97 119 #endif 98 120 121 // main thread deschedule 122 sched_yield( "process exit" ); 123 124 // this code should never be executed 125 assert( false , __FUNCTION__ , "this code should not be executed...\n" ); 99 126 return 0; 100 127
Note: See TracChangeset
for help on using the changeset viewer.