Changeset 435 for trunk/kernel/syscalls
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/shared_syscalls.h
r421 r435 321 321 typedef enum 322 322 { 323 DISPLAY_STRING = 0, 324 DISPLAY_VMM = 1, 325 DISPLAY_SCHED = 2, 326 DISPLAY_PROCESS = 3, 327 DISPLAY_VFS = 4, 328 DISPLAY_CHDEV = 5, 323 DISPLAY_STRING = 0, 324 DISPLAY_VMM = 1, 325 DISPLAY_SCHED = 2, 326 DISPLAY_CLUSTER_PROCESSES = 3, 327 DISPLAY_VFS = 4, 328 DISPLAY_CHDEV = 5, 329 DISPLAY_TXT_PROCESSES = 6, 329 330 } 330 331 display_type_t; … … 391 392 392 393 394 /********************************************************************************************* 395 * These macros can be used by the parent process to analyze a child process 396 * termination status, as returned by the wait() syscall. 397 * The termination state is a 32 bits word: 398 * - the 8 LSB bits contain the user defined exit status 399 * - the 24 other bits contain the flags defined below 400 ********************************************************************************************/ 401 402 #define PROCESS_TERM_STOP 0x100 /*! process received a SIGSTOP signal */ 403 #define PROCESS_TERM_KILL 0x200 /*! process killed by a SIGKILL signal */ 404 #define PROCESS_TERM_EXIT 0x400 /*! process terminated by a sys_exit() */ 405 #define PROCESS_TERM_WAIT 0x800 /*! parent process executed a sys_wait() */ 406 407 #define WIFEXITED( status ) (status & PROCESS_TERM_EXIT) 408 #define WIFSIGNALED( status ) (status & PROCESS_TERM_KILL) 409 #define WIFSTOPPED( status ) (status & PROCESS_TERM_STOP) 410 #define WEXITSTATUS( status ) (status & 0xFF) 411 393 412 394 413 #endif // _SHARED_SYSCALLS_H_ -
trunk/kernel/syscalls/sys_display.c
r433 r435 142 142 } 143 143 } 144 else if( type == DISPLAY_ PROCESS )144 else if( type == DISPLAY_CLUSTER_PROCESSES ) 145 145 { 146 146 cxy_t cxy = (cxy_t)arg0; … … 155 155 156 156 cluster_processes_display( cxy ); 157 } 158 else if( type == DISPLAY_TXT_PROCESSES ) 159 { 160 uint32_t txt_id = (uint32_t)arg0; 161 162 // check argument 163 if( txt_id >= LOCAL_CLUSTER->nb_txt_channels ) 164 { 165 printk("\n[ERROR] in %s : undefined TXT channel %x\n", 166 __FUNCTION__ , txt_id ); 167 return -1; 168 } 169 170 process_txt_display( txt_id ); 157 171 } 158 172 else if( type == DISPLAY_VFS ) -
trunk/kernel/syscalls/sys_exec.c
r433 r435 221 221 printk("\n[ERROR] in %s : cannot access args\n", __FUNCTION__ ); 222 222 #endif 223 this->errno = error;223 this->errno = EINVAL; 224 224 return -1; 225 225 } … … 235 235 printk("\n[ERROR] in %s : cannot access envs\n", __FUNCTION__ ); 236 236 #endif 237 this->errno = error;237 this->errno = EINVAL; 238 238 return -1; 239 239 } … … 248 248 #if CONFIG_DEBUG_SYSCALLS_ERROR 249 249 printk("\n[ERROR] in %s : cannot create process %x in cluster %x\n", 250 __FUNCTION__, pid, CXY_FROM_PID( pid);250 __FUNCTION__, pid, CXY_FROM_PID(pid) ); 251 251 #endif 252 252 this->errno = error; -
trunk/kernel/syscalls/sys_exit.c
r433 r435 29 29 #include <printk.h> 30 30 #include <process.h> 31 #include <s ignal.h>31 #include <shared_syscalls.h> 32 32 #include <cluster.h> 33 33 #include <rpc.h> … … 51 51 #endif 52 52 53 // get cluster and pointers on process in owner cluster 54 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid ); 55 cxy_t owner_cxy = GET_CXY( owner_xp ); 56 process_t * owner_ptr = GET_PTR( owner_xp ); 53 // get owner cluster 54 cxy_t owner_cxy = CXY_FROM_PID( pid ); 57 55 58 assert( (owner_xp != XPTR_NULL) , __FUNCTION__ , "owner_xp cannot be NULL\n" ); 56 // exit must be called by the main thread 57 if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID( this->trdid ) != 0) ) 58 { 59 60 #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 ); 64 #endif 65 this->errno = EINVAL; 66 return -1; 67 } 59 68 60 69 // enable IRQs 61 70 hal_enable_irq( &save_sr ); 62 71 63 // the process_make_kill() function must be executed 64 // by an RPC thread in reference cluster 65 rpc_process_make_kill_client( owner_cxy, owner_ptr, true , status ); 72 // register exit_status in owner process descriptor 73 process->term_state = status; 74 75 // remove TXT ownership from owner process descriptor 76 process_txt_reset_ownership( XPTR( local_cxy , process ) ); 77 78 // block all process threads in all clusters 79 process_sigaction( pid , BLOCK_ALL_THREADS ); 80 81 // mark all process threads in all clusters for delete 82 process_sigaction( pid , DELETE_ALL_THREADS ); 66 83 67 84 // restore IRQs 68 85 hal_restore_irq( save_sr ); 69 86 87 // atomically update owner process descriptor term_state 88 hal_remote_atomic_or( XPTR( local_cxy , &process->term_state ) , 89 PROCESS_TERM_EXIT ); 70 90 hal_fence(); 71 91 -
trunk/kernel/syscalls/sys_fork.c
r433 r435 81 81 if( hal_remote_atomic_add( children_xp , 1 ) >= CONFIG_PROCESS_MAX_CHILDREN ) 82 82 { 83 printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__); 83 84 #if CONFIG_DEBUG_SYSCALLS_ERROR 85 printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__); 86 #endif 84 87 hal_remote_atomic_add ( children_xp , -1 ); 85 88 parent_thread_ptr->errno = EAGAIN; … … 119 122 if( error ) 120 123 { 121 printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n", 122 __FUNCTION__, parent_pid, local_cxy ); 124 125 #if CONFIG_DEBUG_SYSCALLS_ERROR 126 printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n", 127 __FUNCTION__, parent_pid, local_cxy ); 128 #endif 123 129 parent_thread_ptr->errno = EAGAIN; 124 130 return -1; -
trunk/kernel/syscalls/sys_get_config.c
r421 r435 35 35 int sys_get_config( uint32_t * x_size, 36 36 uint32_t * y_size, 37 uint32_t * y_width,38 37 uint32_t * ncores ) 39 38 { … … 41 40 uint32_t k_x_size; 42 41 uint32_t k_y_size; 43 uint32_t k_y_width;44 42 uint32_t k_ncores; 45 43 … … 49 47 process_t * process = this->process; 50 48 49 #if CONFIG_DEBUG_SYS_GET_CONFIG 50 uint64_t tm_start; 51 uint64_t tm_end; 52 tm_start = hal_get_cycles(); 53 if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_start ) 54 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 55 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 56 #endif 57 51 58 // check buffer in user space 52 59 error |= vmm_v2p_translate( false , x_size , &paddr ); 53 60 error |= vmm_v2p_translate( false , y_size , &paddr ); 54 error |= vmm_v2p_translate( false , y_width , &paddr );55 61 error |= vmm_v2p_translate( false , ncores , &paddr ); 56 62 57 63 if( error ) 58 64 { 59 printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n", 60 __FUNCTION__ , this->trdid , process->pid ); 65 66 #if CONFIG_DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n", 68 __FUNCTION__ , this->trdid , process->pid ); 69 #endif 61 70 this->errno = EFAULT; 62 71 return -1; … … 66 75 k_x_size = LOCAL_CLUSTER->x_size; 67 76 k_y_size = LOCAL_CLUSTER->y_size; 68 k_y_width = LOCAL_CLUSTER->y_width;69 77 k_ncores = LOCAL_CLUSTER->cores_nr; 70 78 … … 72 80 hal_copy_to_uspace( x_size , &k_x_size , sizeof(uint32_t) ); 73 81 hal_copy_to_uspace( y_size , &k_y_size , sizeof(uint32_t) ); 74 hal_copy_to_uspace( y_width , &k_y_width , sizeof(uint32_t) );75 82 hal_copy_to_uspace( ncores , &k_ncores , sizeof(uint32_t) ); 83 84 hal_fence(); 85 86 #if CONFIG_DEBUG_SYS_GET_CONFIG 87 tm_end = hal_get_cycles(); 88 if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_end ) 89 printk("\n[DBG] %s : thread %x exit / process %x / cost %d / tycle %d\n", 90 __FUNCTION__, this, process->pid, (uint32_t)(tm_end-tm_start), (uint32_t)tm_end ); 91 #endif 76 92 77 93 return 0; -
trunk/kernel/syscalls/sys_kill.c
r433 r435 48 48 49 49 thread_t * this = CURRENT_THREAD; 50 process_t * process = this->process; 50 51 51 52 #if CONFIG_DEBUG_SYS_KILL … … 58 59 #endif 59 60 60 // get cluster and pointers on owner process 61 // process cannot kill itself 62 if( pid == process->pid ) 63 { 64 65 #if CONFIG_DEBUG_SYSCALLS_ERROR 66 printk("\n[ERROR] in %s : process %d cannot kill itself\n", __FUNCTION__ , pid ); 67 #endif 68 this->errno = EINVAL; 69 return -1; 70 } 71 72 // get cluster and pointers on owner target process descriptor 61 73 owner_xp = cluster_get_owner_process_from_pid( pid ); 62 74 owner_cxy = GET_CXY( owner_xp ); … … 67 79 { 68 80 69 syscall_dmsg("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 70 81 #if CONFIG_DEBUG_SYSCALLS_ERROR 82 printk("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 83 #endif 71 84 this->errno = EINVAL; 72 85 return -1; … … 79 92 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 80 93 81 // processes INIT and processes KSH cannot be stoped or killed82 if( p pid < 2)94 // processes INIT 95 if( pid == 1 ) 83 96 { 84 97 85 syscall_dmsg("\n[ERROR] in %s : process %x cannot be killed\n", __FUNCTION__ , pid ); 86 98 #if CONFIG_DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : process_init cannot be killed\n", __FUNCTION__ ); 100 #endif 87 101 this->errno = EINVAL; 88 102 return -1; … … 92 106 hal_enable_irq( &save_sr ); 93 107 94 // analyse signal type 95 // supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 108 // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 96 109 switch( sig_id ) 97 110 { … … 108 121 109 122 // block all threads in all clusters 110 process_sigaction( owner_ptr, BLOCK_ALL_THREADS );123 process_sigaction( pid , BLOCK_ALL_THREADS ); 111 124 112 // atomically update referenceprocess termination state125 // atomically update owner process termination state 113 126 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 114 PROCESS_ FLAG_BLOCK);127 PROCESS_TERM_STOP ); 115 128 116 129 retval = 0; … … 120 133 { 121 134 // unblock all threads in all clusters 122 process_sigaction( owner_ptr, UNBLOCK_ALL_THREADS );135 process_sigaction( pid , UNBLOCK_ALL_THREADS ); 123 136 124 137 // atomically update reference process termination state 125 138 hal_remote_atomic_and( XPTR( owner_cxy , &owner_ptr->term_state ) , 126 ~PROCESS_ FLAG_BLOCK);139 ~PROCESS_TERM_STOP ); 127 140 retval = 0; 128 141 break; … … 131 144 case SIGKILL: 132 145 { 133 // the process_make_kill() function must be executed 134 // by an RPC thread in process owner cluster 135 // It deletes all target process threads in all clusters, 136 // and updates the process termination state 137 rpc_process_make_kill_client( owner_cxy , owner_ptr , false , 0 ); 146 // remove TXT ownership from owner process descriptor 147 process_txt_reset_ownership( owner_xp ); 148 149 // block all process threads in all clusters 150 process_sigaction( pid , BLOCK_ALL_THREADS ); 151 152 // mark all process threads in all clusters for delete 153 process_sigaction( pid , DELETE_ALL_THREADS ); 154 155 // atomically update owner process descriptor flags 156 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 157 PROCESS_TERM_KILL ); 138 158 139 159 retval = 0; … … 143 163 { 144 164 145 syscall_dmsg("\n[ERROR] in %s : illegal signal type %d for process %x\n", 146 __FUNCTION__ , sig_id, pid );147 165 #if CONFIG_DEBUG_SYSCALLS_ERROR 166 printk("\n[ERROR] in %s : illegal signal %d / process %x\n", __FUNCTION__, sig_id, pid ); 167 #endif 148 168 this->errno = EINVAL; 149 169 retval = -1; -
trunk/kernel/syscalls/sys_mmap.c
r407 r435 25 25 #include <hal_types.h> 26 26 #include <hal_uspace.h> 27 #include <hal_irqmask.h> 27 28 #include <shared_syscalls.h> 28 29 #include <errno.h> … … 44 45 error_t error; 45 46 paddr_t paddr; // unused, but required for user space checking 46 47 uint64_t tm_start; 48 uint64_t tm_end; 49 50 tm_start = hal_get_cycles(); 47 reg_t save_sr; // required to enable IRQs 51 48 52 49 thread_t * this = CURRENT_THREAD; 53 50 process_t * process = this->process; 54 51 52 #if CONFIG_DEBUG_SYS_MMAP 53 uint64_t tm_start; 54 uint64_t tm_end; 55 tm_start = hal_get_cycles(); 56 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 57 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 58 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 59 #endif 60 55 61 // check arguments in user space 56 62 error = vmm_v2p_translate( false , attr , &paddr ); … … 58 64 if ( error ) 59 65 { 60 printk("\n[ERROR] in %s : arguments not in used space = %x\n", 61 __FUNCTION__ , (intptr_t)attr ); 66 67 #if CONFIG_DEBUG_SYSCALLS_ERROR 68 printk("\n[ERROR] in %s : arguments not in used space = %x\n", __FUNCTION__ , (intptr_t)attr ); 69 #endif 62 70 this->errno = EINVAL; 63 71 return -1; … … 82 90 if( map_fixed ) 83 91 { 84 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 92 93 #if CONFIG_DEBUG_SYSCALLS_ERROR 94 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 95 #endif 85 96 this->errno = EINVAL; 86 97 return -1; … … 89 100 if( map_shared == map_private ) 90 101 { 91 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 102 103 #if CONFIG_DEBUG_SYSCALLS_ERROR 104 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 105 #endif 92 106 this->errno = EINVAL; 93 107 return -1; … … 108 122 if( fdid >= CONFIG_PROCESS_FILE_MAX_NR ) 109 123 { 110 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 124 125 #if CONFIG_DEBUG_SYSCALLS_ERROR 126 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 127 #endif 111 128 this->errno = EBADFD; 112 129 return -1; … … 118 135 if( file_xp == XPTR_NULL ) 119 136 { 120 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 137 138 #if CONFIG_DEBUG_SYSCALLS_ERROR 139 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 140 #endif 121 141 this->errno = EBADFD; 122 142 return -1; … … 138 158 if( (offset + length) > size) 139 159 { 140 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 141 __FUNCTION__, k_attr.offset, k_attr.length, size ); 160 161 #if CONFIG_DEBUG_SYSCALLS_ERROR 162 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 163 __FUNCTION__, k_attr.offset, k_attr.length, size ); 164 #endif 142 165 this->errno = ERANGE; 143 166 return -1; … … 148 171 (prot_write && !(file_attr & FD_ATTR_WRITE_ENABLE)) ) 149 172 { 150 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 151 __FUNCTION__ , k_attr.prot , file_attr ); 173 174 #if CONFIG_DEBUG_SYSCALLS_ERROR 175 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 176 __FUNCTION__ , k_attr.prot , file_attr ); 177 #endif 152 178 this->errno = EACCES; 153 179 return -1; … … 178 204 if( cluster_is_undefined( vseg_cxy ) ) 179 205 { 180 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 206 207 #if CONFIG_DEBUG_SYSCALLS_ERROR 208 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 209 #endif 181 210 this->errno = EINVAL; 182 211 return -1; … … 184 213 } 185 214 } 215 216 // enable IRQs 217 hal_enable_irq( &save_sr ); 186 218 187 219 // get reference process cluster and local pointer … … 216 248 } 217 249 250 // restore IRQs 251 hal_restore_irq( save_sr ); 252 218 253 if( vseg == NULL ) 219 254 { 220 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 255 256 #if CONFIG_DEBUG_SYSCALLS_ERROR 257 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 258 #endif 221 259 this->errno = ENOMEM; 222 260 return -1; … … 226 264 hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) ); 227 265 228 tm_end = hal_get_cycles(); 229 230 syscall_dmsg("\n[DBG] %s : core[%x,%d] created vseg %s in cluster %x / cycle %d\n" 231 " base = %x / length = %x / cost = %d\n", 232 __FUNCTION__, local_cxy , this->core->lid , vseg_type_str(vseg->type) , 233 vseg->cxy , (uint32_t)tm_start , vseg->min , length , (uint32_t)(tm_end - tm_start) ); 266 hal_fence(); 267 268 #if CONFIG_DEBUG_SYS_MMAP 269 tm_end = hal_get_cycles(); 270 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 271 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n" 272 "vseg %s / cluster %x / base %x / size %x / cost %d\n", 273 __FUNCTION__, this, process->pid, (uint32_t)tm_end, 274 vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)(tm_end - tm_start) ); 275 #endif 234 276 235 277 return 0; -
trunk/kernel/syscalls/sys_read.c
r433 r435 36 36 // TODO: concurrent user page(s) munmap need to be handled [AG] 37 37 38 // TODO : remove these debug variables39 38 extern uint32_t enter_sys_read; 40 39 extern uint32_t enter_devfs_move; … … 64 63 reg_t save_sr; // required to enable IRQs during syscall 65 64 66 #if CONFIG_READ_DEBUG65 #if (CONFIG_DEBUG_SYS_READ & 1) 67 66 enter_sys_read = (uint32_t)tm_start; 68 67 #endif … … 76 75 tm_start = hal_get_cycles(); 77 76 if( CONFIG_DEBUG_SYS_READ < tm_start ) 78 printk("\n[DBG] %s : thread % denter / process %x / vaddr = %x / count %d / cycle %d\n",77 printk("\n[DBG] %s : thread %x enter / process %x / vaddr = %x / count %d / cycle %d\n", 79 78 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start ); 80 79 #endif … … 83 82 if( file_id >= CONFIG_PROCESS_FILE_MAX_NR ) 84 83 { 85 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", 86 __FUNCTION__ , file_id ); 84 85 #if CONFIG_DEBUG_SYSCALLS_ERROR 86 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", __FUNCTION__ , file_id ); 87 #endif 87 88 this->errno = EBADFD; 88 89 return -1; … … 94 95 if ( error ) 95 96 { 96 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 97 __FUNCTION__ , (intptr_t)vaddr ); 97 98 #if CONFIG_DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 100 __FUNCTION__ , (intptr_t)vaddr ); 101 #endif 98 102 this->errno = EINVAL; 99 103 return -1; … … 108 112 if( file_xp == XPTR_NULL ) 109 113 { 110 printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n", 111 __FUNCTION__ , file_id , process->pid ); 114 115 #if CONFIG_DEBUG_SYSCALLS_ERROR 116 printk("\n[ERROR] in %s : undefined fd_id %d in process %x\n", 117 __FUNCTION__ , file_id , process->pid ); 118 #endif 112 119 this->errno = EBADFD; 113 120 return -1; … … 122 129 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 123 130 { 124 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 125 __FUNCTION__ , file_id , process->pid ); 131 132 #if CONFIG_DEBUG_SYSCALLS_ERROR 133 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 134 __FUNCTION__ , file_id , process->pid ); 135 #endif 126 136 this->errno = EBADFD; 127 137 return -1; … … 138 148 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 139 149 { 140 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 141 __FUNCTION__ , file_id , process->pid ); 150 151 #if CONFIG_DEBUG_SYSCALLS_ERROR 152 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 153 __FUNCTION__ , file_id , process->pid ); 154 #endif 142 155 this->errno = EBADFD; 143 156 return -1; … … 166 179 if( XPTR( local_cxy , process ) != owner_xp ) 167 180 { 168 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n", 169 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) ); 181 182 #if CONFIG_DEBUG_SYSCALLS_ERROR 183 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n", 184 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) ); 185 #endif 170 186 this->errno = EBADFD; 171 187 return -1; … … 180 196 if( nbytes != count ) 181 197 { 182 printk("\n[ERROR] in %s cannot read data from file %d in process %x\n", 183 __FUNCTION__ , file_id , process->pid ); 198 199 #if CONFIG_DEBUG_SYSCALLS_ERROR 200 printk("\n[ERROR] in %s cannot read data from file %d in process %x\n", 201 __FUNCTION__ , file_id , process->pid ); 202 #endif 184 203 this->errno = error; 185 204 return -1; … … 194 213 tm_end = hal_get_cycles(); 195 214 if( CONFIG_DEBUG_SYS_READ < tm_end ) 196 printk("\n[DBG] %s : thread %x / process %x / cycle %d\n"215 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n" 197 216 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n", 198 217 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid , … … 201 220 #endif 202 221 203 #if (CONFIG_ READ_DEBUG & 0x1)222 #if (CONFIG_DEBUG_SYS_READ & 1) 204 223 exit_sys_read = (uint32_t)tm_end; 205 224 206 225 printk("\n@@@@@@@@@@@@ timing to read character %c\n" 207 " - enter_sys_read = %d / delta %d\n"208 " - enter_devfs_ move= %d / delta %d\n"209 " - enter_txt_read = %d / delta %d\n"210 " - enter_chdev_cmd = %d / delta %d\n"211 " - enter_chdev_server = %d / delta %d\n"212 " - enter_tty_cmd = %d / delta %d\n"213 " - enter_tty_isr = %d / delta %d\n"214 " - exit_tty_isr = %d / delta %d\n"215 " - exit_tty_cmd = %d / delta %d\n"216 " - exit_chdev_server = %d / delta %d\n"217 " - exit_chdev_cmd = %d / delta %d\n"218 " - exit_txt_read = %d / delta %d\n"219 " - exit_devfs_ move= %d / delta %d\n"220 " - exit_sys_read = %d / delta %d\n",226 " - enter_sys_read = %d / delta %d\n" 227 " - enter_devfs_read = %d / delta %d\n" 228 " - enter_txt_read = %d / delta %d\n" 229 " - enter_chdev_cmd_read = %d / delta %d\n" 230 " - enter_chdev_server_read = %d / delta %d\n" 231 " - enter_tty_cmd_read = %d / delta %d\n" 232 " - enter_tty_isr_read = %d / delta %d\n" 233 " - exit_tty_isr_read = %d / delta %d\n" 234 " - exit_tty_cmd_read = %d / delta %d\n" 235 " - exit_chdev_server_read = %d / delta %d\n" 236 " - exit_chdev_cmd_read = %d / delta %d\n" 237 " - exit_txt_read = %d / delta %d\n" 238 " - exit_devfs_read = %d / delta %d\n" 239 " - exit_sys_read = %d / delta %d\n", 221 240 *((char *)(intptr_t)paddr) , 222 enter_sys_read , 0 ,223 enter_devfs_ move , enter_devfs_move - enter_sys_read,224 enter_txt_read , enter_txt_read - enter_devfs_move,225 enter_chdev_cmd , enter_chdev_cmd - enter_txt_read,226 enter_chdev_server , enter_chdev_server - enter_chdev_cmd ,227 enter_tty_cmd , enter_tty_cmd - enter_chdev_server,228 enter_tty_isr , enter_tty_isr - enter_tty_cmd ,229 exit_tty_isr , exit_tty_isr - enter_tty_isr,230 exit_tty_cmd , exit_tty_cmd - exit_tty_isr,231 exit_chdev_server , exit_chdev_server - exit_tty_cmd ,232 exit_chdev_cmd , exit_chdev_cmd - exit_chdev_server,233 exit_txt_read , exit_txt_read - exit_chdev_cmd ,234 exit_devfs_ move , exit_devfs_move - exit_txt_read,235 exit_sys_read , exit_sys_read - exit_devfs_move);241 enter_sys_read , 0 , 242 enter_devfs_read , enter_devfs_read - enter_sys_read , 243 enter_txt_read , enter_txt_read - enter_devfs_read , 244 enter_chdev_cmd_read , enter_chdev_cmd_read - enter_txt_read , 245 enter_chdev_server_read , enter_chdev_server_read - enter_chdev_cmd_read , 246 enter_tty_cmd_read , enter_tty_cmd_read - enter_chdev_server_read , 247 enter_tty_isr_read , enter_tty_isr_read - enter_tty_cmd_read , 248 exit_tty_isr_read , exit_tty_isr_read - enter_tty_isr_read , 249 exit_tty_cmd_read , exit_tty_cmd_read - exit_tty_isr_read , 250 exit_chdev_server_read , exit_chdev_server_read - exit_tty_cmd_read , 251 exit_chdev_cmd_read , exit_chdev_cmd_read - exit_chdev_server_read , 252 exit_txt_read , exit_txt_read - exit_chdev_cmd_read , 253 exit_devfs_read , exit_devfs_read - exit_txt_read , 254 exit_sys_read , exit_sys_read - exit_devfs_read ); 236 255 #endif 237 256 -
trunk/kernel/syscalls/sys_signal.c
r409 r435 27 27 #include <thread.h> 28 28 #include <printk.h> 29 #include <signal.h>30 29 31 30 ////////////////////////////////// -
trunk/kernel/syscalls/sys_wait.c
r433 r435 24 24 #include <hal_types.h> 25 25 #include <hal_uspace.h> 26 #include <hal_irqmask.h> 26 27 #include <core.h> 27 28 #include <thread.h> … … 42 43 int child_state; 43 44 thread_t * child_thread; 45 reg_t save_sr; 44 46 45 47 thread_t * this = CURRENT_THREAD; … … 61 63 if( error ) 62 64 { 63 printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n", 64 __FUNCTION__ , this->trdid , process->pid ); 65 66 #if CONFIG_DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n", 68 __FUNCTION__ , this->trdid , process->pid ); 69 #endif 65 70 this->errno = EFAULT; 66 71 return -1; … … 85 90 while( 1 ) 86 91 { 92 // enable IRQS 93 hal_enable_irq( &save_sr ); 94 87 95 // get lock protecting children list 88 96 remote_spinlock_lock( children_lock_xp ); … … 101 109 // test if child process is terminated, 102 110 // but termination not yet reported to parent process 103 if( ((child_state & PROCESS_ FLAG_EXIT)||104 (child_state & PROCESS_ FLAG_KILL)||105 (child_state & PROCESS_ FLAG_BLOCK)) &&106 ((child_state & PROCESS_ FLAG_WAIT) == 0) )111 if( ((child_state & PROCESS_TERM_EXIT) || 112 (child_state & PROCESS_TERM_KILL) || 113 (child_state & PROCESS_TERM_STOP)) && 114 ((child_state & PROCESS_TERM_WAIT) == 0) ) 107 115 { 108 116 // get pointer on main thread and PID from child owner process … … 112 120 // set the PROCESS_FLAG_WAIT in owner child descriptor 113 121 hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ), 114 PROCESS_ FLAG_WAIT );122 PROCESS_TERM_WAIT ); 115 123 116 124 // set the THREAD_FLAG_REQ_DELETE in child main thread … … 118 126 THREAD_FLAG_REQ_DELETE ); 119 127 128 // release lock protecting children list 129 remote_spinlock_unlock( children_lock_xp ); 130 120 131 #if CONFIG_DEBUG_SYS_WAIT 121 132 tm_end = hal_get_cycles(); 122 133 if( CONFIG_DEBUG_SYS_WAIT < tm_end ) 123 printk("\n[DBG] %s : thread %x exit / p rocess%x / cycle %d\n",124 __FUNCTION__, this, process->pid, (uint32_t)tm_end );134 printk("\n[DBG] %s : thread %x exit / parent %x / child %x / cycle %d\n", 135 __FUNCTION__, this, process->pid, child_pid, (uint32_t)tm_end ); 125 136 #endif 126 127 137 // return relevant info to calling parent process 128 138 hal_copy_to_uspace( status , &child_state , sizeof(int) ); … … 131 141 } 132 142 133 // release lock 143 // release lock protecting children list 134 144 remote_spinlock_unlock( children_lock_xp ); 135 145 136 146 // deschedule without blocking 137 147 sched_yield( "parent wait children termination" ); 138 } 148 149 } // end while 139 150 140 151 // never executed -
trunk/kernel/syscalls/sys_write.c
r433 r435 41 41 { 42 42 error_t error; 43 paddr_t paddr; // unused, butrequired for user space checking43 paddr_t paddr; // required for user space checking 44 44 xptr_t file_xp; // remote file extended pointer 45 45 uint32_t nbytes; // number of bytes actually written 46 46 reg_t save_sr; // required to enable IRQs during syscall 47 48 #if (CONFIG_DEBUG_SYS_WRITE_DEBUG & 1) 49 enter_sys_read = (uint32_t)tm_start; 50 #endif 47 51 48 52 thread_t * this = CURRENT_THREAD; … … 54 58 tm_start = hal_get_cycles(); 55 59 if( CONFIG_DEBUG_SYS_WRITE < tm_start ) 56 printk("\n[DBG] %s : thread %x / process %x / vaddr %x / count %d / cycle %d\n",60 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / count %d / cycle %d\n", 57 61 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start ); 58 62 #endif … … 162 166 tm_end = hal_get_cycles(); 163 167 if( CONFIG_DEBUG_SYS_WRITE < tm_end ) 164 printk("\n[DBG] %s : thread %x inprocess %x / cycle %d\n"168 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n" 165 169 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n", 166 170 __FUNCTION__, this, process->pid, (uint32_t)tm_start, … … 168 172 #endif 169 173 174 #if (CONFIG_DEBUG_SYS_WRITE & 1) 175 exit_sys_write = (uint32_t)tm_end; 176 177 printk("\n@@@@@@@@@@@@ timing to write string %c\n" 178 " - enter_sys_write = %d / delta %d\n" 179 " - enter_devfs_write = %d / delta %d\n" 180 " - enter_txt_write = %d / delta %d\n" 181 " - enter_chdev_cmd_write = %d / delta %d\n" 182 " - enter_chdev_server_write = %d / delta %d\n" 183 " - enter_tty_cmd_write = %d / delta %d\n" 184 " - enter_tty_isr_write = %d / delta %d\n" 185 " - exit_tty_isr_write = %d / delta %d\n" 186 " - exit_tty_cmd_write = %d / delta %d\n" 187 " - exit_chdev_server_write = %d / delta %d\n" 188 " - exit_chdev_cmd_write = %d / delta %d\n" 189 " - exit_txt_write = %d / delta %d\n" 190 " - exit_devfs_write = %d / delta %d\n" 191 " - exit_sys_write = %d / delta %d\n", 192 *((char *)(intptr_t)paddr) , 193 enter_sys_write , 0 , 194 enter_devfs_write , enter_devfs_write - enter_sys_write , 195 enter_txt_write , enter_txt_write - enter_devfs_write , 196 enter_chdev_cmd_write , enter_chdev_cmd_write - enter_txt_write , 197 enter_chdev_server_write , enter_chdev_server_write - enter_chdev_cmd_write , 198 enter_tty_cmd_write , enter_tty_cmd_write - enter_chdev_server_write , 199 enter_tty_isr_write , enter_tty_isr_write - enter_tty_cmd_write , 200 exit_tty_isr_write , exit_tty_isr_write - enter_tty_isr_write , 201 exit_tty_cmd_write , exit_tty_cmd_write - exit_tty_isr_write , 202 exit_chdev_server_write , exit_chdev_server_write - exit_tty_cmd_write , 203 exit_chdev_cmd_write , exit_chdev_cmd_write - exit_chdev_server_write , 204 exit_txt_write , exit_txt_write - exit_chdev_cmd_write , 205 exit_devfs_write , exit_devfs_write - exit_txt_write , 206 exit_sys_write , exit_sys_write - exit_devfs_write ); 207 #endif 208 170 209 return nbytes; 171 210 -
trunk/kernel/syscalls/syscalls.h
r433 r435 508 508 * The following macros can be used to extract information from status: 509 509 * - WIFEXITED(status) : is true if the child process terminated with an exit(). 510 * - WIFSIGNALED(status) : is true if the child process terminated by a signal.510 * - WIFSIGNALED(status) : is true if the child process killed by a signal. 511 511 * - WIFSTOPPED(status) : is true if the child process is stopped by a signal. 512 512 * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument. … … 558 558 * [43] This debug function displays on the kernel terminal TXT0 an user defined string, 559 559 * or the current state of a kernel structure, identified by the <type> argument. 560 * The <arg0> and <arg1> arguments depends on the structure type. It can be: 561 * - VMM : VSL and GPT for a process identified by <pid>. 562 * - SCHED : all threads allocated to a scheduler identified by <cxy> & <lid>. 563 * - PROCESS : all processes registered in a cluster identified by <cxy>. 564 * - VFS : all files registered in the VFS cache. 565 * - CHDEV : all registered channel devices. 566 ****************************************************************************************** 567 * type : [in] STRING / VMM / SCHED / PROCESS / VSEG / VFS 560 * The <arg0> and <arg1> arguments depends on the structure type: 561 * - DISPLAY_STRING : an user defined string 562 * - DISPLAY_VMM : VSL and GPT for a process identified by <pid>. 563 * - DISPLAY_SCHED : all threads allocated to a scheduler <cxy> & <lid>. 564 * - DISPLAY_CLUSTER_PROCESS : all processes registered in a cluster identified by <cxy>. 565 * - DISPLAY_TXT_PROCESS : all processes registered in a cluster identified by <cxy>. 566 * - DISPLAY_VFS : all files registered in the VFS cache. 567 * - DISPLAY_CHDEV : all registered channel devices. 568 ****************************************************************************************** 569 * type : [in] type of display 568 570 * arg0 : [in] type dependant argument. 569 571 * arg1 : [in] type dependant argument.
Note: See TracChangeset
for help on using the changeset viewer.