Changeset 610 for trunk/kernel/kern
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (6 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/do_syscall.c
r583 r610 2 2 * do_syscall.c - architecture independant entry-point for system calls. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 61 61 sys_mutex, // 9 62 62 63 sys_ exit,// 1063 sys_rename, // 10 64 64 sys_munmap, // 11 65 65 sys_open, // 12 … … 104 104 sys_fg, // 48 105 105 sys_is_fg, // 49 106 107 sys_exit, // 50 106 108 }; 107 109 … … 122 124 case SYS_MUTEX : return "MUTEX"; // 9 123 125 124 case SYS_ EXIT: return "EXIT";// 10126 case SYS_RENAME: return "RENAME"; // 10 125 127 case SYS_MUNMAP: return "MUNMAP"; // 11 126 128 case SYS_OPEN: return "OPEN"; // 12 … … 165 167 case SYS_FG: return "FG"; // 48 166 168 case SYS_IS_FG: return "IS_FG"; // 49 169 170 case SYS_EXIT: return "EXIT"; // 50 171 167 172 default: return "undefined"; 168 173 } -
trunk/kernel/kern/kernel_init.c
r601 r610 146 146 147 147 "THREAD_JOIN", // 10 148 " VFS_MAIN",// 11148 "XHTAB_STATE", // 11 149 149 "CHDEV_QUEUE", // 12 150 150 "CHDEV_TXT0", // 13 … … 154 154 "CONDVAR_STATE", // 17 155 155 "SEM_STATE", // 18 156 " XHTAB_STATE", // 19156 "RPOCESS_CWD", // 19 157 157 158 158 "unused_20", // 20 … … 171 171 172 172 "MAPPER_STATE", // 30 173 " PROCESS_CWD",// 31174 "VFS_ INODE",// 32175 "V FS_FILE",// 33176 "VMM_ VSL", // 34177 "V MM_GPT",// 35173 "VFS_SIZE", // 31 174 "VFS_FILE", // 32 175 "VMM_VSL", // 33 176 "VMM_GPT", // 34 177 "VFS_MAIN", // 35 178 178 }; 179 179 … … 970 970 #if DEBUG_KERNEL_INIT 971 971 if( (core_lid == 0) & (local_cxy == 0) ) 972 printk("\n[%s] : exit barrier 0 : TXT0 initialized / sr %x /cycle %d\n",973 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );972 printk("\n[%s] : exit barrier 0 : TXT0 initialized / cycle %d\n", 973 __FUNCTION__, (uint32_t)hal_get_cycles() ); 974 974 #endif 975 975 … … 1012 1012 #if DEBUG_KERNEL_INIT 1013 1013 if( (core_lid == 0) & (local_cxy == 0) ) 1014 printk("\n[%s] : exit barrier 1 : clusters initialised / sr %x /cycle %d\n",1015 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1014 printk("\n[%s] : exit barrier 1 : clusters initialised / cycle %d\n", 1015 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1016 1016 #endif 1017 1017 … … 1039 1039 #if DEBUG_KERNEL_INIT 1040 1040 if( (core_lid == 0) & (local_cxy == 0) ) 1041 printk("\n[%s] : exit barrier 2 : PIC initialised / sr %x /cycle %d\n",1042 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1041 printk("\n[%s] : exit barrier 2 : PIC initialised / cycle %d\n", 1042 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1043 1043 #endif 1044 1044 … … 1072 1072 #if DEBUG_KERNEL_INIT 1073 1073 if( (core_lid == 0) & (local_cxy == 0) ) 1074 printk("\n[%s] : exit barrier 3 : all chdevs initialised / sr %x /cycle %d\n",1075 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1074 printk("\n[%s] : exit barrier 3 : all chdevs initialised / cycle %d\n", 1075 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1076 1076 #endif 1077 1077 … … 1136 1136 1137 1137 // 4. create VFS root inode in cluster 0 1138 error = vfs_inode_create( XPTR_NULL, // dentry_xp 1139 FS_TYPE_FATFS, // fs_type 1138 error = vfs_inode_create( FS_TYPE_FATFS, // fs_type 1140 1139 INODE_TYPE_DIR, // inode_type 1141 1140 0, // attr … … 1174 1173 // register VFS root inode in process_zero descriptor of cluster 0 1175 1174 process_zero.vfs_root_xp = vfs_root_inode_xp; 1176 process_zero. vfs_cwd_xp= vfs_root_inode_xp;1175 process_zero.cwd_xp = vfs_root_inode_xp; 1177 1176 } 1178 1177 … … 1185 1184 #if DEBUG_KERNEL_INIT 1186 1185 if( (core_lid == 0) & (local_cxy == 0) ) 1187 printk("\n[%s] : exit barrier 4 : VFS root initialized in cluster 0 / sr %x / cycle %d\n", 1188 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() ); 1186 printk("\n[%s] : exit barrier 4 : VFS root (%x,%x) in cluster 0 / cycle %d\n", 1187 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1188 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); 1189 1189 #endif 1190 1190 … … 1243 1243 // update local process_zero descriptor 1244 1244 process_zero.vfs_root_xp = vfs_root_inode_xp; 1245 process_zero. vfs_cwd_xp= vfs_root_inode_xp;1245 process_zero.cwd_xp = vfs_root_inode_xp; 1246 1246 } 1247 1247 … … 1254 1254 #if DEBUG_KERNEL_INIT 1255 1255 if( (core_lid == 0) & (local_cxy == 1) ) 1256 printk("\n[%s] : exit barrier 5 : VFS root initialized in cluster 1 / sr %x / cycle %d\n", 1257 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() ); 1256 printk("\n[%s] : exit barrier 4 : VFS root (%x,%x) in cluster 1 / cycle %d\n", 1257 __FUNCTION__, GET_CXY(process_zero.vfs_root_xp), 1258 GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() ); 1258 1259 #endif 1259 1260 … … 1303 1304 #if DEBUG_KERNEL_INIT 1304 1305 if( (core_lid == 0) & (local_cxy == 0) ) 1305 printk("\n[%s] : exit barrier 6 : DEVFS root initialized in cluster 0 / sr %x /cycle %d\n",1306 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1306 printk("\n[%s] : exit barrier 6 : DEVFS root initialized in cluster 0 / cycle %d\n", 1307 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1307 1308 #endif 1308 1309 … … 1340 1341 #if DEBUG_KERNEL_INIT 1341 1342 if( (core_lid == 0) & (local_cxy == 0) ) 1342 printk("\n[%s] : exit barrier 7 : DEV initialized in cluster 0 / sr %x /cycle %d\n",1343 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1343 printk("\n[%s] : exit barrier 7 : DEV initialized in cluster 0 / cycle %d\n", 1344 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1344 1345 #endif 1345 1346 … … 1366 1367 #if DEBUG_KERNEL_INIT 1367 1368 if( (core_lid == 0) & (local_cxy == 0) ) 1368 printk("\n[%s] : exit barrier 8 : process init created / sr %x /cycle %d\n",1369 __FUNCTION__, (uint32_t)hal_get_ sr(), (uint32_t)hal_get_cycles() );1369 printk("\n[%s] : exit barrier 8 : process init created / cycle %d\n", 1370 __FUNCTION__, (uint32_t)hal_get_cycles() ); 1370 1371 #endif 1371 1372 … … 1436 1437 dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD ); 1437 1438 1439 ///////////////////////////////////////////////////////////////////////////////// 1440 if( core_lid == 0 ) xbarrier_wait( XPTR( 0 , &global_barrier ), 1441 (info->x_size * info->y_size) ); 1442 barrier_wait( &local_barrier , info->cores_nr ); 1443 ///////////////////////////////////////////////////////////////////////////////// 1444 1438 1445 #if DEBUG_KERNEL_INIT 1439 printk("\n[%s] : thread %x on core[%x,%d] jumps to thread_idle_func() / cycle %d\n", 1440 __FUNCTION__ , CURRENT_THREAD , local_cxy , core_lid , (uint32_t)hal_get_cycles() ); 1446 thread_t * this = CURRENT_THREAD; 1447 printk("\n[%s] : thread[%x,%x] on core[%x,%d] jumps to thread_idle_func() / cycle %d\n", 1448 __FUNCTION__ , this->process->pid, this->trdid, 1449 local_cxy, core_lid, (uint32_t)hal_get_cycles() ); 1441 1450 #endif 1442 1451 1443 1452 // each core jump to thread_idle_func 1444 1453 thread_idle_func(); 1445 } 1446 1454 1455 } // end kernel_init() 1456 -
trunk/kernel/kern/process.c
r593 r610 95 95 xptr_t parent_xp ) 96 96 { 97 xptr_t process_xp; 97 98 cxy_t parent_cxy; 98 99 process_t * parent_ptr; … … 113 114 pid_t parent_pid; 114 115 116 // build extended pointer on this reference process 117 process_xp = XPTR( local_cxy , process ); 118 115 119 // get parent process cluster and local pointer 116 120 parent_cxy = GET_CXY( parent_xp ); … … 121 125 122 126 #if DEBUG_PROCESS_REFERENCE_INIT 127 thread_t * this = CURRENT_THREAD; 123 128 uint32_t cycle = (uint32_t)hal_get_cycles(); 124 if( DEBUG_PROCESS_REFERENCE_INIT )125 printk("\n[%s] thread %x in process %xenter to initalialize process %x / cycle %d\n",126 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid , pid, cycle );127 #endif 128 129 // initialize PID, REF_XP, PARENT_XP, and STATE129 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 130 printk("\n[%s] thread[%x,%x] enter to initalialize process %x / cycle %d\n", 131 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 132 #endif 133 134 // initialize pid, ref_xp, parent_xp, owner_xp, term_state fields 130 135 process->pid = pid; 131 136 process->ref_xp = XPTR( local_cxy , process ); … … 134 139 process->term_state = 0; 135 140 141 // initialize VFS root inode and CWD inode 142 process->vfs_root_xp = hal_remote_l64( XPTR( parent_cxy, &parent_ptr->vfs_root_xp ) ); 143 process->cwd_xp = hal_remote_l64( XPTR( parent_cxy, &parent_ptr->cwd_xp ) ); 144 136 145 // initialize vmm as empty 137 146 error = vmm_init( process ); … … 141 150 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 142 151 cycle = (uint32_t)hal_get_cycles(); 143 if( DEBUG_PROCESS_REFERENCE_INIT )144 printk("\n[%s] thread %x in process %x/ vmm empty for process %x / cycle %d\n",145 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );152 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 153 printk("\n[%s] thread[%x,%x] / vmm empty for process %x / cycle %d\n", 154 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 146 155 #endif 147 156 … … 161 170 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 162 171 cycle = (uint32_t)hal_get_cycles(); 163 if( DEBUG_PROCESS_REFERENCE_INIT )164 printk("\n[%s] thread %x in process %x/ process %x attached to TXT%d / cycle %d\n",165 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, txt_id, cycle );172 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 173 printk("\n[%s] thread[%x,%x] / process %x attached to TXT%d / cycle %d\n", 174 __FUNCTION__, parent_pid, this->trdid, pid, txt_id, cycle ); 166 175 #endif 167 176 // build path to TXT_RX[i] and TXT_TX[i] chdevs … … 170 179 171 180 // create stdin pseudo file 172 error = vfs_open( process,181 error = vfs_open( process->vfs_root_xp, 173 182 rx_path, 183 process_xp, 174 184 O_RDONLY, 175 185 0, // FIXME chmod … … 182 192 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 183 193 cycle = (uint32_t)hal_get_cycles(); 184 if( DEBUG_PROCESS_REFERENCE_INIT )185 printk("\n[%s] thread %x in process %x/ stdin open for process %x / cycle %d\n",186 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );194 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 195 printk("\n[%s] thread[%x,%x] / stdin open for process %x / cycle %d\n", 196 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 187 197 #endif 188 198 189 199 // create stdout pseudo file 190 error = vfs_open( process,200 error = vfs_open( process->vfs_root_xp, 191 201 tx_path, 202 process_xp, 192 203 O_WRONLY, 193 204 0, // FIXME chmod … … 200 211 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 201 212 cycle = (uint32_t)hal_get_cycles(); 202 if( DEBUG_PROCESS_REFERENCE_INIT )203 printk("\n[%s] thread %x in process %x/ stdout open for process %x / cycle %d\n",204 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );213 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 214 printk("\n[%s] thread[%x,%x] / stdout open for process %x / cycle %d\n", 215 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 205 216 #endif 206 217 207 218 // create stderr pseudo file 208 error = vfs_open( process,219 error = vfs_open( process->vfs_root_xp, 209 220 tx_path, 221 process_xp, 210 222 O_WRONLY, 211 223 0, // FIXME chmod … … 218 230 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 219 231 cycle = (uint32_t)hal_get_cycles(); 220 if( DEBUG_PROCESS_REFERENCE_INIT )221 printk("\n[%s] thread %x in process %x/ stderr open for process %x / cycle %d\n",222 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );232 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 233 printk("\n[%s] thread[%x,%x] / stderr open for process %x / cycle %d\n", 234 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 223 235 #endif 224 236 … … 247 259 } 248 260 249 // initialize specific inodes root and cwd 250 process->vfs_root_xp = (xptr_t)hal_remote_l64( XPTR( parent_cxy, 251 &parent_ptr->vfs_root_xp ) ); 252 process->vfs_cwd_xp = (xptr_t)hal_remote_l64( XPTR( parent_cxy, 253 &parent_ptr->vfs_cwd_xp ) ); 254 vfs_inode_remote_up( process->vfs_root_xp ); 255 vfs_inode_remote_up( process->vfs_cwd_xp ); 256 257 remote_rwlock_init( XPTR( local_cxy , &process->cwd_lock ), LOCK_PROCESS_CWD ); 261 // initialize lock protecting CWD changes 262 remote_busylock_init( XPTR( local_cxy , &process->cwd_lock ), LOCK_PROCESS_CWD ); 258 263 259 264 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 260 265 cycle = (uint32_t)hal_get_cycles(); 261 if( DEBUG_PROCESS_REFERENCE_INIT )262 printk("\n[%s] thread %x in process %x/ set fd_array for process %x / cycle %d\n",263 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid , cycle );266 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 267 printk("\n[%s] thread[%x,%x] / set fd_array for process %x / cycle %d\n", 268 __FUNCTION__, parent_pid, this->trdid, pid , cycle ); 264 269 #endif 265 270 … … 300 305 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 301 306 cycle = (uint32_t)hal_get_cycles(); 302 if( DEBUG_PROCESS_REFERENCE_INIT )303 printk("\n[%s] thread %x in process %xexit for process %x / cycle %d\n",304 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );307 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 308 printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n", 309 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 305 310 #endif 306 311 … … 325 330 326 331 #if DEBUG_PROCESS_COPY_INIT 327 thread_t * this = CURRE T_THREAD;332 thread_t * this = CURRENT_THREAD; 328 333 uint32_t cycle = (uint32_t)hal_get_cycles(); 329 if( DEBUG_PROCESS_COPY_INIT )330 printk("\n[%s] thread %x in process %xenter for process %x / cycle %d\n",331 __FUNCTION__, this-> trdid, this->process->pid, local_process->pid, cycle );334 if( DEBUG_PROCESS_COPY_INIT < cycle ) 335 printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n", 336 __FUNCTION__, this->process->pid, this->trdid, local_process->pid, cycle ); 332 337 #endif 333 338 … … 342 347 process_fd_init( local_process ); 343 348 344 // reset vfs_root_xp / vfs_bin_xp / vfs_cwd_xp fields349 // reset vfs_root_xp / vfs_bin_xp / cwd_xp fields 345 350 local_process->vfs_root_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_root_xp ) ); 346 351 local_process->vfs_bin_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_bin_xp ) ); 347 local_process-> vfs_cwd_xp= XPTR_NULL;352 local_process->cwd_xp = XPTR_NULL; 348 353 349 354 // reset children list root (not used in a process descriptor copy) … … 382 387 #if DEBUG_PROCESS_COPY_INIT 383 388 cycle = (uint32_t)hal_get_cycles(); 384 if( DEBUG_PROCESS_COPY_INIT )385 printk("\n[%s] thread %x in process %xexit for process %x / cycle %d\n",386 __FUNCTION__, this-> trdid, this->process->pid, local_process->pid, cycle );389 if( DEBUG_PROCESS_COPY_INIT < cycle ) 390 printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n", 391 __FUNCTION__, this->process->pid, this->trdid, local_process->pid, cycle ); 387 392 #endif 388 393 … … 406 411 407 412 #if DEBUG_PROCESS_DESTROY 413 thread_t * this = CURRENT_THREAD; 408 414 uint32_t cycle = (uint32_t)hal_get_cycles(); 409 if( DEBUG_PROCESS_DESTROY )410 printk("\n[%s] thread %x in process %xenter for process %x in cluster %x / cycle %d\n",411 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, pid, local_cxy, cycle );415 if( DEBUG_PROCESS_DESTROY < cycle ) 416 printk("\n[%s] thread[%x,%x] enter for process %x in cluster %x / cycle %d\n", 417 __FUNCTION__, this->process->pid, this->trdid, pid, local_cxy, cycle ); 412 418 #endif 413 419 … … 446 452 if( process->vfs_bin_xp != XPTR_NULL ) vfs_file_count_down( process->vfs_bin_xp ); 447 453 if( process->vfs_root_xp != XPTR_NULL ) vfs_file_count_down( process->vfs_root_xp ); 448 if( process-> vfs_cwd_xp != XPTR_NULL ) vfs_file_count_down( process->vfs_cwd_xp );454 if( process->cwd_xp != XPTR_NULL ) vfs_file_count_down( process->cwd_xp ); 449 455 450 456 // Destroy VMM … … 456 462 #if DEBUG_PROCESS_DESTROY 457 463 cycle = (uint32_t)hal_get_cycles(); 458 if( DEBUG_PROCESS_DESTROY )459 printk("\n[%s] thread %x in process %xexit / process %x in cluster %x / cycle %d\n",460 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, pid, local_cxy, cycle );464 if( DEBUG_PROCESS_DESTROY < cycle ) 465 printk("\n[%s] thread[%x,%x] exit / process %x in cluster %x / cycle %d\n", 466 __FUNCTION__, this->process->pid, this->trdid, pid, local_cxy, cycle ); 461 467 #endif 462 468 … … 561 567 process_ptr = GET_PTR( process_xp ); 562 568 563 // printk("\n@@@ in %s : process_cxy %x / process_ptr %x / pid %x\n",564 // __FUNCTION__, process_cxy, process_ptr, hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) ) );565 566 569 if( process_cxy == local_cxy ) // process copy is local 567 570 { … … 652 655 assert( (LPID_FROM_PID( process->pid ) != 0 ), "target process must be an user process" ); 653 656 654 // get target process cluster657 // get target process owner cluster 655 658 owner_cxy = CXY_FROM_PID( process->pid ); 656 659 … … 697 700 while( 1 ) 698 701 { 699 // exit when all scheduler ackno ledges received702 // exit when all scheduler acknowledges received 700 703 if ( ack_count == 0 ) break; 701 704 … … 927 930 uint32_t fd; 928 931 932 // initialize lock 929 933 remote_queuelock_init( XPTR( local_cxy , &process->fd_array.lock ), LOCK_PROCESS_FDARRAY ); 930 934 935 // initialize number of open files 931 936 process->fd_array.current = 0; 932 937 … … 937 942 } 938 943 } 939 ///////////////////////////////////////////////// 940 error_t process_fd_register( process_t * process,944 //////////////////////////////////////////////////// 945 error_t process_fd_register( xptr_t process_xp, 941 946 xptr_t file_xp, 942 947 uint32_t * fdid ) … … 944 949 bool_t found; 945 950 uint32_t id; 946 uint32_t count;947 951 xptr_t xp; 948 952 949 953 // get reference process cluster and local pointer 950 xptr_t ref_xp = process->ref_xp; 951 process_t * ref_ptr = GET_PTR( ref_xp ); 952 cxy_t ref_cxy = GET_CXY( ref_xp ); 954 process_t * process_ptr = GET_PTR( process_xp ); 955 cxy_t process_cxy = GET_CXY( process_xp ); 956 957 // check client process is reference process 958 assert( (process_xp == hal_remote_l64( XPTR( process_cxy , &process_ptr->ref_xp ) ) ), 959 "client process must be reference process\n" ); 960 961 #if DEBUG_PROCESS_FD_REGISTER 962 thread_t * this = CURRENT_THREAD; 963 uint32_t cycle = (uint32_t)hal_get_cycles(); 964 pid_t pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid) ); 965 if( DEBUG_PROCESS_FD_REGISTER < cycle ) 966 printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n", 967 __FUNCTION__, this->process->pid, this->trdid, pid, cycle ); 968 #endif 969 970 // build extended pointer on lock protecting reference fd_array 971 xptr_t lock_xp = XPTR( process_cxy , &process_ptr->fd_array.lock ); 953 972 954 973 // take lock protecting reference fd_array 955 remote_queuelock_acquire( XPTR( ref_cxy , &ref_ptr->fd_array.lock ));974 remote_queuelock_acquire( lock_xp ); 956 975 957 976 found = false; … … 959 978 for ( id = 0; id < CONFIG_PROCESS_FILE_MAX_NR ; id++ ) 960 979 { 961 xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->fd_array.array[id] ) );980 xp = hal_remote_l64( XPTR( process_cxy , &process_ptr->fd_array.array[id] ) ); 962 981 if ( xp == XPTR_NULL ) 963 982 { 964 983 // update reference fd_array 965 hal_remote_s64( XPTR( ref_cxy , &ref_ptr->fd_array.array[id] ) , file_xp ); 966 count = hal_remote_l32( XPTR( ref_cxy , &ref_ptr->fd_array.current ) ) + 1; 967 hal_remote_s32( XPTR( ref_cxy , &ref_ptr->fd_array.current ) , count ); 968 969 // update local fd_array copy if required 970 if( ref_cxy != local_cxy ) 971 { 972 process->fd_array.array[id] = file_xp; 973 process->fd_array.current = count; 974 } 984 hal_remote_s64( XPTR( process_cxy , &process_ptr->fd_array.array[id] ) , file_xp ); 985 hal_remote_atomic_add( XPTR( process_cxy , &process_ptr->fd_array.current ) , 1 ); 975 986 976 987 // exit … … 981 992 } 982 993 983 // release lock protecting reference fd_array 984 remote_queuelock_release( XPTR( ref_cxy , &ref_ptr->fd_array.lock ) ); 994 // release lock protecting fd_array 995 remote_queuelock_release( lock_xp ); 996 997 #if DEBUG_PROCESS_FD_REGISTER 998 cycle = (uint32_t)hal_get_cycles(); 999 if( DEBUG_PROCESS_FD_REGISTER < cycle ) 1000 printk("\n[%s] thread[%x,%x] exit for process %x / fdid %d / cycle %d\n", 1001 __FUNCTION__, this->process->pid, this->trdid, pid, id, cycle ); 1002 #endif 985 1003 986 1004 if ( !found ) return -1; 987 1005 else return 0; 988 } 1006 1007 } // end process_fd_register() 989 1008 990 1009 //////////////////////////////////////////////// … … 1119 1138 // returns trdid 1120 1139 *trdid = TRDID( local_cxy , ltid ); 1121 1122 // if( LPID_FROM_PID( process->pid ) == 0 )1123 // printk("\n@@@ %s : allocate ltid %d for a thread %s in cluster %x\n",1124 // __FUNCTION__, ltid, thread_type_str( thread->type), local_cxy );1125 1126 1140 } 1127 1141 … … 1158 1172 process->th_tbl[ltid] = NULL; 1159 1173 process->th_nr = count-1; 1160 1161 // if( LPID_FROM_PID( process->pid ) == 0 )1162 // printk("\n@@@ %s : release ltid %d for a thread %s in cluster %x\n",1163 // __FUNCTION__, ltid, thread_type_str( thread->type), local_cxy );1164 1174 1165 1175 // release lock protecting th_tbl … … 1363 1373 process_t * process; // local pointer on this process 1364 1374 pid_t pid; // this process identifier 1375 xptr_t ref_xp; // reference process for this process 1365 1376 error_t error; // value returned by called functions 1366 1377 char * path; // path to .elf file … … 1370 1381 char ** args_pointers; // array of pointers on main thread arguments 1371 1382 1372 // get thread, process & PID1383 // get thread, process, pid and ref_xp 1373 1384 thread = CURRENT_THREAD; 1374 1385 process = thread->process; 1375 1386 pid = process->pid; 1387 ref_xp = process->ref_xp; 1376 1388 1377 1389 // get relevant infos from exec_info … … 1390 1402 file_xp = XPTR_NULL; 1391 1403 file_id = 0xFFFFFFFF; 1392 error = vfs_open( process ,1404 error = vfs_open( process->vfs_root_xp, 1393 1405 path, 1406 ref_xp, 1394 1407 O_RDONLY, 1395 1408 0, … … 1543 1556 #endif 1544 1557 1545 } // end process_zero_ init()1558 } // end process_zero_create() 1546 1559 1547 1560 //////////////////////////////// … … 1558 1571 1559 1572 #if DEBUG_PROCESS_INIT_CREATE 1573 thread_t * this = CURRENT_THREAD; 1560 1574 uint32_t cycle = (uint32_t)hal_get_cycles(); 1561 1575 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1562 printk("\n[%s] thread %x in process %xenter / cycle %d\n",1563 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );1576 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", 1577 __FUNCTION__, this->process->pid, this->trdid, cycle ); 1564 1578 #endif 1565 1579 … … 1571 1585 "no memory for process descriptor in cluster %x\n", local_cxy ); 1572 1586 1587 // set the CWD and VFS_ROOT fields in process descriptor 1588 process->cwd_xp = process_zero.vfs_root_xp; 1589 process->vfs_root_xp = process_zero.vfs_root_xp; 1590 1573 1591 // get PID from local cluster 1574 1592 error = cluster_pid_alloc( process , &pid ); … … 1589 1607 #if(DEBUG_PROCESS_INIT_CREATE & 1) 1590 1608 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1591 printk("\n[%s] thread %x in process %xinitialized process descriptor\n",1592 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );1609 printk("\n[%s] thread[%x,%x] initialized process descriptor\n", 1610 __FUNCTION__, this->process->pid, this->trdid ); 1593 1611 #endif 1594 1612 … … 1596 1614 file_xp = XPTR_NULL; 1597 1615 file_id = -1; 1598 error = vfs_open( process ,1616 error = vfs_open( process->vfs_root_xp, 1599 1617 CONFIG_PROCESS_INIT_PATH, 1618 XPTR( local_cxy , process ), 1600 1619 O_RDONLY, 1601 1620 0, … … 1608 1627 #if(DEBUG_PROCESS_INIT_CREATE & 1) 1609 1628 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1610 printk("\n[%s] thread %x in process %xopen .elf file decriptor\n",1611 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );1629 printk("\n[%s] thread[%x,%x] open .elf file decriptor\n", 1630 __FUNCTION__, this->process->pid, this->trdid ); 1612 1631 #endif 1613 1632 … … 1621 1640 #if(DEBUG_PROCESS_INIT_CREATE & 1) 1622 1641 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1623 printk("\n[%s] thread %x in process %xregistered code/data vsegs in VMM\n",1624 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );1642 printk("\n[%s] thread[%x,%x] registered code/data vsegs in VMM\n", 1643 __FUNCTION__, this->process->pid, this->trdid ); 1625 1644 #endif 1626 1645 … … 1641 1660 #if(DEBUG_PROCESS_INIT_CREATE & 1) 1642 1661 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1643 printk("\n[%s] thread %x in process %xregistered init process in parent\n",1644 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );1662 printk("\n[%s] thread[%x,%x] registered init process in parent\n", 1663 __FUNCTION__, this->process->pid, this->trdid ); 1645 1664 #endif 1646 1665 … … 1668 1687 #if(DEBUG_PROCESS_INIT_CREATE & 1) 1669 1688 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1670 printk("\n[%s] thread %x in process %xcreated main thread\n",1671 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );1689 printk("\n[%s] thread[%x,%x] created main thread\n", 1690 __FUNCTION__, this->process->pid, this->trdid ); 1672 1691 #endif 1673 1692 … … 1680 1699 cycle = (uint32_t)hal_get_cycles(); 1681 1700 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1682 printk("\n[%s] thread %x in process %xexit / cycle %d\n",1683 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );1701 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 1702 __FUNCTION__, this->process->pid, this->trdid, cycle ); 1684 1703 #endif 1685 1704 … … 1865 1884 1866 1885 #if DEBUG_PROCESS_TXT 1886 thread_t * this = CURRENT_THREAD; 1867 1887 uint32_t cycle = (uint32_t)hal_get_cycles(); 1868 1888 if( DEBUG_PROCESS_TXT < cycle ) 1869 printk("\n[%s] thread %x in process %x attached process %x to TXT %d / cycle %d\n", 1870 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1871 process->pid, txt_id , cycle ); 1889 printk("\n[%s] thread[%x,%x] attached process %x to TXT %d / cycle %d\n", 1890 __FUNCTION__, this->process->pid, this->trdid, process->pid, txt_id , cycle ); 1872 1891 #endif 1873 1892 … … 1919 1938 1920 1939 #if DEBUG_PROCESS_TXT 1940 thread_t * this = CURRENT_THREAD; 1921 1941 uint32_t cycle = (uint32_t)hal_get_cycles(); 1922 1942 uint32_t txt_id = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 1923 1943 if( DEBUG_PROCESS_TXT < cycle ) 1924 printk("\n[%s] thread %x in process %x detached process %x from TXT %d / cycle %d\n", 1925 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1926 process_pid, txt_id, cycle ); 1944 printk("\n[%s] thread[%x,%x] detached process %x from TXT %d / cycle %d\n", 1945 __FUNCTION__, this->process->pid, this->trdid, process_pid, txt_id, cycle ); 1927 1946 #endif 1928 1947 … … 1961 1980 1962 1981 #if DEBUG_PROCESS_TXT 1982 thread_t * this = CURRENT_THREAD; 1963 1983 uint32_t cycle = (uint32_t)hal_get_cycles(); 1964 1984 uint32_t txt_id = hal_remote_l32( XPTR( txt_cxy , &txt_ptr->channel ) ); 1965 1985 if( DEBUG_PROCESS_TXT < cycle ) 1966 printk("\n[%s] thread %x in process %xgive TXT %d to process %x / cycle %d\n",1967 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, process_pid, cycle );1986 printk("\n[%s] thread[%x,%x] give TXT %d to process %x / cycle %d\n", 1987 __FUNCTION__, this->process->pid, this->trdid, txt_id, process_pid, cycle ); 1968 1988 #endif 1969 1989 … … 1990 2010 1991 2011 #if DEBUG_PROCESS_TXT 1992 uint32_t cycle; 2012 thread_t * this = CURRENT_THREAD; 2013 uint32_t cycle; 1993 2014 #endif 1994 2015 … … 2042 2063 2043 2064 #if DEBUG_PROCESS_TXT 2044 cycle 2065 cycle = (uint32_t)hal_get_cycles(); 2045 2066 uint32_t ksh_pid = hal_remote_l32( XPTR( current_cxy , ¤t_ptr->pid ) ); 2046 2067 if( DEBUG_PROCESS_TXT < cycle ) 2047 printk("\n[%s] thread %x in process %xrelease TXT %d to KSH %x / cycle %d\n",2048 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, ksh_pid, cycle );2068 printk("\n[%s] thread[%x,%x] release TXT %d to KSH %x / cycle %d\n", 2069 __FUNCTION__, this->process->pid, this->trdid, txt_id, ksh_pid, cycle ); 2049 2070 process_txt_display( txt_id ); 2050 2071 #endif … … 2079 2100 2080 2101 #if DEBUG_PROCESS_TXT 2081 cycle 2102 cycle = (uint32_t)hal_get_cycles(); 2082 2103 uint32_t new_pid = hal_remote_l32( XPTR( current_cxy , ¤t_ptr->pid ) ); 2083 2104 if( DEBUG_PROCESS_TXT < cycle ) 2084 printk("\n[%s] thread %x in process %xrelease TXT %d to process %x / cycle %d\n",2085 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, new_pid, cycle );2105 printk("\n[%s] thread[%x,%x] release TXT %d to process %x / cycle %d\n", 2106 __FUNCTION__,this->process->pid, this->trdid, txt_id, new_pid, cycle ); 2086 2107 process_txt_display( txt_id ); 2087 2108 #endif … … 2099 2120 cycle = (uint32_t)hal_get_cycles(); 2100 2121 if( DEBUG_PROCESS_TXT < cycle ) 2101 printk("\n[%s] thread %x in process %xrelease TXT %d to nobody / cycle %d\n",2102 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, cycle );2122 printk("\n[%s] thread[%x,%x] release TXT %d to nobody / cycle %d\n", 2123 __FUNCTION__, this->process->pid, this->trdid, txt_id, cycle ); 2103 2124 process_txt_display( txt_id ); 2104 2125 #endif … … 2113 2134 if( DEBUG_PROCESS_TXT < cycle ) 2114 2135 printk("\n[%s] thread %x in process %d does nothing (not TXT owner) / cycle %d\n", 2115 __FUNCTION__, CURRENT_THREAD->trdid, process_pid, cycle );2136 __FUNCTION__, this->trdid, process_pid, cycle ); 2116 2137 process_txt_display( txt_id ); 2117 2138 #endif -
trunk/kernel/kern/process.h
r601 r610 125 125 fd_array_t fd_array; /*! embedded open file descriptors array */ 126 126 127 xptr_t vfs_root_xp; /*! extended pointer on current VFS root inode*/127 xptr_t vfs_root_xp; /*! extended pointer on VFS root inode */ 128 128 xptr_t vfs_bin_xp; /*! extended pointer on .elf file descriptor */ 129 129 pid_t pid; /*! process identifier */ … … 132 132 xptr_t parent_xp; /*! extended pointer on parent process */ 133 133 134 xptr_t vfs_cwd_xp;/*! extended pointer on current working dir inode */135 remote_ rwlock_tcwd_lock; /*! lock protecting working directory changes */134 xptr_t cwd_xp; /*! extended pointer on current working dir inode */ 135 remote_busylock_t cwd_lock; /*! lock protecting working directory changes */ 136 136 137 137 xlist_entry_t children_root; /*! root of the children process xlist */ … … 338 338 * It scan the list of local thread, and sets the THREAD_BLOCKED_GLOBAL bit for all threads. 339 339 * It request the relevant schedulers to acknowledge the blocking, using IPI if required, 340 * and returns only when all threads in cluster, but the calling thread, are actually blocked. 340 * when the target thread is running on another core than the calling thread. 341 * It returns only when all threads in cluster, including the caller are actually blocked. 341 342 * The threads are not detached from the scheduler, and not detached from the local process. 342 343 ********************************************************************************************* … … 425 426 426 427 /********************************************************************************************* 427 * This function allocates a free slot in the fd_array of the reference process, 428 * register the <file_xp> argument in the allocated slot, and return the slot index. 428 * This function allocates a free slot in the fd_array of the reference process 429 * identified by the <process_xp> argument, register the <file_xp> argument in the 430 * allocated slot, and return the slot index in the <fdid> buffer. 429 431 * It can be called by any thread in any cluster, because it uses portable remote access 430 432 * primitives to access the reference process descriptor. 431 433 * It takes the lock protecting the reference fd_array against concurrent accesses. 432 434 ********************************************************************************************* 433 * @ file_xp : extended pointer on the file descriptor to be registered. 434 * @ fdid : [out] buffer for fd_array slot index. 435 * @ process_xp : [in] extended pointer on client reference process. 436 * @ file_xp : [in] extended pointer on the file descriptor to be registered. 437 * @ fdid : [out] buffer for fd_array slot index. 435 438 * @ return 0 if success / return EMFILE if array full. 436 439 ********************************************************************************************/ 437 error_t process_fd_register( process_t * process,440 error_t process_fd_register( xptr_t process_xp, 438 441 xptr_t file_xp, 439 442 uint32_t * fdid ); … … 447 450 * TODO this function is not implemented yet. 448 451 ********************************************************************************************* 449 * @ process : pointer on the local process descriptor.450 * @ fdid : file descriptor index in the fd_array.452 * @ process : [in] pointer on the local process descriptor. 453 * @ fdid : [in] file descriptor index in the fd_array. 451 454 ********************************************************************************************/ 452 455 void process_fd_remove( process_t * process, -
trunk/kernel/kern/rpc.c
r601 r610 75 75 &rpc_kcm_alloc_server, // 22 76 76 &rpc_kcm_free_server, // 23 77 &rpc_ mapper_move_user_server, // 2477 &rpc_undefined, // 24 unused slot 78 78 &rpc_mapper_handle_miss_server, // 25 79 79 &rpc_undefined, // 26 unused slot … … 111 111 "KCM_ALLOC", // 22 112 112 "KCM_FREE", // 23 113 " MAPPER_MOVE_USER",// 24113 "undefined", // 24 114 114 "MAPPER_HANDLE_MISS", // 25 115 115 "undefined", // 26 … … 302 302 uint32_t cycle = (uint32_t)hal_get_cycles(); 303 303 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 304 printk("\n[ DBG] %s :RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",304 printk("\n[%s] RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n", 305 305 __FUNCTION__, server_ptr->trdid, server_core_lid, cycle ); 306 306 #endif … … 318 318 desc_ptr = GET_PTR( desc_xp ); 319 319 320 index = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) ); 321 blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) ); 320 index = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) ); 321 blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) ); 322 client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) ); 322 323 323 324 #if DEBUG_RPC_SERVER_GENERIC … … 325 326 uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) ); 326 327 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 327 printk("\n[ DBG] %s :RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",328 printk("\n[%s] RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n", 328 329 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle ); 329 330 #endif 331 // register client thread in RPC thread descriptor 332 server_ptr->rpc_client_xp = XPTR( desc_cxy , client_ptr ); 333 330 334 // call the relevant server function 331 335 rpc_server[index]( desc_xp ); … … 334 338 cycle = (uint32_t)hal_get_cycles(); 335 339 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 336 printk("\n[ DBG] %s :RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",340 printk("\n[%s] RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n", 337 341 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, cycle ); 338 342 #endif … … 355 359 cycle = (uint32_t)hal_get_cycles(); 356 360 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 357 printk("\n[ DBG] %s :RPC thread %x unblocked client thread %x / cycle %d\n",361 printk("\n[%s] RPC thread %x unblocked client thread %x / cycle %d\n", 358 362 __FUNCTION__, server_ptr->trdid, client_ptr->trdid, cycle ); 359 363 #endif … … 372 376 uint32_t cycle = (uint32_t)hal_get_cycles(); 373 377 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 374 printk("\n[ DBG] %s :RPC thread %x suicides / cycle %d\n",378 printk("\n[%s] RPC thread %x suicides / cycle %d\n", 375 379 __FUNCTION__, server_ptr->trdid, cycle ); 376 380 #endif … … 391 395 uint32_t cycle = (uint32_t)hal_get_cycles(); 392 396 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 393 printk("\n[ DBG] %s :RPC thread %x block IDLE & deschedules / cycle %d\n",397 printk("\n[%s] RPC thread %x block IDLE & deschedules / cycle %d\n", 394 398 __FUNCTION__, server_ptr->trdid, cycle ); 395 399 #endif … … 870 874 uint32_t action = rpc->args[0]; 871 875 pid_t pid = rpc->args[1]; 876 thread_t * this = CURRENT_THREAD; 872 877 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 873 printk("\n[ DBG] %s :enter to request %s of process %x in cluster %x / cycle %d\n",874 __FUNCTION__ , process_action_str( action ) , pid , cxy, cycle );878 printk("\n[%s] thread[%x,%x] enter to request %s of process %x in cluster %x / cycle %d\n", 879 __FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle ); 875 880 #endif 876 881 … … 885 890 cycle = (uint32_t)hal_get_cycles(); 886 891 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 887 printk("\n[ DBG] %s : exit after requesting to %sprocess %x in cluster %x / cycle %d\n",888 __FUNCTION__ , process_action_str( action ) , pid , cxy, cycle );892 printk("\n[%s] thread[%x,%x] requested %s of process %x in cluster %x / cycle %d\n", 893 __FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle ); 889 894 #endif 890 895 … … 915 920 #if DEBUG_RPC_PROCESS_SIGACTION 916 921 uint32_t cycle = (uint32_t)hal_get_cycles(); 922 thread_t * this = CURRENT_THREAD; 917 923 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 918 printk("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n", 919 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle ); 924 printk("\n[%s] thread[%x,%x] enter to %s process %x in cluster %x / cycle %d\n", 925 __FUNCTION__, this->process->pid, this->trdid, 926 process_action_str( action ), pid, local_cxy, cycle ); 920 927 #endif 921 928 … … 954 961 cycle = (uint32_t)hal_get_cycles(); 955 962 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 956 printk("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n", 957 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle ); 963 printk("\n[%s] thread[%x,%x] exit after %s process %x in cluster %x / cycle %d\n", 964 __FUNCTION__, this->process->pid, this->trdid, 965 process_action_str( action ), pid, local_cxy, cycle ); 958 966 #endif 959 967 … … 966 974 ///////////////////////////////////////////////////// 967 975 void rpc_vfs_inode_create_client( cxy_t cxy, 968 xptr_t dentry_xp, // in969 976 uint32_t fs_type, // in 970 977 uint32_t inode_type, // in … … 993 1000 994 1001 // set input arguments in RPC descriptor 995 rpc.args[0] = (uint64_t)dentry_xp; 996 rpc.args[1] = (uint64_t)fs_type; 997 rpc.args[2] = (uint64_t)inode_type; 998 rpc.args[3] = (uint64_t)attr; 999 rpc.args[4] = (uint64_t)rights; 1000 rpc.args[5] = (uint64_t)uid; 1001 rpc.args[6] = (uint64_t)gid; 1002 rpc.args[0] = (uint64_t)fs_type; 1003 rpc.args[1] = (uint64_t)inode_type; 1004 rpc.args[2] = (uint64_t)attr; 1005 rpc.args[3] = (uint64_t)rights; 1006 rpc.args[4] = (uint64_t)uid; 1007 rpc.args[5] = (uint64_t)gid; 1002 1008 1003 1009 // register RPC request in remote RPC fifo … … 1005 1011 1006 1012 // get output values from RPC descriptor 1007 *inode_xp = (xptr_t)rpc.args[ 7];1008 *error = (error_t)rpc.args[ 8];1013 *inode_xp = (xptr_t)rpc.args[6]; 1014 *error = (error_t)rpc.args[7]; 1009 1015 1010 1016 #if DEBUG_RPC_VFS_INODE_CREATE … … 1027 1033 #endif 1028 1034 1029 xptr_t dentry_xp;1030 1035 uint32_t fs_type; 1031 1036 uint32_t inode_type; … … 1042 1047 1043 1048 // get input arguments from client rpc descriptor 1044 dentry_xp = (xptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1045 fs_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1046 inode_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1047 attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 1048 rights = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 1049 uid = (uid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) ); 1050 gid = (gid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[6] ) ); 1049 fs_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1050 inode_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1051 attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1052 rights = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 1053 uid = (uid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 1054 gid = (gid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) ); 1051 1055 1052 1056 // call local kernel function 1053 error = vfs_inode_create( dentry_xp, 1054 fs_type, 1057 error = vfs_inode_create( fs_type, 1055 1058 inode_type, 1056 1059 attr, … … 1061 1064 1062 1065 // set output arguments 1063 hal_remote_s64( XPTR( client_cxy , &desc->args[ 7] ) , (uint64_t)inode_xp );1064 hal_remote_s64( XPTR( client_cxy , &desc->args[ 8] ) , (uint64_t)error );1066 hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)inode_xp ); 1067 hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)error ); 1065 1068 1066 1069 #if DEBUG_RPC_VFS_INODE_CREATE … … 1149 1152 uint32_t type, // in 1150 1153 char * name, // in 1151 struct vfs_inode_s * parent, // in1152 1154 xptr_t * dentry_xp, // out 1153 1155 error_t * error ) // out … … 1172 1174 rpc.args[0] = (uint64_t)type; 1173 1175 rpc.args[1] = (uint64_t)(intptr_t)name; 1174 rpc.args[2] = (uint64_t)(intptr_t)parent;1175 1176 1176 1177 // register RPC request in remote RPC fifo … … 1178 1179 1179 1180 // get output values from RPC descriptor 1180 *dentry_xp = (xptr_t)rpc.args[ 3];1181 *error = (error_t)rpc.args[ 4];1181 *dentry_xp = (xptr_t)rpc.args[2]; 1182 *error = (error_t)rpc.args[3]; 1182 1183 1183 1184 #if DEBUG_RPC_VFS_DENTRY_CREATE … … 1202 1203 uint32_t type; 1203 1204 char * name; 1204 vfs_inode_t * parent;1205 1205 xptr_t dentry_xp; 1206 1206 error_t error; … … 1212 1212 1213 1213 // get arguments "name", "type", and "parent" from client RPC descriptor 1214 type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1215 name = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1216 parent = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1214 type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1215 name = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1217 1216 1218 1217 // makes a local copy of name … … 1223 1222 error = vfs_dentry_create( type, 1224 1223 name_copy, 1225 parent,1226 1224 &dentry_xp ); 1227 1225 // set output arguments 1228 hal_remote_s64( XPTR( client_cxy , &desc->args[ 3] ) , (uint64_t)dentry_xp );1229 hal_remote_s64( XPTR( client_cxy , &desc->args[ 4] ) , (uint64_t)error );1226 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp ); 1227 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 1230 1228 1231 1229 #if DEBUG_RPC_VFS_DENTRY_CREATE … … 2112 2110 2113 2111 ///////////////////////////////////////////////////////////////////////////////////////// 2114 // [24] Marshaling functions attached to RPC_MAPPER_MOVE_USER 2115 ///////////////////////////////////////////////////////////////////////////////////////// 2116 2117 ///////////////////////////////////////////////// 2118 void rpc_mapper_move_user_client( cxy_t cxy, 2119 mapper_t * mapper, // in 2120 bool_t to_buffer, // in 2121 uint32_t file_offset, // in 2122 void * buffer, // in 2123 uint32_t size, // in 2124 error_t * error ) // out 2125 { 2126 #if DEBUG_RPC_MAPPER_MOVE_USER 2127 uint32_t cycle = (uint32_t)hal_get_cycles(); 2128 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2129 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 2130 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2131 #endif 2132 2133 assert( (cxy != local_cxy) , "target cluster is not remote\n"); 2134 2135 // initialise RPC descriptor header 2136 rpc_desc_t rpc; 2137 rpc.index = RPC_MAPPER_MOVE_USER; 2138 rpc.blocking = true; 2139 rpc.responses = 1; 2140 2141 // set input arguments in RPC descriptor 2142 rpc.args[0] = (uint64_t)(intptr_t)mapper; 2143 rpc.args[1] = (uint64_t)to_buffer; 2144 rpc.args[2] = (uint64_t)file_offset; 2145 rpc.args[3] = (uint64_t)(intptr_t)buffer; 2146 rpc.args[4] = (uint64_t)size; 2147 2148 // register RPC request in remote RPC fifo 2149 rpc_send( cxy , &rpc ); 2150 2151 // get output values from RPC descriptor 2152 *error = (error_t)rpc.args[5]; 2153 2154 #if DEBUG_RPC_MAPPER_MOVE_USER 2155 cycle = (uint32_t)hal_get_cycles(); 2156 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2157 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 2158 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2159 #endif 2160 } 2161 2162 ///////////////////////////////////////////// 2163 void rpc_mapper_move_user_server( xptr_t xp ) 2164 { 2165 #if DEBUG_RPC_MAPPER_MOVE_USER 2166 uint32_t cycle = (uint32_t)hal_get_cycles(); 2167 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2168 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 2169 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2170 #endif 2171 2172 mapper_t * mapper; 2173 bool_t to_buffer; 2174 uint32_t file_offset; 2175 void * buffer; 2176 uint32_t size; 2177 error_t error; 2178 2179 // get client cluster identifier and pointer on RPC descriptor 2180 cxy_t client_cxy = GET_CXY( xp ); 2181 rpc_desc_t * desc = GET_PTR( xp ); 2182 2183 // get arguments from client RPC descriptor 2184 mapper = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2185 to_buffer = hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2186 file_offset = hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 2187 buffer = (void *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 2188 size = hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 2189 2190 // call local kernel function 2191 error = mapper_move_user( mapper, 2192 to_buffer, 2193 file_offset, 2194 buffer, 2195 size ); 2196 2197 // set output argument to client RPC descriptor 2198 hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error ); 2199 2200 #if DEBUG_RPC_MAPPER_MOVE_USER 2201 cycle = (uint32_t)hal_get_cycles(); 2202 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2203 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 2204 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2205 #endif 2206 } 2112 // [24] undefined slot 2113 ///////////////////////////////////////////////////////////////////////////////////////// 2207 2114 2208 2115 ///////////////////////////////////////////////////////////////////////////////////////// … … 2280 2187 2281 2188 // set output argument to client RPC descriptor 2282 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t) error);2283 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t) page_xp);2189 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)page_xp ); 2190 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 2284 2191 2285 2192 #if DEBUG_RPC_MAPPER_HANDLE_MISS -
trunk/kernel/kern/rpc.h
r601 r610 77 77 RPC_VFS_FILE_DESTROY = 15, 78 78 RPC_VFS_FS_CHILD_INIT = 16, 79 RPC_VFS_FS_ REMOVE_DENTRY= 17,80 RPC_VFS_FS_ ADD_DENTRY= 18,79 RPC_VFS_FS_ADD_DENTRY = 17, 80 RPC_VFS_FS_REMOVE_DENTRY = 18, 81 81 RPC_VFS_INODE_LOAD_ALL_PAGES = 19, 82 82 … … 85 85 RPC_KCM_ALLOC = 22, 86 86 RPC_KCM_FREE = 23, 87 RPC_ MAPPER_MOVE_USER= 24,87 RPC_UNDEFINED_24 = 24, 88 88 RPC_MAPPER_HANDLE_MISS = 25, 89 89 RPC_UNDEFINED_26 = 26, … … 307 307 *********************************************************************************** 308 308 * @ cxy : server cluster identifier. 309 * @ dentry_xp : [in] extended pointer on parent dentry.310 309 * @ fs_type : [in] file system type. 311 310 * @ inode_type : [in] file system type. … … 318 317 **********************************************************************************/ 319 318 void rpc_vfs_inode_create_client( cxy_t cxy, 320 xptr_t dentry_xp,321 319 uint32_t fs_type, 322 320 uint32_t inode_type, … … 349 347 * @ type : [in] file system type. 350 348 * @ name : [in] directory entry name. 351 * @ parent : [in] local pointer on parent inode.352 349 * @ dentry_xp : [out] buffer for extended pointer on created dentry. 353 350 * @ error : [out] error status (0 if success). … … 356 353 uint32_t type, 357 354 char * name, 358 struct vfs_inode_s * parent,359 355 xptr_t * dentry_xp, 360 356 error_t * error ); … … 546 542 547 543 /*********************************************************************************** 548 * [24] The RPC_MAPPER_MOVE_USER allows a client thread to require a remote 549 * mapper to move data to/from a distributed user buffer. 550 * It is used by the vfs_move_user() function to move data between a mapper 551 * and an user buffer required by a sys_read() or a sys_write(). 552 *********************************************************************************** 553 * @ cxy : server cluster identifier. 554 * @ mapper : [in] local pointer on mapper. 555 * @ to_buffer : [in] move data from mapper to buffer if non zero. 556 * @ file_offset : [in] first byte to move in mapper. 557 * @ buffer : [in] user space buffer pointer. 558 * @ size : [in] number of bytes to move. 559 * @ error : [out] error status (0 if success). 560 **********************************************************************************/ 561 void rpc_mapper_move_user_client( cxy_t cxy, 562 struct mapper_s * mapper, 563 bool_t to_buffer, 564 uint32_t file_offset, 565 void * buffer, 566 uint32_t size, 567 error_t * error ); 568 569 void rpc_mapper_move_user_server( xptr_t xp ); 544 * [24] undefined slot 545 **********************************************************************************/ 570 546 571 547 /*********************************************************************************** -
trunk/kernel/kern/scheduler.c
r593 r610 254 254 uint32_t cycle = (uint32_t)hal_get_cycles(); 255 255 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 256 printk("\n[ DBG] %s :thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",256 printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / cycle %d\n", 257 257 __FUNCTION__ , process->pid , thread->trdid , local_cxy , thread->core->lid , cycle ); 258 258 #endif … … 266 266 cycle = (uint32_t)hal_get_cycles(); 267 267 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 268 printk("\n[ DBG] %s :process %x in cluster %x deleted / cycle %d\n",268 printk("\n[%s] process %x in cluster %x deleted / cycle %d\n", 269 269 __FUNCTION__ , process->pid , local_cxy , cycle ); 270 270 #endif … … 336 336 uint32_t cycle = (uint32_t)hal_get_cycles(); 337 337 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 338 printk("\n[ DBG] %s :thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",338 printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / cycle %d\n", 339 339 __FUNCTION__ , process_zero.pid , thread->trdid , local_cxy , thread->core->lid , cycle ); 340 340 #endif … … 396 396 uint32_t cycle = (uint32_t)hal_get_cycles(); 397 397 if( DEBUG_SCHED_RPC_ACTIVATE < cycle ) 398 printk("\n[ DBG] %s :new RPC thread %x created for core[%x,%d] / total %d / cycle %d\n",398 printk("\n[%s] new RPC thread %x created for core[%x,%d] / total %d / cycle %d\n", 399 399 __FUNCTION__, thread->trdid, local_cxy, lid, LOCAL_CLUSTER->rpc_threads[lid], cycle ); 400 400 #endif … … 409 409 uint32_t cycle = (uint32_t)hal_get_cycles(); 410 410 if( DEBUG_SCHED_RPC_ACTIVATE < cycle ) 411 printk("\n[ DBG] %s :idle RPC thread %x unblocked for core[%x,%d] / cycle %d\n",411 printk("\n[%s] idle RPC thread %x unblocked for core[%x,%d] / cycle %d\n", 412 412 __FUNCTION__, thread->trdid, local_cxy, lid, cycle ); 413 413 #endif … … 540 540 #if DEBUG_SCHED_YIELD 541 541 if( sched->trace ) 542 printk("\n[ DBG] %s :core[%x,%d] / cause = %s\n"542 printk("\n[%s] core[%x,%d] / cause = %s\n" 543 543 " thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n", 544 544 __FUNCTION__, local_cxy, lid, cause, … … 557 557 #if (DEBUG_SCHED_YIELD & 1) 558 558 if( sched->trace ) 559 printk("\n[ DBG] %s :core[%x,%d] / cause = %s\n"559 printk("\n[%s] core[%x,%d] / cause = %s\n" 560 560 " thread %x (%s) (%x,%x) continue / cycle %d\n", 561 561 __FUNCTION__, local_cxy, lid, cause, current, thread_type_str(current->type), … … 687 687 uint32_t blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) ); 688 688 uint32_t flags = hal_remote_l32 ( XPTR( cxy , &thread->flags ) ); 689 process_t * process = hal_remote_lpt ( XPTR( cxy , &thread->process ) );689 process_t * process = hal_remote_lpt ( XPTR( cxy , &thread->process ) ); 690 690 pid_t pid = hal_remote_l32 ( XPTR( cxy , &process->pid ) ); 691 691 … … 695 695 char name[16]; 696 696 chdev_t * chdev = hal_remote_lpt( XPTR( cxy , &thread->chdev ) ); 697 hal_remote_strcpy( XPTR( local_cxy , name ), XPTR( cxy , &chdev->name ) );697 hal_remote_strcpy( XPTR( local_cxy , name ), XPTR( cxy , chdev->name ) ); 698 698 699 699 nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X / %s\n", … … 721 721 uint32_t blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) ); 722 722 uint32_t flags = hal_remote_l32 ( XPTR( cxy , &thread->flags ) ); 723 process_t * process = hal_remote_lpt ( XPTR( cxy , &thread->process ) );723 process_t * process = hal_remote_lpt ( XPTR( cxy , &thread->process ) ); 724 724 pid_t pid = hal_remote_l32 ( XPTR( cxy , &process->pid ) ); 725 725 -
trunk/kernel/kern/thread.h
r583 r610 194 194 dma_command_t dma_cmd; /*! DMA device generic command */ 195 195 196 cxy_t rpc_client_cxy; /*! client cluster index (for a RPC thread)*/196 xptr_t rpc_client_xp; /*! client thread (for a RPC thread only) */ 197 197 198 198 list_entry_t wait_list; /*! member of a local waiting queue */
Note: See TracChangeset
for help on using the changeset viewer.