Changeset 625 for trunk/kernel/syscalls/sys_fork.c
- Timestamp:
- Apr 10, 2019, 10:09:39 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_fork.c
r594 r625 2 2 * sys_fork.c - Kernel function implementing the "fork" system call. 3 3 * 4 * Authors Alain Greiner (2016,2017 )4 * Authors Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 73 73 #if DEBUG_SYS_FORK 74 74 if( DEBUG_SYS_FORK < tm_start ) 75 printk("\n[ DBG] %s :thread[%x,%x] enter / cycle = %d\n",75 printk("\n[%s] thread[%x,%x] enter / cycle = %d\n", 76 76 __FUNCTION__, parent_pid, parent_thread_ptr->trdid, (uint32_t)tm_start ); 77 77 #endif … … 151 151 152 152 // set remote child CPU context from parent_thread register values 153 // replicates the parent thread kernel stack to the child thread descriptor, 154 // and finally unblock the child thread. 153 155 hal_cpu_context_fork( XPTR( child_cxy , child_thread_ptr ) ); 154 156 155 157 // From this point, both parent and child threads execute the following code, 156 // but they can be distinguished by the (CURRENT_THREAD,local_cxy) values.157 // - parent unblock child, and return child PID to user application.158 // - child thread does nothing, and return 0 to user pplication159 // The child thread will only execute it when it is unblocked by parent thread.158 // but child thread will only execute it after being unblocked by parent thread. 159 // They can be distinguished by the (CURRENT_THREAD,local_cxy) values. 160 // - parent return child PID to user application. 161 // - child return 0 to user application 160 162 161 163 thread_t * current = CURRENT_THREAD; … … 165 167 #endif 166 168 169 if( (current == parent_thread_ptr) && (local_cxy == parent_cxy) ) // parent thread 170 { 171 167 172 #if DEBUG_SYS_FORK 168 173 if( DEBUG_SYS_FORK < tm_end ) 169 printk("\n[%s] thread[%x,%x] exit/ cycle %d\n",170 __FUNCTION__, current->process->pid, current->trdid, (uint32_t)tm_end );174 printk("\n[%s] parent thread[%x,%x] exit / child_pid %x / cycle %d\n", 175 __FUNCTION__, current->process->pid, current->trdid, child_pid, (uint32_t)tm_end ); 171 176 #endif 172 177 173 if( (current == parent_thread_ptr) && (local_cxy == parent_cxy) ) // parent thread 174 { 175 // parent_thread unblock child_thread 176 thread_unblock( XPTR( child_cxy , child_thread_ptr ) , THREAD_BLOCKED_GLOBAL ); 177 178 // only parent contribute to instrumentation 179 178 // only parent contribute to instrumentation 180 179 #if CONFIG_INSTRUMENTATION_SYSCALLS 181 180 hal_atomic_add( &syscalls_cumul_cost[SYS_FORK] , tm_end - tm_start ); … … 186 185 else // child_thread 187 186 { 187 188 #if DEBUG_SYS_FORK 189 if( DEBUG_SYS_FORK < tm_end ) 190 printk("\n[%s] child thread[%x,%x] exit / child_pid %x / cycle %d\n", 191 __FUNCTION__, current->process->pid, current->trdid, child_pid, (uint32_t)tm_end ); 192 #endif 193 188 194 return 0; 189 195 }
Note: See TracChangeset
for help on using the changeset viewer.