Changeset 625 for trunk/kernel/syscalls/sys_exit.c
- Timestamp:
- Apr 10, 2019, 10:09:39 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_exit.c
r619 r625 2 2 * sys_exit.c - Kernel function implementing the "exit" system call. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 53 53 pid_t pid = process->pid; 54 54 55 #if (DEBUG_SYS_EXIT || CONFIG_INSTRUMENTATION_SYSCALLS) 56 uint64_t tm_start = hal_get_cycles(); 57 #endif 58 55 59 #if DEBUG_SYS_EXIT 56 uint64_t tm_start;57 uint64_t tm_end;58 tm_start = hal_get_cycles();59 60 if( DEBUG_SYS_EXIT < tm_start ) 60 61 printk("\n[%s] thread[%x,%x] enter / status %x / cycle %d\n", 61 __FUNCTION__, p rocess->pid, this->trdid , status , (uint32_t)tm_start );62 __FUNCTION__, pid, this->trdid , status , (uint32_t)tm_start ); 62 63 #endif 63 64 … … 66 67 owner_cxy = GET_CXY( owner_xp ); 67 68 owner_ptr = GET_PTR( owner_xp ); 68 69 #if (DEBUG_SYS_EXIT & 1)70 if( DEBUG_SYS_EXIT < tm_start )71 printk("\n[%s] thread[%x,%x] get owner process in cluster %x\n",72 __FUNCTION__, process->pid, this->trdid, owner_cxy );73 #endif74 69 75 70 // get local pointer on the main thread … … 80 75 parent_cxy = GET_CXY( parent_xp ); 81 76 parent_ptr = GET_PTR( parent_xp ); 82 83 #if (DEBUG_SYS_EXIT & 1)84 if( DEBUG_SYS_EXIT < tm_start )85 printk("\n[%s] thread[%x,%x] get parent process in cluster %x\n",86 __FUNCTION__, process->pid, this->trdid, parent_cxy );87 #endif88 77 89 78 // get pointers on the parent process main thread … … 96 85 #if( DEBUG_SYS_EXIT & 1) 97 86 if( DEBUG_SYS_EXIT < tm_start ) 98 printk("\n[%s] thread[%x,%x] detached process from TXT\n",99 __FUNCTION__, p rocess->pid, this->trdid );87 printk("\n[%s] thread[%x,%x] detached process %x from TXT\n", 88 __FUNCTION__, pid, this->trdid, pid ); 100 89 #endif 101 90 102 91 // mark for delete all process threads in all clusters, 103 92 // but the main thread and this calling thread 104 process_sigaction( p rocess->pid , DELETE_ALL_THREADS );93 process_sigaction( pid , DELETE_ALL_THREADS ); 105 94 106 95 #if( DEBUG_SYS_EXIT & 1) 107 96 if( DEBUG_SYS_EXIT < tm_start ) 108 printk("\n[%s] thread[%x,%x] deleted all threads but itself\n",109 __FUNCTION__, p rocess->pid, this->trdid );97 printk("\n[%s] thread[%x,%x] deleted all threads in process %x (but itself)\n", 98 __FUNCTION__, pid, this->trdid, pid ); 110 99 #endif 111 100 … … 116 105 #if( DEBUG_SYS_EXIT & 1) 117 106 if( tm_start > DEBUG_SYS_EXIT ) 118 printk("\n[% u] thread[%x,%x] marked iself for delete\n",119 __FUNCTION__, p rocess->pid, this->trdid );107 printk("\n[%s] thread[%x,%x] marked iself for delete\n", 108 __FUNCTION__, pid, this->trdid ); 120 109 #endif 121 110 thread_delete( XPTR( local_cxy , this ) , pid , true ); 122 111 } 123 112 124 // block th ismain thread113 // block the main thread 125 114 thread_block( XPTR( owner_cxy , main_ptr ) , THREAD_BLOCKED_GLOBAL ); 126 115 127 116 #if( DEBUG_SYS_EXIT & 1) 117 trdid_t main_trdid = hal_remote_l32( XPTR( owner_cxy , &main_ptr->trdid ) ); 128 118 if( tm_start > DEBUG_SYS_EXIT ) 129 printk("\n[%s] thread[%x,%x] blocked main thread \n",130 __FUNCTION__, p rocess->pid, this->trdid );119 printk("\n[%s] thread[%x,%x] blocked main thread[%x,%x]\n", 120 __FUNCTION__, pid, this->trdid, pid, main_trdid ); 131 121 #endif 132 122 133 // atomically update owner process descriptor term_stateto ask134 // the parent process sys_wait() function to delete the main thread123 // update term_state in owner process descriptor to ask 124 // the parent process sys_wait() function to delete the process 135 125 term_state = (status & 0xFF) | PROCESS_TERM_EXIT; 136 126 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , term_state ); … … 139 129 if( tm_start > DEBUG_SYS_EXIT ) 140 130 printk("\n[%s] thread[%x,%x] set exit status %x in owner process\n", 141 __FUNCTION__, p rocess->pid, this->trdid, term_state );131 __FUNCTION__, pid, this->trdid, term_state ); 142 132 #endif 143 133 … … 148 138 if( tm_start > DEBUG_SYS_EXIT ) 149 139 printk("\n[%s] thread[%x,%x] unblocked parent main thread in process %x\n", 150 __FUNCTION__ , p rocess->pid, this->trdid,140 __FUNCTION__ , pid, this->trdid, 151 141 hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid) ) ); 152 142 #endif … … 154 144 hal_fence(); 155 145 146 #if (DEBUG_SYS_EXIT || CONFIG_INSTRUMENTATION_SYSCALLS) 147 uint64_t tm_end = hal_get_cycles(); 148 #endif 149 156 150 #if DEBUG_SYS_EXIT 157 tm_end = hal_get_cycles();158 151 if( DEBUG_SYS_EXIT < tm_end ) 159 printk("\n[%s] thread[%x,%x] exit / status %x / cost = %d / cycle %d\n", 160 __FUNCTION__, process->pid, this->trdid, status, 161 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 152 printk("\n[%s] thread[%x,%x] exit / term_state %x / cycle %d\n", 153 __FUNCTION__, pid, this->trdid, term_state, (uint32_t)tm_end ); 154 #endif 155 156 #if CONFIG_INSTRUMENTATION_SYSCALLS 157 hal_atomic_add( &syscalls_cumul_cost[SYS_EXIT] , tm_end - tm_start ); 158 hal_atomic_add( &syscalls_occurences[SYS_EXIT] , 1 ); 162 159 #endif 163 160
Note: See TracChangeset
for help on using the changeset viewer.