Changeset 408 for trunk/kernel/syscalls/sys_exec.c
- Timestamp:
- Dec 5, 2017, 4:20:07 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_exec.c
r407 r408 150 150 // Implementation note: 151 151 // This function build an exec_info_t structure containing all informations 152 // required to create the new process descriptor and the associated thread. 152 // required to initialize the new process descriptor and the associated thread. 153 // It includes the process PID (unchanged), main() arguments, environment variables, 154 // and the pathname to the new process .elf file. 153 155 // It calls the process_exec_get_strings() functions to copy the main() arguments and 154 156 // the environment variables from user buffers to the exec_info_t structure, allocate 155 157 // and call the process_make_exec() function. 156 // Finally, it destroys the calling thread and process. 158 // As it must destroy all parent process copies, and all parent threads in all clusters, 159 // the process_make_exec() function must be executed in the parent owner cluster, 160 // and this sys_exec() function uses a RPC to access the owner cluster if required. 161 // 157 162 // TODO : the args & envs arguments are not supported yet : both must be NULL 158 163 ///////////////////////////////////////////////////////////////////////////////////////// … … 169 174 tm_start = hal_get_cycles(); 170 175 171 // get p ointers on parent process and thread176 // get parent process pid 172 177 thread_t * this = CURRENT_THREAD; 173 178 process_t * process = this->process; … … 177 182 __FUNCTION__, local_cxy, this->core->lid, pid, (uint32_t)hal_get_cycles() ); 178 183 179 sched_display( 0 ); 184 // get owner cluster 185 cxy_t owner_cxy = CXY_FROM_PID( pid ); 180 186 181 187 // check pathname length … … 189 195 // copy pathname in exec_info structure (kernel space) 190 196 hal_strcpy_from_uspace( exec_info.path , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 197 191 198 // check args argument 192 199 assert( (args == NULL) , __FUNCTION__ , … … 196 203 assert( (envs == NULL) , __FUNCTION__ , 197 204 "args not supported yet\n" ); 198 199 // compute client_cxy (local cluster) and server_cxy (target cluster)200 cxy_t cxy_server = CXY_FROM_PID( pid );201 cxy_t cxy_client = local_cxy;202 203 // register parent process in exec_info204 exec_info.parent_xp = process->ref_xp;205 206 // new process keep the parent process PID207 exec_info.keep_pid = true;208 205 209 206 // check and store args in exec_info structure if required … … 229 226 } 230 227 228 // register PID in exec_info 229 exec_info.pid = pid; 230 231 231 // call process_make_exec (local or remote) 232 if( cxy_server == cxy_client)232 if( owner_cxy == local_cxy ) 233 233 { 234 234 error = process_make_exec( &exec_info ); … … 236 236 else 237 237 { 238 rpc_process_exec_client( cxy_server , &exec_info , &error ); 238 rpc_process_make_exec_client( owner_cxy, 239 &exec_info, 240 &error ); 239 241 } 240 242 … … 242 244 { 243 245 printk("\n[ERROR] in %s : cannot create new process %x in cluster %x\n", 244 __FUNCTION__, pid, cxy_server);246 __FUNCTION__, pid, owner_cxy ); 245 247 this->errno = error; 246 248 return -1; 247 249 } 248 249 // FIXME delete the local process descriptor250 // process_kill( process );251 250 252 251 tm_end = hal_get_cycles();
Note: See TracChangeset
for help on using the changeset viewer.