Changeset 614 for trunk/kernel/libk
- Timestamp:
- Jan 15, 2019, 1:59:32 PM (6 years ago)
- Location:
- trunk/kernel/libk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/user_dir.c
r613 r614 80 80 } // end user_dir_from_ident() 81 81 82 /////////////////////////////////////////////////// 83 user_dir_t * user_dir_create( vfs_inode_t * inode ) 82 ////////////////////////////////////////////////// 83 user_dir_t * user_dir_create( vfs_inode_t * inode, 84 xptr_t ref_xp ) 84 85 { 85 86 user_dir_t * dir; // local pointer on created user_dir_t 86 87 vseg_t * vseg; // local pointer on dirent array vseg 87 88 uint32_t vseg_size; // size of vseg in bytes 88 process_t * process; // local pointer on calling process89 xptr_t ref_xp; // extended pointer on reference process90 89 process_t * ref_ptr; // local pointer on reference process 91 90 cxy_t ref_cxy; // reference process cluster identifier 91 pid_t ref_pid; // reference process PID 92 92 xptr_t gpt_xp; // extended pointer on reference process GPT 93 93 uint32_t gpt_attributes; // attributes for all mapped gpt entries … … 109 109 error_t error; 110 110 111 // get pointer on local process descriptor 112 process = CURRENT_THREAD->process; 111 // get cluster, local pointer, and pid of reference user process 112 ref_cxy = GET_CXY( ref_xp ); 113 ref_ptr = GET_PTR( ref_xp ); 114 ref_pid = hal_remote_l32( XPTR( ref_cxy , &ref_ptr->pid ) ); 113 115 114 116 #if DEBUG_USER_DIR … … 116 118 thread_t * this = CURRENT_THREAD; 117 119 if( cycle > DEBUG_USER_DIR ) 118 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n",119 __FUNCTION__, process->pid, this->trdid, local_cxy, inode, cycle );120 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) and process %x / cycle %d\n", 121 __FUNCTION__, this->process->pid, this->trdid, local_cxy, inode, ref_pid, cycle ); 120 122 #endif 121 123 … … 128 130 // initialise temporary list of pages 129 131 list_root_init( &root ); 130 131 // get pointers on reference process132 ref_xp = process->ref_xp;133 ref_cxy = GET_CXY( ref_xp );134 ref_ptr = GET_PTR( ref_xp );135 132 136 133 // allocate memory for a local user_dir descriptor … … 207 204 } // end while 208 205 206 #if DEBUG_USER_DIR 207 if( cycle > DEBUG_USER_DIR ) 208 printk("\n[%s] thread[%x,%x] initialised dirent array / %d entries\n", 209 __FUNCTION__, this->process->pid, this->trdid, total_dirents, cycle ); 210 #endif 211 209 212 // compute required vseg size for a 64 bytes dirent 210 213 vseg_size = total_dirents << 6; … … 213 216 if( local_cxy == ref_cxy ) 214 217 { 215 vseg = vmm_create_vseg( process,218 vseg = vmm_create_vseg( ref_ptr, 216 219 VSEG_TYPE_ANON, 217 220 0, // vseg base (unused) … … 220 223 0, // file_size (unused) 221 224 XPTR_NULL, // mapper (unused) 222 ref_cxy );225 local_cxy ); 223 226 } 224 227 else … … 232 235 0, // file size (unused) 233 236 XPTR_NULL, // mapper (unused) 234 ref_cxy,237 local_cxy, 235 238 &vseg ); 236 239 } 240 237 241 if( vseg == NULL ) 238 242 { 239 printk("\n[ERROR] in %s : cannot create vseg for DIRin cluster %x\n",243 printk("\n[ERROR] in %s : cannot create vseg for user_dir in cluster %x\n", 240 244 __FUNCTION__, ref_cxy); 241 245 goto user_dir_create_failure; 242 246 } 243 247 244 #if (DEBUG_USER_DIR & 1)248 #if DEBUG_USER_DIR 245 249 if( cycle > DEBUG_USER_DIR ) 246 250 printk("\n[%s] thread[%x,%x] allocated vseg ANON / base %x / size %x\n", 247 __FUNCTION__, process->pid, this->trdid, vseg->min, vseg->max - vseg->min );251 __FUNCTION__, this->process->pid, this->trdid, vseg->min, vseg->max - vseg->min ); 248 252 #endif 249 253 … … 289 293 desc.lid = CURRENT_THREAD->core->lid; 290 294 desc.blocking = true; 291 desc.args[0] = process->pid;295 desc.args[0] = ref_pid; 292 296 desc.args[1] = vpn << CONFIG_PPM_PAGE_SHIFT; 293 297 rpc_vmm_delete_vseg_client( ref_cxy , &desc ); … … 299 303 } 300 304 301 #if (DEBUG_USER_DIR & 1)305 #if DEBUG_USER_DIR 302 306 if( cycle > DEBUG_USER_DIR ) 303 307 printk("\n[%s] thread[%x,%x] mapped vpn %x to ppn %x\n", 304 __FUNCTION__, process->pid, this->trdid, vpn + page_id, ppn );308 __FUNCTION__, this->process->pid, this->trdid, vpn + page_id, ppn ); 305 309 #endif 306 310 … … 340 344 if( cycle > DEBUG_USER_DIR ) 341 345 printk("\n[%s] thread[%x,%x] created user_dir (%x,%x) / %d entries / cycle %d\n", 342 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, total_dirents, cycle );346 __FUNCTION__, this->process->pid, this->trdid, local_cxy, dir, total_dirents, cycle ); 343 347 #endif 344 348 … … 365 369 } // end user_dir_create() 366 370 367 ///////////////////////////////////////// 368 void user_dir_destroy( user_dir_t * dir ) 371 //////////////////////////////////////// 372 void user_dir_destroy( user_dir_t * dir, 373 xptr_t ref_xp ) 369 374 { 370 process_t * process; // local pointer on client process371 thread_t * this; // local pointer on client thread375 thread_t * this; // local pointer on calling thread 376 process_t * process; // local pointer on calling process 372 377 cluster_t * cluster; // local pointer on local cluster 373 378 intptr_t ident; // user pointer on dirent array 374 xptr_t ref_ xp; // extended pointer on reference process379 xptr_t ref_pid; // reference process PID 375 380 cxy_t ref_cxy; // reference process cluster identifier 376 381 process_t * ref_ptr; // local pointer on reference process … … 379 384 xptr_t iter_xp; // iteratot in xlist 380 385 reg_t save_sr; // for critical section 381 pid_t pid; // process descriptor382 386 cxy_t owner_cxy; // owner process cluster 383 387 lpid_t lpid; // process local index 384 388 rpc_desc_t rpc; // rpc descriptor 385 389 386 // get pointers on c lientprocess & thread390 // get pointers on calling process & thread 387 391 this = CURRENT_THREAD; 388 392 process = this->process; 389 393 cluster = LOCAL_CLUSTER; 390 394 395 // get cluster, local pointer, and PID of reference user process 396 ref_cxy = GET_CXY( ref_xp ); 397 ref_ptr = GET_PTR( ref_xp ); 398 ref_pid = hal_remote_l32( XPTR( ref_cxy , &ref_ptr->pid ) ); 399 391 400 #if DEBUG_USER_DIR 392 401 uint32_t cycle = (uint32_t)hal_get_cycles(); 393 402 if( cycle > DEBUG_USER_DIR ) 394 printk("\n[%s] thread[%x,%x] enter for user_dir (%x,%x) / cycle %d\n",395 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, cycle );403 printk("\n[%s] thread[%x,%x] enter for user_dir (%x,%x) and process %x / cycle %d\n", 404 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, ref_pid, cycle ); 396 405 #endif 397 406 398 407 // get user pointer on dirent array 399 408 ident = dir->ident; 400 401 // get pointers on reference process402 ref_xp = process->ref_xp;403 ref_cxy = GET_CXY( ref_xp );404 ref_ptr = GET_PTR( ref_xp );405 409 406 410 // build extended pointer on lock protecting open directories list … … 424 428 425 429 // get owner cluster identifier and process lpid 426 pid = process->pid; 427 owner_cxy = CXY_FROM_PID( pid ); 428 lpid = LPID_FROM_PID( pid ); 430 owner_cxy = CXY_FROM_PID( ref_pid ); 431 lpid = LPID_FROM_PID( ref_pid ); 429 432 430 433 // get root of list of copies and lock from owner cluster … … 444 447 rpc.thread = this; 445 448 rpc.lid = this->core->lid; 446 rpc.args[0] = process->pid;449 rpc.args[0] = ref_pid; 447 450 rpc.args[1] = ident; 448 451 -
trunk/kernel/libk/user_dir.h
r613 r614 70 70 * in the reference process descriptor. 71 71 ***************************************************************************************** 72 * @ ident : DIR virtual address, used as identifier.72 * @ ident : [in] DIR virtual address, used as identifier. 73 73 * @ returns extended pointer on user_dir_t if success / returns XPTR_NULL if not found. 74 74 ****************************************************************************************/ … … 77 77 /***************************************************************************************** 78 78 * This function allocates memory and initializes a user_dir_t structure in the cluster 79 * containing the directory inode identified by the <inode> argument. 79 * containing the directory inode identified by the <inode> argument and map the 80 * user accessible dirent array in the reference user process VMM, identified by the 81 * <ref_xp> argument. 80 82 * It must be executed by a thread running in the cluster containing the target inode. 81 83 * Use the RPC_USER_DIR_CREATE when the client thread is remote. 82 84 * It makes the following actions: 83 * - the allocation of one user_dir_t descriptor in reference cluster.85 * - the allocation of one user_dir_t descriptor in the directory inode cluster. 84 86 * - the allocation of one or several physical pages in reference cluster to store 85 87 * all directory entries in an array of 64 bytes dirent structures, 86 88 * - the initialisation of this array from informations found in the Inode Tree. 87 * - the creation of an user accessible vseg containing this dirent array, and the88 * mapping of allrelevant physical pages in this vseg.89 * - the creation of an ANON vseg containing this dirent array in reference process VMM, 90 * and the mapping of the relevant physical pages in this vseg. 89 91 * - the registration of the created user_dir_t structure in the xlist rooted 90 92 * in the reference process, 91 93 * It returns a local pointer on the created user_dir_t structure. 92 94 ***************************************************************************************** 93 * @ inode : local pointer on the directory inode. 95 * @ inode : [in] local pointer on the directory inode. 96 * @ ref_xp : [in] extended pointer on the reference user process descriptor. 94 97 * @ return local pointer on user_dir_t if success / return XPTR_NULL if failure. 95 98 ****************************************************************************************/ 96 user_dir_t * user_dir_create( struct vfs_inode_s * inode ); 99 user_dir_t * user_dir_create( struct vfs_inode_s * inode, 100 xptr_t ref_xp ); 97 101 98 102 /***************************************************************************************** 99 103 * This function removes a user_dir_t structure from the xlist of user_dir_t 100 * structures rooted in the reference process descriptor, and release all memory 101 * allocated for the user_dir_t struct in the directory inode cluster, 102 * including the dirent array. 104 * structures rooted in the reference process descriptor, release all memory 105 * allocated for the user_dir_t struct in the directory inode cluster, including 106 * the dirent array, and delete all ANON vseg copies in all process VMM copies, 107 * using parallel RPCs. 103 108 * It must be executed by a thread running in the cluster containing the target inode. 104 109 * Use the RPC_USER_DIR_DESTROY when the client thread is remote. 105 110 ***************************************************************************************** 106 * @ dir : local pointer on user_dir_t structure. 111 * @ dir : [in] local pointer on user_dir_t structure. 112 * @ ref_xp : [in] extended pointer on the reference user process descriptor. 107 113 ****************************************************************************************/ 108 void user_dir_destroy( struct user_dir_s * dir ); 114 void user_dir_destroy( struct user_dir_s * dir, 115 xptr_t ref_xp ); 109 116 110 117 -
trunk/kernel/libk/xhtab.c
r612 r614 42 42 // XHTAB_DENTRY_TYPE 43 43 // This functions compute the hash index from the key, that is the directory entry name. 44 // In this implementation, the index value is simply the ASCII code of the first 45 // character, to provide an approximate lexicographic order. 44 46 /////////////////////////////////////////////////////////////////////////////////////////// 45 47 // @ key : local pointer on name. … … 49 51 { 50 52 char * name = key; 51 uint32_t index = 0; 53 54 return (name[0] % XHASHTAB_SIZE); 55 /* 56 uint32_t index = 0; 52 57 while( *name ) 53 58 { … … 55 60 } 56 61 return index % XHASHTAB_SIZE; 62 */ 63 57 64 } 58 65 -
trunk/kernel/libk/xhtab.h
r611 r614 61 61 /////////////////////////////////////////////////////////////////////////////////////////// 62 62 63 #define XHASHTAB_SIZE 8 // number of subsets63 #define XHASHTAB_SIZE 128 // number of subsets 64 64 65 65 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.