Changeset 435 for trunk/kernel/syscalls/sys_wait.c
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.