Changeset 610 for trunk/kernel/kern


Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (6 years ago)
Author:
alain
Message:

Fix several bugs in VFS to support the following
ksh commandis : cp, mv, rm, mkdir, cd, pwd

Location:
trunk/kernel/kern
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/do_syscall.c

    r583 r610  
    22 * do_syscall.c - architecture independant entry-point for system calls.
    33 *
    4  * Author    Alain Greiner (2016)
     4 * Author    Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    6161    sys_mutex,              // 9
    6262
    63     sys_exit,               // 10
     63    sys_rename,             // 10
    6464    sys_munmap,             // 11
    6565    sys_open,               // 12
     
    104104    sys_fg,                 // 48
    105105    sys_is_fg,              // 49
     106
     107    sys_exit,               // 50
    106108};
    107109
     
    122124    case SYS_MUTEX :                       return "MUTEX";            // 9
    123125
    124     case SYS_EXIT:                         return "EXIT";             // 10
     126    case SYS_RENAME:                       return "RENAME";           // 10
    125127    case SYS_MUNMAP:                       return "MUNMAP";           // 11
    126128    case SYS_OPEN:                         return "OPEN";             // 12
     
    165167    case SYS_FG:                           return "FG";               // 48
    166168    case SYS_IS_FG:                        return "IS_FG";            // 49
     169
     170    case SYS_EXIT:                         return "EXIT";             // 50
     171
    167172    default:                               return "undefined";
    168173    }
  • trunk/kernel/kern/kernel_init.c

    r601 r610  
    146146
    147147    "THREAD_JOIN",           // 10
    148     "VFS_MAIN",              // 11
     148    "XHTAB_STATE",           // 11
    149149    "CHDEV_QUEUE",           // 12
    150150    "CHDEV_TXT0",            // 13
     
    154154    "CONDVAR_STATE",         // 17
    155155    "SEM_STATE",             // 18
    156     "XHTAB_STATE",           // 19
     156    "RPOCESS_CWD",           // 19
    157157
    158158    "unused_20",             // 20
     
    171171
    172172    "MAPPER_STATE",          // 30
    173     "PROCESS_CWD",           // 31
    174     "VFS_INODE",             // 32
    175     "VFS_FILE",              // 33
    176     "VMM_VSL",               // 34
    177     "VMM_GPT",               // 35
     173    "VFS_SIZE",              // 31
     174    "VFS_FILE",              // 32
     175    "VMM_VSL",               // 33
     176    "VMM_GPT",               // 34
     177    "VFS_MAIN",              // 35
    178178};       
    179179
     
    970970#if DEBUG_KERNEL_INIT
    971971if( (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() );
     972printk("\n[%s] : exit barrier 0 : TXT0 initialized / cycle %d\n",
     973__FUNCTION__, (uint32_t)hal_get_cycles() );
    974974#endif
    975975
     
    10121012#if DEBUG_KERNEL_INIT
    10131013if( (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() );
     1014printk("\n[%s] : exit barrier 1 : clusters initialised / cycle %d\n",
     1015__FUNCTION__, (uint32_t)hal_get_cycles() );
    10161016#endif
    10171017
     
    10391039#if DEBUG_KERNEL_INIT
    10401040if( (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() );
     1041printk("\n[%s] : exit barrier 2 : PIC initialised / cycle %d\n",
     1042__FUNCTION__, (uint32_t)hal_get_cycles() );
    10431043#endif
    10441044
     
    10721072#if DEBUG_KERNEL_INIT
    10731073if( (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() );
     1074printk("\n[%s] : exit barrier 3 : all chdevs initialised / cycle %d\n",
     1075__FUNCTION__, (uint32_t)hal_get_cycles() );
    10761076#endif
    10771077
     
    11361136 
    11371137            // 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
    11401139                                      INODE_TYPE_DIR,                      // inode_type
    11411140                                      0,                                   // attr
     
    11741173        // register VFS root inode in process_zero descriptor of cluster 0
    11751174        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;
    11771176    }
    11781177
     
    11851184#if DEBUG_KERNEL_INIT
    11861185if( (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() );
     1186printk("\n[%s] : exit barrier 4 : VFS root (%x,%x) in cluster 0 / cycle %d\n",
     1187__FUNCTION__, GET_CXY(process_zero.vfs_root_xp),
     1188GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() );
    11891189#endif
    11901190
     
    12431243        // update local process_zero descriptor
    12441244        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;
    12461246    }
    12471247
     
    12541254#if DEBUG_KERNEL_INIT
    12551255if( (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() );
     1256printk("\n[%s] : exit barrier 4 : VFS root (%x,%x) in cluster 1 / cycle %d\n",
     1257__FUNCTION__, GET_CXY(process_zero.vfs_root_xp),
     1258GET_PTR(process_zero.vfs_root_xp), (uint32_t)hal_get_cycles() );
    12581259#endif
    12591260
     
    13031304#if DEBUG_KERNEL_INIT
    13041305if( (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() );
     1306printk("\n[%s] : exit barrier 6 : DEVFS root initialized in cluster 0 / cycle %d\n",
     1307__FUNCTION__, (uint32_t)hal_get_cycles() );
    13071308#endif
    13081309
     
    13401341#if DEBUG_KERNEL_INIT
    13411342if( (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() );
     1343printk("\n[%s] : exit barrier 7 : DEV initialized in cluster 0 / cycle %d\n",
     1344__FUNCTION__, (uint32_t)hal_get_cycles() );
    13441345#endif
    13451346
     
    13661367#if DEBUG_KERNEL_INIT
    13671368if( (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() );
     1369printk("\n[%s] : exit barrier 8 : process init created / cycle %d\n",
     1370__FUNCTION__, (uint32_t)hal_get_cycles() );
    13701371#endif
    13711372
     
    14361437    dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD );
    14371438
     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
    14381445#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() );
     1446thread_t * this = CURRENT_THREAD;
     1447printk("\n[%s] : thread[%x,%x] on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
     1448__FUNCTION__ , this->process->pid, this->trdid,
     1449local_cxy, core_lid, (uint32_t)hal_get_cycles() );
    14411450#endif
    14421451
    14431452    // each core jump to thread_idle_func
    14441453    thread_idle_func();
    1445 }
    1446 
     1454
     1455}  // end kernel_init()
     1456
  • trunk/kernel/kern/process.c

    r593 r610  
    9595                             xptr_t      parent_xp )
    9696{
     97    xptr_t      process_xp;
    9798    cxy_t       parent_cxy;
    9899    process_t * parent_ptr;
     
    113114    pid_t       parent_pid;
    114115
     116    // build extended pointer on this reference process
     117    process_xp = XPTR( local_cxy , process );
     118
    115119    // get parent process cluster and local pointer
    116120    parent_cxy = GET_CXY( parent_xp );
     
    121125
    122126#if DEBUG_PROCESS_REFERENCE_INIT
     127thread_t * this = CURRENT_THREAD;
    123128uint32_t cycle = (uint32_t)hal_get_cycles();
    124 if( DEBUG_PROCESS_REFERENCE_INIT )
    125 printk("\n[%s] thread %x in process %x enter 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 STATE
     129if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     130printk("\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
    130135        process->pid        = pid;
    131136    process->ref_xp     = XPTR( local_cxy , process );
     
    134139    process->term_state = 0;
    135140
     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
    136145    // initialize vmm as empty
    137146    error = vmm_init( process );
     
    141150#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    142151cycle = (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 );
     152if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     153printk("\n[%s] thread[%x,%x] / vmm empty for process %x / cycle %d\n",
     154__FUNCTION__, parent_pid, this->trdid, pid, cycle );
    146155#endif
    147156
     
    161170#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    162171cycle = (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 );
     172if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     173printk("\n[%s] thread[%x,%x] / process %x attached to TXT%d / cycle %d\n",
     174__FUNCTION__, parent_pid, this->trdid, pid, txt_id, cycle );
    166175#endif
    167176        // build path to TXT_RX[i] and TXT_TX[i] chdevs
     
    170179
    171180        // create stdin pseudo file         
    172         error = vfs_open( process,
     181        error = vfs_open(  process->vfs_root_xp,
    173182                           rx_path,
     183                           process_xp,
    174184                           O_RDONLY,
    175185                           0,                // FIXME chmod
     
    182192#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    183193cycle = (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 );
     194if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     195printk("\n[%s] thread[%x,%x] / stdin open for process %x / cycle %d\n",
     196__FUNCTION__, parent_pid, this->trdid, pid, cycle );
    187197#endif
    188198
    189199        // create stdout pseudo file         
    190         error = vfs_open( process,
     200        error = vfs_open(  process->vfs_root_xp,
    191201                           tx_path,
     202                           process_xp,
    192203                           O_WRONLY,
    193204                           0,                // FIXME chmod
     
    200211#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    201212cycle = (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 );
     213if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     214printk("\n[%s] thread[%x,%x] / stdout open for process %x / cycle %d\n",
     215__FUNCTION__, parent_pid, this->trdid, pid, cycle );
    205216#endif
    206217
    207218        // create stderr pseudo file         
    208         error = vfs_open( process,
     219        error = vfs_open(  process->vfs_root_xp,
    209220                           tx_path,
     221                           process_xp,
    210222                           O_WRONLY,
    211223                           0,                // FIXME chmod
     
    218230#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    219231cycle = (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 );
     232if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     233printk("\n[%s] thread[%x,%x] / stderr open for process %x / cycle %d\n",
     234__FUNCTION__, parent_pid, this->trdid, pid, cycle );
    223235#endif
    224236
     
    247259    }
    248260
    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 );
    258263
    259264#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    260265cycle = (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 );
     266if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     267printk("\n[%s] thread[%x,%x] / set fd_array for process %x / cycle %d\n",
     268__FUNCTION__, parent_pid, this->trdid, pid , cycle );
    264269#endif
    265270
     
    300305#if (DEBUG_PROCESS_REFERENCE_INIT & 1)
    301306cycle = (uint32_t)hal_get_cycles();
    302 if( DEBUG_PROCESS_REFERENCE_INIT )
    303 printk("\n[%s] thread %x in process %x exit for process %x / cycle %d\n",
    304 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle );
     307if( DEBUG_PROCESS_REFERENCE_INIT < cycle )
     308printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n",
     309__FUNCTION__, parent_pid, this->trdid, pid, cycle );
    305310#endif
    306311
     
    325330
    326331#if DEBUG_PROCESS_COPY_INIT
    327 thread_t * this = CURRET_THREAD; 
     332thread_t * this = CURRENT_THREAD; 
    328333uint32_t cycle = (uint32_t)hal_get_cycles();
    329 if( DEBUG_PROCESS_COPY_INIT )
    330 printk("\n[%s] thread %x in process %x enter for process %x / cycle %d\n",
    331 __FUNCTION__, this->trdid, this->process->pid, local_process->pid, cycle );
     334if( DEBUG_PROCESS_COPY_INIT < cycle )
     335printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n",
     336__FUNCTION__, this->process->pid, this->trdid, local_process->pid, cycle );
    332337#endif
    333338
     
    342347        process_fd_init( local_process );
    343348
    344     // reset vfs_root_xp / vfs_bin_xp / vfs_cwd_xp fields
     349    // reset vfs_root_xp / vfs_bin_xp / cwd_xp fields
    345350    local_process->vfs_root_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_root_xp ) );
    346351    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;
    348353
    349354    // reset children list root (not used in a process descriptor copy)
     
    382387#if DEBUG_PROCESS_COPY_INIT
    383388cycle = (uint32_t)hal_get_cycles();
    384 if( DEBUG_PROCESS_COPY_INIT )
    385 printk("\n[%s] thread %x in process %x exit for process %x / cycle %d\n",
    386 __FUNCTION__, this->trdid, this->process->pid, local_process->pid, cycle );
     389if( DEBUG_PROCESS_COPY_INIT < cycle )
     390printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n",
     391__FUNCTION__, this->process->pid, this->trdid, local_process->pid, cycle );
    387392#endif
    388393
     
    406411
    407412#if DEBUG_PROCESS_DESTROY
     413thread_t * this = CURRENT_THREAD;
    408414uint32_t cycle = (uint32_t)hal_get_cycles();
    409 if( DEBUG_PROCESS_DESTROY )
    410 printk("\n[%s] thread %x in process %x enter for process %x in cluster %x / cycle %d\n",
    411 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, pid, local_cxy, cycle );
     415if( DEBUG_PROCESS_DESTROY < cycle )
     416printk("\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 );
    412418#endif
    413419
     
    446452        if( process->vfs_bin_xp  != XPTR_NULL ) vfs_file_count_down( process->vfs_bin_xp );
    447453        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 );
    449455
    450456    // Destroy VMM
     
    456462#if DEBUG_PROCESS_DESTROY
    457463cycle = (uint32_t)hal_get_cycles();
    458 if( DEBUG_PROCESS_DESTROY )
    459 printk("\n[%s] thread %x in process %x exit / process %x in cluster %x / cycle %d\n",
    460 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, pid, local_cxy, cycle );
     464if( DEBUG_PROCESS_DESTROY < cycle )
     465printk("\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 );
    461467#endif
    462468
     
    561567        process_ptr = GET_PTR( process_xp );
    562568
    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 
    566569        if( process_cxy == local_cxy )    // process copy is local
    567570        {
     
    652655assert( (LPID_FROM_PID( process->pid ) != 0 ), "target process must be an user process" );
    653656
    654     // get target process cluster
     657    // get target process owner cluster
    655658    owner_cxy = CXY_FROM_PID( process->pid );
    656659
     
    697700    while( 1 )
    698701    {
    699         // exit when all scheduler acknoledges received
     702        // exit when all scheduler acknowledges received
    700703        if ( ack_count == 0 ) break;
    701704   
     
    927930    uint32_t fd;
    928931
     932    // initialize lock
    929933    remote_queuelock_init( XPTR( local_cxy , &process->fd_array.lock ), LOCK_PROCESS_FDARRAY );
    930934
     935    // initialize number of open files
    931936    process->fd_array.current = 0;
    932937
     
    937942    }
    938943}
    939 /////////////////////////////////////////////////
    940 error_t process_fd_register( process_t * process,
     944////////////////////////////////////////////////////
     945error_t process_fd_register( xptr_t      process_xp,
    941946                             xptr_t      file_xp,
    942947                             uint32_t  * fdid )
     
    944949    bool_t    found;
    945950    uint32_t  id;
    946     uint32_t  count;
    947951    xptr_t    xp;
    948952
    949953    // 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
     958assert( (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
     962thread_t * this  = CURRENT_THREAD;
     963uint32_t   cycle = (uint32_t)hal_get_cycles();
     964pid_t      pid   = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid) );
     965if( DEBUG_PROCESS_FD_REGISTER < cycle )
     966printk("\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 );
    953972
    954973    // take lock protecting reference fd_array
    955         remote_queuelock_acquire( XPTR( ref_cxy , &ref_ptr->fd_array.lock ) );
     974        remote_queuelock_acquire( lock_xp );
    956975
    957976    found   = false;
     
    959978    for ( id = 0; id < CONFIG_PROCESS_FILE_MAX_NR ; id++ )
    960979    {
    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] ) );
    962981        if ( xp == XPTR_NULL )
    963982        {
    964983            // 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 );
    975986
    976987            // exit
     
    981992    }
    982993
    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
     998cycle = (uint32_t)hal_get_cycles();
     999if( DEBUG_PROCESS_FD_REGISTER < cycle )
     1000printk("\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
    9851003
    9861004    if ( !found ) return -1;
    9871005    else          return 0;
    988 }
     1006
     1007}  // end process_fd_register()
    9891008
    9901009////////////////////////////////////////////////
     
    11191138        // returns trdid
    11201139        *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 
    11261140    }
    11271141
     
    11581172    process->th_tbl[ltid] = NULL;
    11591173    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 );
    11641174
    11651175    // release lock protecting th_tbl
     
    13631373    process_t      * process;                 // local pointer on this process
    13641374    pid_t            pid;                     // this process identifier
     1375    xptr_t           ref_xp;                  // reference process for this process
    13651376        error_t          error;                   // value returned by called functions
    13661377    char           * path;                    // path to .elf file
     
    13701381    char          ** args_pointers;           // array of pointers on main thread arguments
    13711382
    1372     // get thread, process & PID
     1383    // get thread, process, pid and ref_xp
    13731384    thread  = CURRENT_THREAD;
    13741385    process = thread->process;
    13751386    pid     = process->pid;
     1387    ref_xp  = process->ref_xp;
    13761388
    13771389        // get relevant infos from exec_info
     
    13901402    file_xp = XPTR_NULL;
    13911403    file_id = 0xFFFFFFFF;
    1392         error   = vfs_open( process,
     1404        error   = vfs_open( process->vfs_root_xp,
    13931405                            path,
     1406                        ref_xp,
    13941407                            O_RDONLY,
    13951408                            0,
     
    15431556#endif
    15441557
    1545 }  // end process_zero_init()
     1558}  // end process_zero_create()
    15461559
    15471560////////////////////////////////
     
    15581571
    15591572#if DEBUG_PROCESS_INIT_CREATE
     1573thread_t * this = CURRENT_THREAD;
    15601574uint32_t cycle = (uint32_t)hal_get_cycles();
    15611575if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1562 printk("\n[%s] thread %x in process %x enter / cycle %d\n",
    1563 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );
     1576printk("\n[%s] thread[%x,%x] enter / cycle %d\n",
     1577__FUNCTION__, this->process->pid, this->trdid, cycle );
    15641578#endif
    15651579
     
    15711585"no memory for process descriptor in cluster %x\n", local_cxy  );
    15721586
     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
    15731591    // get PID from local cluster
    15741592    error = cluster_pid_alloc( process , &pid );
     
    15891607#if(DEBUG_PROCESS_INIT_CREATE & 1)
    15901608if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1591 printk("\n[%s] thread %x in process %x initialized process descriptor\n",
    1592 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     1609printk("\n[%s] thread[%x,%x] initialized process descriptor\n",
     1610__FUNCTION__, this->process->pid, this->trdid );
    15931611#endif
    15941612
     
    15961614    file_xp = XPTR_NULL;
    15971615    file_id = -1;
    1598         error   = vfs_open( process,
     1616        error   = vfs_open( process->vfs_root_xp,
    15991617                            CONFIG_PROCESS_INIT_PATH,
     1618                        XPTR( local_cxy , process ),
    16001619                            O_RDONLY,
    16011620                            0,
     
    16081627#if(DEBUG_PROCESS_INIT_CREATE & 1)
    16091628if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1610 printk("\n[%s] thread %x in process %x open .elf file decriptor\n",
    1611 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     1629printk("\n[%s] thread[%x,%x] open .elf file decriptor\n",
     1630__FUNCTION__, this->process->pid, this->trdid );
    16121631#endif
    16131632
     
    16211640#if(DEBUG_PROCESS_INIT_CREATE & 1)
    16221641if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1623 printk("\n[%s] thread %x in process %x registered code/data vsegs in VMM\n",
    1624 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     1642printk("\n[%s] thread[%x,%x] registered code/data vsegs in VMM\n",
     1643__FUNCTION__, this->process->pid, this->trdid );
    16251644#endif
    16261645
     
    16411660#if(DEBUG_PROCESS_INIT_CREATE & 1)
    16421661if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1643 printk("\n[%s] thread %x in process %x registered init process in parent\n",
    1644 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     1662printk("\n[%s] thread[%x,%x] registered init process in parent\n",
     1663__FUNCTION__, this->process->pid, this->trdid );
    16451664#endif
    16461665
     
    16681687#if(DEBUG_PROCESS_INIT_CREATE & 1)
    16691688if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1670 printk("\n[%s] thread %x in process %x created main thread\n",
    1671 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid );
     1689printk("\n[%s] thread[%x,%x] created main thread\n",
     1690__FUNCTION__, this->process->pid, this->trdid );
    16721691#endif
    16731692
     
    16801699cycle = (uint32_t)hal_get_cycles();
    16811700if( DEBUG_PROCESS_INIT_CREATE < cycle )
    1682 printk("\n[%s] thread %x in process %x exit / cycle %d\n",
    1683 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );
     1701printk("\n[%s] thread[%x,%x] exit / cycle %d\n",
     1702__FUNCTION__, this->process->pid, this->trdid, cycle );
    16841703#endif
    16851704
     
    18651884
    18661885#if DEBUG_PROCESS_TXT
     1886thread_t * this = CURRENT_THREAD;
    18671887uint32_t cycle = (uint32_t)hal_get_cycles();
    18681888if( 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 );
     1889printk("\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 );
    18721891#endif
    18731892
     
    19191938
    19201939#if DEBUG_PROCESS_TXT
     1940thread_t * this = CURRENT_THREAD;
    19211941uint32_t cycle  = (uint32_t)hal_get_cycles();
    19221942uint32_t txt_id = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) );
    19231943if( 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 );
     1944printk("\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 );
    19271946#endif
    19281947
     
    19611980
    19621981#if DEBUG_PROCESS_TXT
     1982thread_t * this = CURRENT_THREAD;
    19631983uint32_t cycle  = (uint32_t)hal_get_cycles();
    19641984uint32_t txt_id = hal_remote_l32( XPTR( txt_cxy , &txt_ptr->channel ) );
    19651985if( DEBUG_PROCESS_TXT < cycle )
    1966 printk("\n[%s] thread %x in process %x give TXT %d to process %x / cycle %d\n",
    1967 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, process_pid, cycle );
     1986printk("\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 );
    19681988#endif
    19691989
     
    19902010
    19912011#if DEBUG_PROCESS_TXT
    1992 uint32_t cycle;
     2012thread_t * this  = CURRENT_THREAD;
     2013uint32_t   cycle;
    19932014#endif
    19942015
     
    20422063
    20432064#if DEBUG_PROCESS_TXT
    2044 cycle   = (uint32_t)hal_get_cycles();
     2065cycle = (uint32_t)hal_get_cycles();
    20452066uint32_t ksh_pid = hal_remote_l32( XPTR( current_cxy , &current_ptr->pid ) );
    20462067if( DEBUG_PROCESS_TXT < cycle )
    2047 printk("\n[%s] thread %x in process %x release TXT %d to KSH %x / cycle %d\n",
    2048 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, ksh_pid, cycle );
     2068printk("\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 );
    20492070process_txt_display( txt_id );
    20502071#endif
     
    20792100
    20802101#if DEBUG_PROCESS_TXT
    2081 cycle   = (uint32_t)hal_get_cycles();
     2102cycle  = (uint32_t)hal_get_cycles();
    20822103uint32_t new_pid = hal_remote_l32( XPTR( current_cxy , &current_ptr->pid ) );
    20832104if( DEBUG_PROCESS_TXT < cycle )
    2084 printk("\n[%s] thread %x in process %x release TXT %d to process %x / cycle %d\n",
    2085 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, new_pid, cycle );
     2105printk("\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 );
    20862107process_txt_display( txt_id );
    20872108#endif
     
    20992120cycle = (uint32_t)hal_get_cycles();
    21002121if( DEBUG_PROCESS_TXT < cycle )
    2101 printk("\n[%s] thread %x in process %x release TXT %d to nobody / cycle %d\n",
    2102 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, cycle );
     2122printk("\n[%s] thread[%x,%x] release TXT %d to nobody / cycle %d\n",
     2123__FUNCTION__, this->process->pid, this->trdid, txt_id, cycle );
    21032124process_txt_display( txt_id );
    21042125#endif
     
    21132134if( DEBUG_PROCESS_TXT < cycle )
    21142135printk("\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 );
    21162137process_txt_display( txt_id );
    21172138#endif
  • trunk/kernel/kern/process.h

    r601 r610  
    125125        fd_array_t         fd_array;         /*! embedded open file descriptors array            */
    126126
    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              */
    128128        xptr_t             vfs_bin_xp;       /*! extended pointer on .elf file descriptor        */
    129129        pid_t              pid;              /*! process identifier                              */
     
    132132    xptr_t             parent_xp;        /*! extended pointer on parent process              */
    133133
    134         xptr_t             vfs_cwd_xp;       /*! extended pointer on current working dir inode   */
    135         remote_rwlock_t    cwd_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       */
    136136
    137137        xlist_entry_t      children_root;    /*! root of the children process xlist              */
     
    338338 * It scan the list of local thread, and sets the THREAD_BLOCKED_GLOBAL bit for all threads.
    339339 * 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.
    341342 * The threads are not detached from the scheduler, and not detached from the local process.
    342343 *********************************************************************************************
     
    425426
    426427/*********************************************************************************************
    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.
    429431 * It can be called by any thread in any cluster, because it uses portable remote access
    430432 * primitives to access the reference process descriptor.
    431433 * It takes the lock protecting the reference fd_array against concurrent accesses.
    432434 *********************************************************************************************
    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.
    435438 * @ return 0 if success / return EMFILE if array full.
    436439 ********************************************************************************************/
    437 error_t process_fd_register( process_t * process,
     440error_t process_fd_register( xptr_t      process_xp,
    438441                             xptr_t      file_xp,
    439442                             uint32_t  * fdid );
     
    447450 * TODO this function is not implemented yet.
    448451 *********************************************************************************************
    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.
    451454 ********************************************************************************************/
    452455void process_fd_remove( process_t * process,
  • trunk/kernel/kern/rpc.c

    r601 r610  
    7575    &rpc_kcm_alloc_server,                 // 22
    7676    &rpc_kcm_free_server,                  // 23
    77     &rpc_mapper_move_user_server,          // 24
     77    &rpc_undefined,                        // 24   unused slot
    7878    &rpc_mapper_handle_miss_server,        // 25
    7979    &rpc_undefined,                        // 26   unused slot
     
    111111    "KCM_ALLOC",                 // 22
    112112    "KCM_FREE",                  // 23
    113     "MAPPER_MOVE_USER",          // 24
     113    "undefined",                 // 24
    114114    "MAPPER_HANDLE_MISS",        // 25
    115115    "undefined",                 // 26
     
    302302uint32_t cycle = (uint32_t)hal_get_cycles();
    303303if( DEBUG_RPC_SERVER_GENERIC < cycle )
    304 printk("\n[DBG] %s : RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
     304printk("\n[%s] RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
    305305__FUNCTION__, server_ptr->trdid, server_core_lid, cycle );
    306306#endif
     
    318318                desc_ptr = GET_PTR( desc_xp );
    319319
    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 ) );
    322323
    323324#if DEBUG_RPC_SERVER_GENERIC
     
    325326uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) );
    326327if( DEBUG_RPC_SERVER_GENERIC < cycle )
    327 printk("\n[DBG] %s : RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
     328printk("\n[%s] RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
    328329__FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle );
    329330#endif
     331                // register client thread in RPC thread descriptor
     332                server_ptr->rpc_client_xp = XPTR( desc_cxy , client_ptr );
     333 
    330334                // call the relevant server function
    331335                rpc_server[index]( desc_xp );
     
    334338cycle = (uint32_t)hal_get_cycles();
    335339if( DEBUG_RPC_SERVER_GENERIC < cycle )
    336 printk("\n[DBG] %s : RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
     340printk("\n[%s] RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
    337341__FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );
    338342#endif
     
    355359cycle = (uint32_t)hal_get_cycles();
    356360if( DEBUG_RPC_SERVER_GENERIC < cycle )
    357 printk("\n[DBG] %s : RPC thread %x unblocked client thread %x / cycle %d\n",
     361printk("\n[%s] RPC thread %x unblocked client thread %x / cycle %d\n",
    358362__FUNCTION__, server_ptr->trdid, client_ptr->trdid, cycle );
    359363#endif
     
    372376uint32_t cycle = (uint32_t)hal_get_cycles();
    373377if( DEBUG_RPC_SERVER_GENERIC < cycle )
    374 printk("\n[DBG] %s : RPC thread %x suicides / cycle %d\n",
     378printk("\n[%s] RPC thread %x suicides / cycle %d\n",
    375379__FUNCTION__, server_ptr->trdid, cycle );
    376380#endif
     
    391395uint32_t cycle = (uint32_t)hal_get_cycles();
    392396if( DEBUG_RPC_SERVER_GENERIC < cycle )
    393 printk("\n[DBG] %s : RPC thread %x block IDLE & deschedules / cycle %d\n",
     397printk("\n[%s] RPC thread %x block IDLE & deschedules / cycle %d\n",
    394398__FUNCTION__, server_ptr->trdid, cycle );
    395399#endif
     
    870874uint32_t  action = rpc->args[0];
    871875pid_t     pid    = rpc->args[1];
     876thread_t * this = CURRENT_THREAD;
    872877if( 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 );
     878printk("\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 );
    875880#endif
    876881
     
    885890cycle = (uint32_t)hal_get_cycles();
    886891if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
    887 printk("\n[DBG] %s : exit after requesting to %s process %x in cluster %x / cycle %d\n",
    888 __FUNCTION__ , process_action_str( action ) , pid , cxy , cycle );
     892printk("\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 );
    889894#endif
    890895
     
    915920#if DEBUG_RPC_PROCESS_SIGACTION
    916921uint32_t cycle = (uint32_t)hal_get_cycles();
     922thread_t * this = CURRENT_THREAD;
    917923if( 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 );
     924printk("\n[%s] thread[%x,%x] enter to %s process %x in cluster %x / cycle %d\n",
     925__FUNCTION__, this->process->pid, this->trdid,
     926process_action_str( action ), pid, local_cxy, cycle );
    920927#endif
    921928
     
    954961cycle = (uint32_t)hal_get_cycles();
    955962if( 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 );
     963printk("\n[%s] thread[%x,%x] exit after %s process %x in cluster %x / cycle %d\n",
     964__FUNCTION__, this->process->pid, this->trdid,
     965process_action_str( action ), pid, local_cxy, cycle );
    958966#endif
    959967
     
    966974/////////////////////////////////////////////////////
    967975void rpc_vfs_inode_create_client( cxy_t          cxy,     
    968                                   xptr_t         dentry_xp,  // in
    969976                                  uint32_t       fs_type,    // in
    970977                                  uint32_t       inode_type, // in
     
    9931000
    9941001    // 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;
    10021008
    10031009    // register RPC request in remote RPC fifo
     
    10051011
    10061012    // 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];
    10091015
    10101016#if DEBUG_RPC_VFS_INODE_CREATE
     
    10271033#endif
    10281034
    1029     xptr_t           dentry_xp;
    10301035    uint32_t         fs_type;
    10311036    uint32_t         inode_type;
     
    10421047
    10431048    // 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] ) );
    10511055
    10521056    // call local kernel function
    1053     error = vfs_inode_create( dentry_xp,
    1054                               fs_type,
     1057    error = vfs_inode_create( fs_type,
    10551058                              inode_type,
    10561059                              attr,
     
    10611064
    10621065    // 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 );
    10651068
    10661069#if DEBUG_RPC_VFS_INODE_CREATE
     
    11491152                                   uint32_t               type,         // in
    11501153                                   char                 * name,         // in
    1151                                    struct vfs_inode_s   * parent,       // in
    11521154                                   xptr_t               * dentry_xp,    // out
    11531155                                   error_t              * error )       // out
     
    11721174    rpc.args[0] = (uint64_t)type;
    11731175    rpc.args[1] = (uint64_t)(intptr_t)name;
    1174     rpc.args[2] = (uint64_t)(intptr_t)parent;
    11751176
    11761177    // register RPC request in remote RPC fifo
     
    11781179
    11791180    // 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];
    11821183
    11831184#if DEBUG_RPC_VFS_DENTRY_CREATE
     
    12021203    uint32_t      type;
    12031204    char        * name;
    1204     vfs_inode_t * parent;
    12051205    xptr_t        dentry_xp;
    12061206    error_t       error;
     
    12121212
    12131213    // 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] ) );
    12171216
    12181217    // makes a local copy of  name
     
    12231222    error = vfs_dentry_create( type,
    12241223                               name_copy,
    1225                                parent,
    12261224                               &dentry_xp );
    12271225    // 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 );
    12301228
    12311229#if DEBUG_RPC_VFS_DENTRY_CREATE
     
    21122110
    21132111/////////////////////////////////////////////////////////////////////////////////////////
    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/////////////////////////////////////////////////////////////////////////////////////////
    22072114
    22082115/////////////////////////////////////////////////////////////////////////////////////////
     
    22802187
    22812188    // 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 );
    22842191
    22852192#if DEBUG_RPC_MAPPER_HANDLE_MISS
  • trunk/kernel/kern/rpc.h

    r601 r610  
    7777    RPC_VFS_FILE_DESTROY          = 15,
    7878    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,
    8181    RPC_VFS_INODE_LOAD_ALL_PAGES  = 19,
    8282
     
    8585    RPC_KCM_ALLOC                 = 22,
    8686    RPC_KCM_FREE                  = 23,
    87     RPC_MAPPER_MOVE_USER          = 24,
     87    RPC_UNDEFINED_24              = 24,
    8888    RPC_MAPPER_HANDLE_MISS        = 25,
    8989    RPC_UNDEFINED_26              = 26,
     
    307307 ***********************************************************************************
    308308 * @ cxy        :  server cluster identifier.
    309  * @ dentry_xp  : [in]  extended pointer on parent dentry.
    310309 * @ fs_type    : [in]  file system type.
    311310 * @ inode_type : [in]  file system type.
     
    318317 **********************************************************************************/
    319318void rpc_vfs_inode_create_client( cxy_t      cxy,
    320                                   xptr_t     dentry_xp,
    321319                                  uint32_t   fs_type,
    322320                                  uint32_t   inode_type,
     
    349347 * @ type       : [in]  file system type.
    350348 * @ name       : [in]  directory entry name.
    351  * @ parent     : [in]  local pointer on parent inode.
    352349 * @ dentry_xp  : [out] buffer for extended pointer on created dentry.
    353350 * @ error      : [out] error status (0 if success).
     
    356353                                   uint32_t               type,
    357354                                   char                 * name,   
    358                                    struct vfs_inode_s   * parent,
    359355                                   xptr_t               * dentry_xp,
    360356                                   error_t              * error );
     
    546542
    547543/***********************************************************************************
    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 **********************************************************************************/
    570546
    571547/***********************************************************************************
  • trunk/kernel/kern/scheduler.c

    r593 r610  
    254254uint32_t cycle = (uint32_t)hal_get_cycles();
    255255if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    256 printk("\n[DBG] %s : thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
     256printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
    257257__FUNCTION__ , process->pid , thread->trdid , local_cxy , thread->core->lid , cycle );
    258258#endif
     
    266266cycle = (uint32_t)hal_get_cycles();
    267267if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    268 printk("\n[DBG] %s : process %x in cluster %x deleted / cycle %d\n",
     268printk("\n[%s] process %x in cluster %x deleted / cycle %d\n",
    269269__FUNCTION__ , process->pid , local_cxy , cycle );
    270270#endif
     
    336336uint32_t cycle = (uint32_t)hal_get_cycles();
    337337if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    338 printk("\n[DBG] %s : thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
     338printk("\n[%s] thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
    339339__FUNCTION__ , process_zero.pid , thread->trdid , local_cxy , thread->core->lid , cycle );
    340340#endif
     
    396396uint32_t cycle = (uint32_t)hal_get_cycles();
    397397if( DEBUG_SCHED_RPC_ACTIVATE < cycle )
    398 printk("\n[DBG] %s : new RPC thread %x created for core[%x,%d] / total %d / cycle %d\n",
     398printk("\n[%s] new RPC thread %x created for core[%x,%d] / total %d / cycle %d\n",
    399399__FUNCTION__, thread->trdid, local_cxy, lid, LOCAL_CLUSTER->rpc_threads[lid], cycle );
    400400#endif
     
    409409uint32_t cycle = (uint32_t)hal_get_cycles();
    410410if( DEBUG_SCHED_RPC_ACTIVATE < cycle )
    411 printk("\n[DBG] %s : idle RPC thread %x unblocked for core[%x,%d] / cycle %d\n",
     411printk("\n[%s] idle RPC thread %x unblocked for core[%x,%d] / cycle %d\n",
    412412__FUNCTION__, thread->trdid, local_cxy, lid, cycle );
    413413#endif
     
    540540#if DEBUG_SCHED_YIELD
    541541if( sched->trace )
    542 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
     542printk("\n[%s] core[%x,%d] / cause = %s\n"
    543543"      thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n",
    544544__FUNCTION__, local_cxy, lid, cause,
     
    557557#if (DEBUG_SCHED_YIELD & 1)
    558558if( sched->trace )
    559 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
     559printk("\n[%s] core[%x,%d] / cause = %s\n"
    560560"      thread %x (%s) (%x,%x) continue / cycle %d\n",
    561561__FUNCTION__, local_cxy, lid, cause, current, thread_type_str(current->type),
     
    687687        uint32_t      blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) );
    688688        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 ) );
    690690        pid_t         pid     = hal_remote_l32 ( XPTR( cxy , &process->pid ) );
    691691
     
    695695            char      name[16];
    696696            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 ) );
    698698
    699699            nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X / %s\n",
     
    721721        uint32_t      blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) );
    722722        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 ) );
    724724        pid_t         pid     = hal_remote_l32 ( XPTR( cxy , &process->pid ) );
    725725
  • trunk/kernel/kern/thread.h

    r583 r610  
    194194    dma_command_t       dma_cmd;         /*! DMA device generic command               */
    195195
    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)    */
    197197
    198198    list_entry_t        wait_list;       /*! member of a local waiting queue          */
Note: See TracChangeset for help on using the changeset viewer.