Changeset 612 for trunk/kernel/kern
- Timestamp:
- Jan 11, 2019, 6:35:07 PM (6 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/kernel_init.c
r611 r612 3 3 * 4 4 * Authors : Mohamed Lamine Karaoui (2015) 5 * Alain Greiner (2016,2017 )5 * Alain Greiner (2016,2017,2018) 6 6 * 7 7 * Copyright (c) Sorbonne Universites -
trunk/kernel/kern/process.h
r611 r612 382 382 * The "new" process keep the "old" process PID and PPID, all open files, and env variables, 383 383 * the vfs_root and vfs_cwd, but build a brand new memory image (new VMM from the new .elf). 384 * It actually creates a "new" reference process descriptor, and copies all relevant385 * information from the "old" process descriptor to the "new" process descriptor.386 * It completes the "new" process descriptor, from information found in the <exec_info>387 * structure (defined in the process.h file), that must be built by the caller.388 * It creates and initializes the associated main thread. It finally destroys all copies389 * of the "old" process in all clusters, and destroys all old associated threads.390 384 * It is executed in the local cluster, that becomes both the "owner" and the "reference" 391 385 * cluster for the "new" process. -
trunk/kernel/kern/rpc.c
r611 r612 29 29 #include <hal_special.h> 30 30 #include <printk.h> 31 #include <user_dir.h> 31 32 #include <remote_sem.h> 32 33 #include <core.h> … … 66 67 &rpc_vfs_file_create_server, // 14 67 68 &rpc_vfs_file_destroy_server, // 15 68 &rpc_vfs_fs_ child_init_server, // 1669 &rpc_vfs_fs_get_dentry_server, // 16 69 70 &rpc_vfs_fs_add_dentry_server, // 17 70 71 &rpc_vfs_fs_remove_dentry_server, // 18 … … 102 103 "VFS_FILE_CREATE", // 14 103 104 "VFS_FILE_DESTROY", // 15 104 "VFS_FS_ CHILD_INIT", // 16105 "VFS_FS_GET_DENTRY", // 16 105 106 "VFS_FS_ADD_DENTRY", // 17 106 107 "VFS_FS_REMOVE_DENTRY", // 18 … … 650 651 651 652 ///////////////////////////////////////////////////////////////////////////////////////// 652 // [4] undefined slot 653 ///////////////////////////////////////////////////////////////////////////////////////// 654 655 ///////////////////////////////////////////////////////////////////////////////////////// 656 // [5] undefined slot 657 ///////////////////////////////////////////////////////////////////////////////////////// 653 // [4] Marshaling functions attached to RPC_USER_DIR_CREATE (blocking) 654 ///////////////////////////////////////////////////////////////////////////////////////// 655 656 //////////////////////////////////////////////////// 657 void rpc_user_dir_create_client( cxy_t cxy, 658 vfs_inode_t * inode, 659 user_dir_t ** dir ) 660 { 661 #if DEBUG_RPC_USER_DIR_CREATE 662 thread_t * this = CURRENT_THREAD; 663 uint32_t cycle = (uint32_t)hal_get_cycles(); 664 if( cycle > DEBUG_RPC_USER_DIR_CREATE) 665 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 666 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 667 #endif 668 669 assert( (cxy != local_cxy) , "server cluster is not remote\n"); 670 671 // initialise RPC descriptor header 672 rpc_desc_t rpc; 673 rpc.index = RPC_USER_DIR_CREATE; 674 rpc.blocking = true; 675 rpc.responses = 1; 676 677 // set input arguments in RPC descriptor 678 rpc.args[0] = (uint64_t)(intptr_t)inode; 679 680 // register RPC request in remote RPC fifo 681 rpc_send( cxy , &rpc ); 682 683 // get output argument from RPC descriptor 684 *dir = (user_dir_t *)(intptr_t)rpc.args[1]; 685 686 #if DEBUG_RPC_USER_DIR_CREATE 687 cycle = (uint32_t)hal_get_cycles(); 688 if( cycle > DEBUG_RPC_USER_DIR_CREATE) 689 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 690 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 691 #endif 692 } 693 694 //////////////////////////////////////////// 695 void rpc_user_dir_create_server( xptr_t xp ) 696 { 697 #if DEBUG_RPC_USER_DIR_CREATE 698 thread_t * this = CURRENT_THREAD; 699 uint32_t cycle = (uint32_t)hal_get_cycles(); 700 if( cycle > DEBUG_RPC_USER_DIR_CREATE) 701 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 702 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 703 #endif 704 705 vfs_inode_t * inode; // pointer on inode in server cluster 706 user_dir_t * dir; // pointer on user_dir structure in server cluster 707 708 // get client cluster identifier and pointer on RPC descriptor 709 cxy_t client_cxy = GET_CXY( xp ); 710 rpc_desc_t * desc = GET_PTR( xp ); 711 712 // get input argument from RPC descriptor 713 inode = (vfs_inode_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); 714 715 // call kernel function 716 dir = user_dir_create( inode ); 717 718 // set output argument into RPC descriptor 719 hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (intptr_t)dir ); 720 721 #if DEBUG_RPC_USER_DIR_CREATE 722 cycle = (uint32_t)hal_get_cycles(); 723 if( cycle > DEBUG_RPC_USER_DIR_CREATE) 724 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 725 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 726 #endif 727 } 728 729 ///////////////////////////////////////////////////////////////////////////////////////// 730 // [5] Marshaling functions attached to RPC_USER_DIR_DESTROY (blocking) 731 ///////////////////////////////////////////////////////////////////////////////////////// 732 733 //////////////////////////////////////////////////// 734 void rpc_user_dir_destroy_client( cxy_t cxy, 735 user_dir_t * dir ) 736 { 737 #if DEBUG_RPC_USER_DIR_DESTROY 738 thread_t * this = CURRENT_THREAD; 739 uint32_t cycle = (uint32_t)hal_get_cycles(); 740 if( cycle > DEBUG_RPC_USER_DIR_DESTROY) 741 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 742 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 743 #endif 744 745 assert( (cxy != local_cxy) , "server cluster is not remote\n"); 746 747 // initialise RPC descriptor header 748 rpc_desc_t rpc; 749 rpc.index = RPC_USER_DIR_DESTROY; 750 rpc.blocking = true; 751 rpc.responses = 1; 752 753 // set input arguments in RPC descriptor 754 rpc.args[0] = (uint64_t)(intptr_t)dir; 755 756 // register RPC request in remote RPC fifo 757 rpc_send( cxy , &rpc ); 758 759 #if DEBUG_RPC_USER_DIR_DESTROY 760 cycle = (uint32_t)hal_get_cycles(); 761 if( cycle > DEBUG_RPC_USER_DIR_DESTROY) 762 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 763 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 764 #endif 765 } 766 767 ///////////////////////////////////////////// 768 void rpc_user_dir_destroy_server( xptr_t xp ) 769 { 770 #if DEBUG_RPC_USER_DIR_DESTROY 771 thread_t * this = CURRENT_THREAD; 772 uint32_t cycle = (uint32_t)hal_get_cycles(); 773 if( cycle > DEBUG_RPC_USER_DIR_DESTROY) 774 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 775 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 776 #endif 777 778 user_dir_t * dir; // pointer on user_dir structure in server cluster 779 780 // get client cluster identifier and pointer on RPC descriptor 781 cxy_t client_cxy = GET_CXY( xp ); 782 rpc_desc_t * desc = GET_PTR( xp ); 783 784 // get input argument from RPC descriptor 785 dir = (user_dir_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); 786 787 // call kernel function 788 user_dir_destroy( dir ); 789 790 #if DEBUG_RPC_USER_DIR_DESTROY 791 cycle = (uint32_t)hal_get_cycles(); 792 if( cycle > DEBUG_RPC_USER_DIR_DESTROY) 793 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 794 __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); 795 #endif 796 } 658 797 659 798 ///////////////////////////////////////////////////////////////////////////////////////// … … 731 870 cxy_t client_cxy = GET_CXY( xp ); 732 871 rpc_desc_t * desc = GET_PTR( xp ); 733 734 // get pointer on attributes structure in client cluster from RPC descriptor735 872 736 873 // get input arguments from RPC descriptor … … 751 888 &attr_copy, 752 889 &thread_ptr ); 753 754 890 // set output arguments 755 891 thread_xp = XPTR( local_cxy , thread_ptr ); … … 1426 1562 1427 1563 ///////////////////////////////////////////////////////////////////////////////////////// 1428 // [16] Marshaling functions attached to RPC_VFS_FS_ CHILD_INIT(blocking)1564 // [16] Marshaling functions attached to RPC_VFS_FS_GET_DENTRY (blocking) 1429 1565 ///////////////////////////////////////////////////////////////////////////////////////// 1430 1566 1431 1567 ///////////////////////////////////////////////////////// 1432 void rpc_vfs_fs_ child_init_client( cxy_t cxy,1568 void rpc_vfs_fs_get_dentry_client( cxy_t cxy, 1433 1569 vfs_inode_t * parent_inode, // in 1434 1570 char * name, // in … … 1436 1572 error_t * error ) // out 1437 1573 { 1438 #if DEBUG_RPC_VFS_FS_ CHILD_INIT1439 thread_t * this = CURRENT_THREAD; 1440 uint32_t cycle = (uint32_t)hal_get_cycles(); 1441 if( cycle > DEBUG_RPC_VFS_FS_ CHILD_INIT)1574 #if DEBUG_RPC_VFS_FS_GET_DENTRY 1575 thread_t * this = CURRENT_THREAD; 1576 uint32_t cycle = (uint32_t)hal_get_cycles(); 1577 if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY ) 1442 1578 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 1443 1579 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); … … 1448 1584 // initialise RPC descriptor header 1449 1585 rpc_desc_t rpc; 1450 rpc.index = RPC_VFS_FS_ CHILD_INIT;1586 rpc.index = RPC_VFS_FS_GET_DENTRY; 1451 1587 rpc.blocking = true; 1452 1588 rpc.responses = 1; … … 1463 1599 *error = (error_t)rpc.args[3]; 1464 1600 1465 #if DEBUG_RPC_VFS_FS_ CHILD_INIT1466 cycle = (uint32_t)hal_get_cycles(); 1467 if( cycle > DEBUG_RPC_VFS_FS_ CHILD_INIT)1601 #if DEBUG_RPC_VFS_FS_GET_DENTRY 1602 cycle = (uint32_t)hal_get_cycles(); 1603 if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY ) 1468 1604 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 1469 1605 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); … … 1472 1608 1473 1609 ////////////////////////////////////////////// 1474 void rpc_vfs_fs_ child_init_server( xptr_t xp )1475 { 1476 #if DEBUG_RPC_VFS_FS_ CHILD_INIT1477 thread_t * this = CURRENT_THREAD; 1478 uint32_t cycle = (uint32_t)hal_get_cycles(); 1479 if( cycle > DEBUG_RPC_VFS_FS_ CHILD_INIT)1610 void rpc_vfs_fs_get_dentry_server( xptr_t xp ) 1611 { 1612 #if DEBUG_RPC_VFS_FS_GET_DENTRY 1613 thread_t * this = CURRENT_THREAD; 1614 uint32_t cycle = (uint32_t)hal_get_cycles(); 1615 if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY ) 1480 1616 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 1481 1617 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); … … 1503 1639 1504 1640 // call the kernel function 1505 error = vfs_fs_ child_init( parent , name_copy , child_xp );1641 error = vfs_fs_get_dentry( parent , name_copy , child_xp ); 1506 1642 1507 1643 // set output argument 1508 1644 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 1509 1645 1510 #if DEBUG_RPC_VFS_FS_ CHILD_INIT1511 cycle = (uint32_t)hal_get_cycles(); 1512 if( cycle > DEBUG_RPC_VFS_FS_ CHILD_INIT)1646 #if DEBUG_RPC_VFS_FS_GET_DENTRY 1647 cycle = (uint32_t)hal_get_cycles(); 1648 if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY ) 1513 1649 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 1514 1650 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); -
trunk/kernel/kern/rpc.h
r611 r612 40 40 struct pthread_attr_s; 41 41 struct remote_sem_s; 42 struct user_dir_s; 42 43 struct fragment_s; 43 44 struct vfs_inode_s; … … 63 64 RPC_UNDEFINED_2 = 2, 64 65 RPC_PROCESS_MAKE_FORK = 3, 65 RPC_U NDEFINED_4= 4,66 RPC_U NDEFINED_5= 5,66 RPC_USER_DIR_CREATE = 4, 67 RPC_USER_DIR_DESTROY = 5, 67 68 RPC_THREAD_USER_CREATE = 6, 68 69 RPC_THREAD_KERNEL_CREATE = 7, … … 76 77 RPC_VFS_FILE_CREATE = 14, 77 78 RPC_VFS_FILE_DESTROY = 15, 78 RPC_VFS_FS_ CHILD_INIT= 16,79 RPC_VFS_FS_GET_DENTRY = 16, 79 80 RPC_VFS_FS_ADD_DENTRY = 17, 80 81 RPC_VFS_FS_REMOVE_DENTRY = 18, … … 226 227 227 228 /*********************************************************************************** 228 * [4] undefined slot 229 **********************************************************************************/ 230 231 /*********************************************************************************** 232 * [5] undefined slot 233 **********************************************************************************/ 229 * [4] The RPC_USER_DIR_CREATE allows a client thread to create an user_dir_t 230 * structure and the associated array of dirents in a remote cluster containing 231 * the target directory inode. It is called by the sys_opendir() function. 232 *********************************************************************************** 233 * @ cxy : server cluster identifier. 234 * @ inode : [in] local pointer on inode in server cluster. 235 * @ dir : [out] local pointer on created user_dir structure. 236 **********************************************************************************/ 237 void rpc_user_dir_create_client( cxy_t cxy, 238 struct vfs_inode_s * inode, 239 struct user_dir_s ** dir ); 240 241 void rpc_user_dir_create_server( xptr_t xp ); 242 243 /*********************************************************************************** 244 * [5] The RPC_USER_DIR_DESTROY allows a client thread to delete an user_dir_t 245 * structure and the associated array of dirents in a remote cluster containing 246 * the target directory inode. It is called by the sys_closedir() function. 247 *********************************************************************************** 248 * @ cxy : server cluster identifier. 249 * @ dir : [in] local pointer on created user_dir structure. 250 **********************************************************************************/ 251 void rpc_user_dir_destroy_client( cxy_t cxy, 252 struct user_dir_s * dir ); 253 254 void rpc_user_dir_destroy_server( xptr_t xp ); 234 255 235 256 /*********************************************************************************** … … 402 423 403 424 /*********************************************************************************** 404 * [16] The RPC_VFS_FS_ CHILD_INIT calls the vfs_fs_child_init_load_inode()425 * [16] The RPC_VFS_FS_GET_DENTRY calls the vfs_fs_get_dentry() 405 426 * function in a remote cluster containing a parent inode directory to scan the 406 427 * associated mapper, find a directory entry identified by its name, and update 407 * both the child inode and thedentry.428 * both the - existing - child inode and dentry. 408 429 *********************************************************************************** 409 430 * @ cxy : server cluster identifier … … 413 434 * @ error : [out] error status (0 if success). 414 435 **********************************************************************************/ 415 void rpc_vfs_fs_ child_init_client( cxy_t cxy,436 void rpc_vfs_fs_get_dentry_client( cxy_t cxy, 416 437 struct vfs_inode_s * parent_inode, 417 438 char * name, … … 419 440 error_t * error ); 420 441 421 void rpc_vfs_fs_ child_init_server( xptr_t xp );442 void rpc_vfs_fs_get_dentry_server( xptr_t xp ); 422 443 423 444 /***********************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.