Changeset 566 for trunk


Ignore:
Timestamp:
Oct 4, 2018, 11:50:21 PM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

Location:
trunk/kernel/syscalls
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/shared_include/shared_pthread.h

    r457 r566  
    2626
    2727/*******************************************************************************************
     28 *    This file defines the types and mnemonics that are shared by the kernel
     29 *    and by the <pthread> user level library.
     30 ******************************************************************************************/
     31
     32
     33/*******************************************************************************************
    2834 * These typedef define the POSIX thread related types.
    2935 ******************************************************************************************/
    3036
     37typedef unsigned int      pthread_mutex_t;
     38typedef unsigned int      pthread_mutexattr_t;         // TODO not implemented
     39
    3140typedef unsigned int      pthread_cond_t;
    32 typedef unsigned int      pthread_condattr_t;
    33 typedef unsigned int      pthread_rwlock_t;
    34 typedef unsigned int      pthread_rwlockattr_t;
    35 typedef unsigned int      pthread_key_t;
     41typedef unsigned int      pthread_condattr_t;          // TODO not implemented
     42
     43typedef unsigned int      pthread_rwlock_t;            // TODO not implemented
     44typedef unsigned int      pthread_rwlockattr_t;        // TODO not implemented
    3645
    3746/*******************************************************************************************
     
    92101        MUTEX_LOCK,
    93102        MUTEX_UNLOCK,
     103    MUTEX_TRYLOCK,
    94104}
    95105mutex_operation_t;
  • trunk/kernel/syscalls/shared_include/syscalls_numbers.h

    r526 r566  
    8484    SYS_FG             = 48,
    8585    SYS_IS_FG          = 49,
     86
     87    SYSCALLS_NR        = 50,
    8688} syscalls_t;
    8789
    88 // Keep me concistant with enum above !
    89 #define SYSCALLS_NR (50U)
    90 
    9190#endif // _SYSCALLS_NUMBERS_H_
  • trunk/kernel/syscalls/sys_chdir.c

    r506 r566  
    3535
    3636/////////////////////////////////
    37 int sys_chdir ( const char * pathname )
     37int sys_chdir ( char * pathname )
    3838{
    3939    error_t   error;
     
    4646    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
    4747    {
    48         printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     48
     49#if DEBUG_SYSCALLS_ERROR
     50printk("\n[ERROR] in %s : pathname too long / thread %x in process %x\n",
     51__FUNCTION__, this->trdid, process->pid );
     52#endif
    4953        this->errno = ENFILE;
    5054        return -1;
     
    5458    hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    5559
     60    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
     61    return -1;
     62
    5663    // get cluster and local pointer on reference process
    57     xptr_t      ref_xp  = process->ref_xp;
    58     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    59     cxy_t       ref_cxy = GET_CXY( ref_xp );
     64    // xptr_t      ref_xp  = process->ref_xp;
     65    // process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     66    // cxy_t       ref_cxy = GET_CXY( ref_xp );
    6067
    6168    // get extended pointer on cwd lock in reference process
    62     xptr_t lock_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     69    // xptr_t lock_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    6370
    6471    // get cwd lock in read mode
    65     remote_rwlock_rd_lock( lock_xp );
     72    // remote_rwlock_rd_acquire( lock_xp );
    6673
    67     // call relevant VFS function
    68     error = vfs_chdir( process->vfs_cwd_xp , kbuf );
     74    // TODO ce n'et pas au VFS de le faire [AG]
     75    // error = vfs_chdir( process->vfs_cwd_xp , kbuf );
    6976
    7077    // release cwd lock
    71     remote_rwlock_rd_unlock( lock_xp );
     78    // remote_rwlock_rd_release( lock_xp );
    7279
    7380    if( error )
  • trunk/kernel/syscalls/sys_chmod.c

    r506 r566  
    3232#include <syscalls.h>
    3333
    34 //////////////////////////////////
    35 int sys_chmod( const char * pathname,
    36                uint32_t     rights )
     34///////////////////////////////////
     35int sys_chmod( char    * pathname,
     36               uint32_t   rights __attribute__((unused)) )
    3737{
    3838    error_t     error;
     
    4545    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
    4646    {
    47         printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     47
     48#if DEBUG_SYSCALLS_ERROR
     49        printk("\n[ERROR] in %s : pathname too long / thread %x in process %x\n",
     50        __FUNCTION__, this->trdid, process->pid );
     51#endif
    4852        this->errno = ENFILE;
    4953        return -1;
     
    5357    hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    5458
     59    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
     60    return -1;
     61
    5562    // get cluster and local pointer on reference process
    56     xptr_t      ref_xp  = process->ref_xp;
    57     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    58     cxy_t       ref_cxy = GET_CXY( ref_xp );
    59 
    60     // get extended pointer on cwd inode
    61     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    62 
    63     // get the cwd lock in read mode from reference process
    64     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     63    // xptr_t      ref_xp  = process->ref_xp;
     64    // process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     65    // cxy_t       ref_cxy = GET_CXY( ref_xp );
    6566
    6667    // call the relevant VFS function
    67     error = vfs_chmod( cwd_xp,
    68                        kbuf,
    69                        rights );
    70 
    71     // release the cwd lock
    72     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     68    // error = vfs_chmod( cwd_xp,
     69    //                    kbuf,
     70    //                    rights );
    7371
    7472    if( error )
    7573    {
    7674        printk("\n[ERROR] in %s : cannot remove directory %s\n",
    77                __FUNCTION__ , kbuf );
     75        __FUNCTION__ , kbuf );
    7876        this->errno = error;
    7977        return -1;
  • trunk/kernel/syscalls/sys_condvar.c

    r508 r566  
    3232#include <remote_mutex.h>
    3333
    34 ////////////////////////////////////////
     34
     35#if DEBUG_SYS_CONDVAR
     36/////////////////////////////////////////////////////
     37static char * sys_convar_op_str( uint32_t operation )
     38{
     39        if     ( operation == CONDVAR_INIT      ) return "INIT";
     40        else if( operation == CONDVAR_WAIT      ) return "WAIT";
     41        else if( operation == CONDVAR_SIGNAL    ) return "SIGNAL";
     42        else if( operation == CONDVAR_BROADCAST ) return "BROADCAST";
     43        else if( operation == CONDVAR_DESTROY   ) return "DESTROY";
     44        else                                      return "undefined";
     45}
     46#endif
     47
     48//////////////////////////////////////
    3549int sys_condvar( void         * condvar,
    3650                 uint32_t       operation,
    3751                 void         * mutex )
    3852{
     53    vseg_t    * vseg;         // for condvar check
    3954        error_t     error;
    40     vseg_t    * vseg;
    4155 
    4256    thread_t  * this    = CURRENT_THREAD;
    4357    process_t * process = this->process;
     58
     59#if DEBUG_SYS_CONDVAR
     60uint64_t    tm_start;
     61uint64_t    tm_end;
     62tm_start = hal_get_cycles();
     63if( DEBUG_SYS_CONDVAR < tm_start )
     64printk("\n[DBG] %s : thread %x in process %x enter for %s / cycle %d\n",
     65__FUNCTION__, this->trdid, process->pid, sys_condvar_op_str( operation ), (uint32_t)tm_start );
     66#endif
    4467
    4568    // check condvar in user vspace
     
    191214        }   // end switch
    192215
     216    hal_fence();
     217
     218#if DEBUG_SYS_CONDVAR
     219tm_start = hal_get_cycles();
     220if( DEBUG_SYS_MUTEX < tm_start )
     221printk("\n[DBG] %s : thread %x in process %x exit for %s / cycle %d\n",
     222__FUNCTION__, this->trdid, process->pid, sys_condvar_op_str( operation ), (uint32_t)tm_start );
     223#endif
     224
    193225        return 0;
    194226
  • trunk/kernel/syscalls/sys_exec.c

    r509 r566  
    158158// the environment variables from user buffers to the exec_info_t structure, allocate
    159159// and call the process_make_exec() function.
    160 // As it must destroy all process copies, and all othert threads in all clusters,
     160// As it must destroy all process copies, and all other threads in all clusters,
    161161// the process_make_exec() function must be executed in the owner cluster.
    162162//
    163163// TODO : the args & envs arguments are not supported yet : both must be NULL  [AG]
    164164/////////////////////////////////////////////////////////////////////////////////////////
    165 int sys_exec( const char  * pathname, // .elf file pathname
     165int sys_exec( char  * pathname,      // .elf file pathname
    166166              char ** args,           // process arguments
    167167              char ** envs )          // environment variables
    168168{
    169     exec_info_t   exec_info;        // structure to pass to process_make_exec()
     169    exec_info_t   exec_info;          // structure to pass to process_make_exec()
    170170    error_t       error;
    171171
     
    175175    pid_t         pid     = process->pid;
    176176
     177#if DEBUG_SYS_EXEC
     178uint64_t     tm_start = hal_get_cycles();
     179#endif
     180
    177181    assert( (CXY_FROM_PID( pid ) == local_cxy) ,
    178182    "must be called in the owner cluster\n");
     
    202206
    203207#if DEBUG_SYS_EXEC
    204 uint64_t      tm_start;
    205 tm_start = hal_get_cycles();
    206208if( DEBUG_SYS_EXEC < tm_start )
    207209printk("\n[DBG] %s : thread %x in process %x enter for path <%s> / cycle = %d\n",
  • trunk/kernel/syscalls/sys_exit.c

    r506 r566  
    4747    cxy_t       parent_cxy;        // parent process cluster
    4848    process_t * parent_ptr;        // local pointer on parent process
    49     xptr_t      children_lock_xp;  // extended pointer on children locki
    5049    thread_t  * parent_main_ptr;   // local pointer on parent main thread
    5150    xptr_t      parent_main_xp;    // extended pointer on parent main thread
     
    7271#if (DEBUG_SYS_EXIT & 1)
    7372if( DEBUG_SYS_EXIT < tm_start )
    74 printk("\n[DBG] %s : thread %x in process %x get owner process %x in cluster %x\n",
    75 __FUNCTION__, this->trdid, process->pid, owner_ptr, owner_cxy );
     73printk("\n[DBG] %s : thread %x in process %x get owner process in cluster %x\n",
     74__FUNCTION__, this->trdid, process->pid, owner_cxy );
    7675#endif
    7776
    78     // get local pointer on the process main thread
     77    // get local pointer on the main thread
    7978    main_ptr  = hal_remote_lpt( XPTR( owner_cxy , &owner_ptr->th_tbl[0] ) );
    8079
     
    8685#if (DEBUG_SYS_EXIT & 1)
    8786if( DEBUG_SYS_EXIT < tm_start )
    88 printk("\n[DBG] %s : thread %x in process %x get parent process %x in cluster %x\n",
    89 __FUNCTION__, this->trdid, process->pid, parent_ptr, parent_cxy );
     87printk("\n[DBG] %s : thread %x in process %x get parent process in cluster %x\n",
     88__FUNCTION__, this->trdid, process->pid, parent_cxy );
    9089#endif
    91 
    92     // get extended pointer on lock protecting children list in parent process
    93     children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );
    9490
    9591    // get pointers on the parent process main thread
     
    118114#endif
    119115
    120     // mark for delete this calling thread when it is not the main
     116    // mark for delete the calling thread when it is not the main
    121117    if( (owner_cxy != local_cxy) || (main_ptr != this) )
    122118    {
     
    151147
    152148    // unblock the parent process main thread
    153     remote_spinlock_lock( children_lock_xp );
    154149    thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    155     remote_spinlock_unlock( children_lock_xp );
    156150
    157151#if( DEBUG_SYS_EXIT & 1)
    158152if( tm_start > DEBUG_SYS_EXIT )
    159 printk("\n[DBG] %s : thread %x in process %x unblock parent main thread in process %x\n",
     153printk("\n[DBG] %s : thread %x in process %x unblocked parent main thread in process %x\n",
    160154__FUNCTION__ , this->trdid, process->pid,
    161 hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid) ) );
     155hal_remote_l32( XPTR( parent_cxy , &parent_ptr->pid) ) );
    162156#endif
    163157
  • trunk/kernel/syscalls/sys_fg.c

    r506 r566  
    7575
    7676    // get extended pointer on the reference process STDIN file descriptor
    77     file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) );
     77    file_xp = hal_remote_l64( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) );
    7878 
    7979    // get extended pointer on TXT_RX chdev
     
    8585
    8686    // set reference process owner in TXT_RX chdev
    87     hal_remote_swd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) , process_xp );
     87    hal_remote_s64( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) , process_xp );
    8888
    8989    // reset PROCESS_TERM_WAIT and PROCESS_TERM_STOP flags in process term_state
     
    9898printk("\n[DBG] %s : thread %x exit / process %x get TXT_%d ownership / cycle %d\n",
    9999__FUNCTION__ , CURRENT_THREAD , pid,
    100 hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->channel ) ) , (uint32_t)tm_end );
     100hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ) , (uint32_t)tm_end );
    101101#endif
    102102
  • trunk/kernel/syscalls/sys_fork.c

    r506 r566  
    4040#include <syscalls.h>
    4141
    42 //////////////
     42////////////////////
    4343int sys_fork( void )
    4444{
     
    6767    parent_cxy         = local_cxy;
    6868
     69#if (DEBUG_SYS_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)
     70uint64_t     tm_start = hal_get_cycles();
     71#endif
     72
    6973#if DEBUG_SYS_FORK
    70 uint64_t          tm_start;
    71 uint64_t          tm_end;
    72 tm_start = hal_get_cycles();
    7374if( DEBUG_SYS_FORK < tm_start )
    7475printk("\n[DBG] %s : thread %x in process %x enter / cycle =  %d\n",
     
    8788
    8889#if DEBUG_SYSCALLS_ERROR
    89 printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__);
     90printk("\n[ERROR] in %s : thread %x in process %x cannot fork : too much children\n",
     91__FUNCTION__, parent_thread_ptr->trdid, parent_pid );
    9092#endif
    9193            hal_remote_atomic_add ( children_xp , -1 );
     
    134136
    135137#if DEBUG_SYSCALLS_ERROR
    136 printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n",
    137 __FUNCTION__, parent_pid, local_cxy );
     138printk("\n[ERROR] in %s : thread %x in process %x cannot fork to cluster %x\n",
     139__FUNCTION__, parent_thread_ptr->trdid, parent_pid, local_cxy );
    138140#endif
    139141        parent_thread_ptr->errno = EAGAIN;
     
    159161    thread_t * current = CURRENT_THREAD;
    160162
     163#if (DEBUG_SYS_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)
     164uint64_t     tm_end = hal_get_cycles();
     165#endif
     166
     167#if DEBUG_SYS_FORK
     168if( DEBUG_SYS_FORK < tm_end )
     169printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     170__FUNCTION__, current->trdid, current->process->pid, (uint32_t)tm_end );
     171#endif
     172
    161173    if( (current == parent_thread_ptr) && (local_cxy == parent_cxy) )   // parent thread
    162174    {
     
    164176        thread_unblock( XPTR( child_cxy , child_thread_ptr ) , THREAD_BLOCKED_GLOBAL );
    165177
    166 #if DEBUG_SYS_FORK
    167 tm_end = hal_get_cycles();
    168 if( DEBUG_SYS_FORK < tm_end )
    169 printk("\n[DBG] %s : process %x exit / cost = %d / cycle %d\n",
    170 __FUNCTION__, parent_pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
     178        // only parent contribute to instrumentation
     179
     180#if CONFIG_INSTRUMENTATION_SYSCALLS
     181hal_atomic_add( &syscalls_cumul_cost[SYS_FORK] , tm_end - tm_start );
     182hal_atomic_add( &syscalls_occurences[SYS_FORK] , 1 );
    171183#endif
    172184        return child_pid;
     
    174186        else                                                               // child_thread
    175187    {
    176 
    177 #if DEBUG_SYS_FORK
    178 tm_end = hal_get_cycles();
    179 if( DEBUG_SYS_FORK < tm_end )
    180 printk("\n[DBG] %s : process %x exit / cost = %d / cycle %d\n",
    181 __FUNCTION__, child_pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    182 #endif
    183188        return 0;
    184189    }
  • trunk/kernel/syscalls/sys_get_config.c

    r506 r566  
    3737int sys_get_config( uint32_t * x_size,
    3838                    uint32_t * y_size,
    39                     uint32_t * y_width,
    4039                    uint32_t * ncores )
    4140{
  • trunk/kernel/syscalls/sys_getcwd.c

    r506 r566  
    8080
    8181    // get CWD lock in read mode
    82         remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     82        remote_rwlock_rd_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    8383
    8484    // call relevant VFS function
     
    8686                          kbuf , CONFIG_VFS_MAX_PATH_LENGTH );
    8787
    88     // release CWD lock
    89         remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     88    // release CWD lock in read mode
     89        remote_rwlock_rd_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    9090
    9191    // copy kernel buffer to user space
  • trunk/kernel/syscalls/sys_getpid.c

    r506 r566  
    11/*
    2  * kern/sys_getpid.c - get process id
     2 * kern/sys_getpid.c - Kernel function implementing the "get_pid" system call.
    33 *
    4  * Author     Alain Greiner  (2016,2017)
     4 * Author     Alain Greiner  (2016,2017, 2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2323
    2424#include <thread.h>
    25 
     25#include <process.h>
    2626#include <syscalls.h>
    2727
    28 ////////////////
     28//////////////////////
    2929int sys_getpid( void )
    3030{
    31         return CURRENT_THREAD->process->pid;
    32 }
     31    thread_t  * this    = CURRENT_THREAD;
     32    process_t * process = this->process;
     33
     34#if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS)
     35uint64_t     tm_start = hal_get_cycles();
     36#endif
     37
     38#if DEBUG_SYS_GETPID
     39tm_start = hal_get_cycles();
     40if( DEBUG_SYS_FG < tm_start )
     41printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
     42__FUNCTION__ , this->trdid , process->pid, (uint32_t)tm_start );
     43#endif
     44
     45    // get pid value from local process descriptor   
     46    pid_t pid = process->pid;
     47
     48#if (DEBUG_SYS_GETPID || CONFIG_INSTRUMENTATION_SYSCALLS)
     49uint64_t     tm_end = hal_get_cycles();
     50#endif
     51
     52#if DEBUG_SYS_GETPID
     53tm_end = hal_get_cycles();
     54if( DEBUG_SYS_GETPID < tm_end )
     55printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     56__FUNCTION__, this->trdid, process->pid, (uint32_t)tm_end );
     57#endif
     58
     59#if CONFIG_INSTRUMENTATION_SYSCALLS
     60hal_atomic_add( &syscalls_cumul_cost[SYS_GETPID] , tm_end - tm_start );
     61hal_atomic_add( &syscalls_occurences[SYS_GETPID] , 1 );
     62#endif
     63
     64        return pid;
     65
     66}  // end sys_getpid()
  • trunk/kernel/syscalls/sys_is_fg.c

    r506 r566  
    4848    process_t * process = this->process;
    4949
     50#if (DEBUG_SYS_IS_FG || CONFIG_INSTRUMENTATION_SYSCALLS)
     51uint64_t     tm_start = hal_get_cycles();
     52#endif
     53
    5054#if DEBUG_SYS_IS_FG
    51 uint64_t    tm_start;
    52 uint64_t    tm_end;
    5355tm_start = hal_get_cycles();
    54 if( DEBUG_SYS_FG < tm_start )
     56if( DEBUG_SYS_IS_FG < tm_start )
    5557printk("\n[DBG] %s : thread %x in process %x enter for pid %x / cycle %d\n",
    5658__FUNCTION__ , this->trdid , process->pid, pid, (uint32_t)tm_start );
     
    9294    hal_fence();
    9395
     96#if (DEBUG_SYS_IS_FG || CONFIG_INSTRUMENTATION_SYSCALLS)
     97uint64_t     tm_end = hal_get_cycles();
     98#endif
     99
    94100#if DEBUG_SYS_IS_FG
    95101tm_end = hal_get_cycles();
    96 if( DEBUG_SYS_FG < tm_end )
     102if( DEBUG_SYS_IS_FG < tm_end )
    97103printk("\n[DBG] %s : thread %x in process %x exit / is_txt_owner %d / cycle %d\n",
    98104__FUNCTION__, this->trdid, process->pid, is_txt_owner, (uint32_t)tm_end );
    99105#endif
    100106
    101         return 0;
     107#if CONFIG_INSTRUMENTATION_SYSCALLS
     108hal_atomic_add( &syscalls_cumul_cost[SYS_IS_FG] , tm_end - tm_start );
     109hal_atomic_add( &syscalls_occurences[SYS_IS_FG] , 1 );
     110#endif
     111
     112return 0;
    102113
    103114}  // end sys_is_fg()
  • trunk/kernel/syscalls/sys_isatty.c

    r506 r566  
    8989
    9090    // get file type
    91     vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
     91    vfs_inode_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );
    9292
    9393    // action depend on file type
     
    104104
    105105        // get chdev type
    106         chdev_func = hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->func ) );
     106        chdev_func = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->func ) );
    107107
    108108        if( chdev_func == DEV_FUNC_TXT ) retval = 1;
  • trunk/kernel/syscalls/sys_kill.c

    r506 r566  
    4747    cxy_t       parent_cxy;        // parent process cluster
    4848    process_t * parent_ptr;        // local pointer on parent process
    49     xptr_t      children_lock_xp;  // extended pointer on children lock in parent
    5049    thread_t  * parent_main_ptr;   // local pointer on parent main thread
    5150    xptr_t      parent_main_xp;    // extended pointer on parent main thread
     
    108107
    109108    // get parent process descriptor pointers
    110     parent_xp  = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
     109    parent_xp  = (xptr_t)hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    111110    parent_cxy = GET_CXY( parent_xp );
    112111    parent_ptr = GET_PTR( parent_xp );
     
    118117#endif
    119118
    120     // get extended pointer on lock protecting children list in parent process
    121     children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );
    122 
    123119    // get pointers on the parent process main thread
    124120    parent_main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );
     
    149145                                  PROCESS_TERM_STOP );
    150146
    151             // take the children lock and unblock the parent process main thread
    152             remote_spinlock_lock( children_lock_xp );
     147            // unblock the parent process main thread
    153148            thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    154             remote_spinlock_unlock( children_lock_xp );
    155149
    156150            retval = 0;
     
    188182                                  PROCESS_TERM_KILL );
    189183
    190             // take the children lock and unblock the parent process main thread
    191             remote_spinlock_lock( children_lock_xp );
     184            // unblock the parent process main thread
    192185            thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
    193             remote_spinlock_unlock( children_lock_xp );
    194186
    195187            retval = 0;
  • trunk/kernel/syscalls/sys_mkdir.c

    r457 r566  
    3333///////////////////////////////////
    3434int sys_mkdir( char     * pathname,
    35                uint32_t   mode )
     35               uint32_t   mode __attribute__((unused)) )
    3636{
    3737    error_t        error;
     
    5858    }
    5959
     60    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
     61    return -1;
     62   
    6063    // copy pathname in kernel space
    6164    hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    6265
    6366    // get cluster and local pointer on reference process
    64     xptr_t      ref_xp  = process->ref_xp;
    65     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    66     cxy_t       ref_cxy = GET_CXY( ref_xp );
     67    // xptr_t      ref_xp  = process->ref_xp;
     68    // process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     69    // cxy_t       ref_cxy = GET_CXY( ref_xp );
    6770
    6871    // get extended pointer on cwd inode
    69     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
     72    // xptr_t cwd_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    7073
    7174    // get the cwd lock in read mode from reference process
    72     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     75    // remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    7376
    7477    // call the relevant VFS function
    75     error = vfs_mkdir( cwd_xp,
    76                        kbuf,
    77                        mode );
     78    // error = vfs_mkdir( cwd_xp,
     79    //                   kbuf,
     80    //                   mode );
    7881
    7982    // release the cwd lock
    80     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     83    // remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    8184
    8285    if( error )
  • trunk/kernel/syscalls/sys_mkfifo.c

    r457 r566  
    3131////////////////////////////////////
    3232int sys_mkfifo ( char    * pathname,
    33                  uint32_t  mode )
     33                 uint32_t  mode __attribute__((unused)) )
    3434{
    3535    error_t        error;
     
    5959    hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    6060
    61     // get cluster and local pointer on reference process
    62     xptr_t      ref_xp  = process->ref_xp;
    63     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    64     cxy_t       ref_cxy = GET_CXY( ref_xp );
    65 
    66     // get extended pointer on cwd inode
    67     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    68 
    69     // get the cwd lock in read mode from reference process
    70     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    71 
    72     // call the relevant VFS function
    73     error = vfs_mkfifo( cwd_xp,
    74                         kbuf,
    75                         mode );
    76 
    77     // release the cwd lock
    78     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     61    printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ );
     62    return -1;
    7963
    8064    if( error )
  • trunk/kernel/syscalls/sys_mmap.c

    r506 r566  
    156156        // get inode pointer, mapper pointer and file attributes
    157157        vfs_inode_t * inode_ptr  = hal_remote_lpt(XPTR(file_cxy , &file_ptr->inode ));
    158         uint32_t      file_attr  = hal_remote_lw (XPTR(file_cxy , &file_ptr->attr  ));
     158        uint32_t      file_attr  = hal_remote_l32 (XPTR(file_cxy , &file_ptr->attr  ));
    159159        mapper_t    * mapper_ptr = hal_remote_lpt(XPTR(file_cxy , &file_ptr->mapper));
    160160
    161161        // get file size
    162                 uint32_t size = hal_remote_lw( XPTR( file_cxy , &inode_ptr->size ) );
     162                uint32_t size = hal_remote_l32( XPTR( file_cxy , &inode_ptr->size ) );
    163163
    164164        // chek offset and length arguments
  • trunk/kernel/syscalls/sys_mutex.c

    r508 r566  
    3232
    3333
     34#if DEBUG_SYS_MUTEX
     35////////////////////////////////////////////////////
     36static char * sys_mutex_op_str( uint32_t operation )
     37{
     38        if     ( operation == MUTEX_INIT     ) return "INIT";
     39        else if( operation == MUTEX_LOCK     ) return "LOCK";
     40        else if( operation == MUTEX_UNLOCK   ) return "UNLOCK";
     41        else if( operation == MUTEX_TRYLOCK  ) return "TRYLOCK";
     42        else if( operation == MUTEX_DESTROY  ) return "DESTROY";
     43        else                                   return "undefined";
     44}
     45#endif
     46
    3447/////////////////////////////////
    3548int sys_mutex( void     * vaddr,
     
    3851{
    3952        error_t     error;
    40     vseg_t    * vseg;
     53    vseg_t    * vseg;      // for vaddr check
    4154
    4255    thread_t  * this    = CURRENT_THREAD;
    4356    process_t * process = this->process;
     57
     58#if DEBUG_SYS_MUTEX
     59uint64_t    tm_start;
     60uint64_t    tm_end;
     61tm_start = hal_get_cycles();
     62if( DEBUG_SYS_MUTEX < tm_start )
     63printk("\n[DBG] %s : thread %x in process %x enter for %s / cycle %d\n",
     64__FUNCTION__, this->trdid, process->pid, sys_mutex_op_str( operation ), (uint32_t)tm_start );
     65#endif
    4466
    4567    // check vaddr in user vspace
     
    148170            else                          // success
    149171            {
    150                 remote_mutex_unlock( mutex_xp );
     172                error = remote_mutex_unlock( mutex_xp );
     173
     174                if( error )
     175                {
     176
     177#if DEBUG_SYSCALLS_ERROR
     178printk("\n[ERROR] in %s : mutex %x not owned in UNLOCK / thread %x / process %x\n",
     179__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     180#endif
     181                    this->errno = EINVAL;
     182                    return -1;
     183                }
     184            }
     185            break;
     186        }
     187        ///////////////////
     188            case MUTEX_TRYLOCK:
     189        {
     190            xptr_t mutex_xp = remote_mutex_from_ident( (intptr_t)vaddr );
     191
     192            if( mutex_xp == XPTR_NULL )     // user error
     193            {
     194
     195#if DEBUG_SYSCALLS_ERROR
     196printk("\n[ERROR] in %s : mutex %x not registered / thread %x / process %x\n",
     197__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     198#endif
     199                this->errno = EINVAL;
     200                return -1;
     201            }
     202            else                          // success
     203            {
     204                error = remote_mutex_trylock( mutex_xp );
     205
     206                if( error ) // non fatal : mutex already taken
     207                {
     208                    this->errno = EBUSY;
     209                    return -1;
     210                }
    151211            }
    152212            break;
    153213        }
    154214        ////////
    155         default: {
     215        default:
     216        {
    156217            assert ( false, "illegal operation type <%x>", operation );
    157218        }
    158219        }
    159220
     221    hal_fence();
     222
     223#if DEBUG_SYS_MUTEX
     224tm_end = hal_get_cycles();
     225if( DEBUG_SYS_MUTEX < tm_start )
     226printk("\n[DBG] %s : thread %x in process %x exit for %s / cost %d / cycle %d\n",
     227__FUNCTION__, this->trdid, process->pid, sys_mutex_op_str( operation ),
     228(uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
     229#endif
     230
    160231        return 0;
    161232
  • trunk/kernel/syscalls/sys_open.c

    r506 r566  
    3030#include <vfs.h>
    3131#include <process.h>
    32 #include <remote_spinlock.h>
    3332#include <remote_rwlock.h>
    3433
     
    3635
    3736///////////////////////////////////
    38 int sys_open ( const char * pathname,
    39                uint32_t     flags,
    40                uint32_t     mode )
     37int sys_open ( char    * pathname,
     38               uint32_t   flags,
     39               uint32_t   mode )
    4140{
    4241    error_t        error;
     
    5756    if( process_fd_array_full() )
    5857    {
    59         printk("\n[ERROR] in %s : file descriptor array full for process %x\n",
    60                __FUNCTION__ , process->pid );
     58
     59#if DEBUG_SYSCALLS_ERROR
     60printk("\n[ERROR] in %s : file descriptor array full for process %x\n",
     61__FUNCTION__ , process->pid );
     62#endif
    6163        this->errno = ENFILE;
    6264        return -1;
     
    6668    if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH )
    6769    {
    68         printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     70
     71#if DEBUG_SYSCALLS_ERROR
     72printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     73#endif
    6974        this->errno = ENFILE;
    7075        return -1;
     
    8691
    8792    // get the cwd lock in read mode from reference process
    88     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     93    remote_rwlock_rd_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    8994
    9095    // call the relevant VFS function
     
    97102
    98103    // release the cwd lock
    99     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     104    remote_rwlock_rd_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    100105
    101106    if( error )
     
    106111        return -1;
    107112    }
    108 
    109     // update local fd_array
    110     remote_spinlock_lock( XPTR( local_cxy , &process->fd_array.lock ) );
    111     process->fd_array.array[file_id] = file_xp;
    112     remote_spinlock_unlock( XPTR( local_cxy , &process->fd_array.lock ) );
    113 
    114     hal_fence();
    115113
    116114#if DEBUG_SYS_OPEN
  • trunk/kernel/syscalls/sys_read.c

    r506 r566  
    3434#include <process.h>
    3535
    36 #include <syscalls.h>
    37 
    38 // TODO: concurrent user page(s) munmap need to be handled [AG]
    3936
    4037extern uint32_t enter_sys_read;
     
    6966    xptr_t       process_owner_xp = process->owner_xp;
    7067 
     68#if (DEBUG_SYS_READ || CONFIG_INSTRUMENTATION_SYSCALLS)
     69uint64_t     tm_start = hal_get_cycles();
     70#endif
     71
    7172#if DEBUG_SYS_READ
    72 uint64_t     tm_start;
    73 uint64_t     tm_end;
    74 tm_start = hal_get_cycles();
    7573if( DEBUG_SYS_READ < tm_start )
    7674printk("\n[DBG] %s : thread %x in process %x enter / vaddr %x / count %d / cycle %d\n",
     
    130128
    131129    // check file readable
    132     uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) );
     130    uint32_t attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) );
    133131    if( (attr & FD_ATTR_READ_ENABLE) == 0 )
    134132        {
     
    143141   
    144142    // get file type
    145     vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
     143    vfs_inode_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );
    146144
    147145    // action depend on file type
     
    149147    {
    150148        // check file readable
    151         uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) );
     149        uint32_t attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) );
    152150
    153151        if( (attr & FD_ATTR_READ_ENABLE) == 0 )
     
    181179        {
    182180            // extended pointer on TXT owner process
    183             txt_owner_xp  = hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) );
     181            txt_owner_xp  = hal_remote_l64( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) );
    184182
    185183            // check TXT_RX ownership
     
    230228    hal_fence();
    231229
     230#if (DEBUG_SYS_READ || CONFIG_INSTRUMENTATION_SYSCALLS)
     231uint64_t     tm_end = hal_get_cycles();
     232#endif
     233
    232234#if DEBUG_SYS_READ
    233 tm_end = hal_get_cycles();
    234235if( DEBUG_SYS_READ < tm_end )
    235 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d / cost %d\n",
    236 __FUNCTION__ , this->trdid, process->pid, (uint32_t)tm_start, (uint32_t)(tm_end - tm_start) );
     236printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     237__FUNCTION__ , this->trdid, process->pid, (uint32_t)tm_end );
     238#endif
     239
     240#if CONFIG_INSTRUMENTATION_SYSCALLS
     241hal_atomic_add( &syscalls_cumul_cost[SYS_READ] , tm_end - tm_start );
     242hal_atomic_add( &syscalls_occurences[SYS_READ] , 1 );
    237243#endif
    238244
  • trunk/kernel/syscalls/sys_rmdir.c

    r506 r566  
    3434
    3535////////////////////////////////
    36 int sys_rmdir( const char * pathname )
     36int sys_rmdir( char * pathname )
    3737{
    3838    error_t     error;
     
    5959
    6060    // get extended pointer on cwd inode
    61     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
     61    xptr_t cwd_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    6262   
    63     // get the cwd lock in read mode from reference process
    64         remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     63    // get the cwd lock in write mode from reference process
     64        remote_rwlock_wr_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    6565
    6666    // call the relevant VFS function
     
    6969
    7070    // release the cwd lock
    71         remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     71        remote_rwlock_wr_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    7272
    7373    if( error )
  • trunk/kernel/syscalls/sys_sem.c

    r469 r566  
    5151             uint32_t     * current_value )   // pointer on current value buffer
    5252{
    53         vseg_t         * vseg;
     53        vseg_t         * vseg;        // for vaddr check
    5454    error_t          error;
    55     uint32_t         current;     // semaphore current value
    56     xptr_t           sem_xp;      // extended pointer on semaphore
    5755
    5856    thread_t       * this    = CURRENT_THREAD;
     
    9088            // call relevant kernel function to initialize semaphore
    9189            error = remote_sem_create( (intptr_t)vaddr ,
    92                                        init_value,
    93                                        XPTR( local_cxy , &sem_xp ) );
    94 
     90                                       init_value );
    9591            if ( error )
    9692            {
     
    10399                return -1;
    104100            }
    105 
    106             break;
    107         }
     101        }
     102        break;
    108103        //////////////////
    109104        case SEM_GETVALUE:
     
    115110
    116111#if DEBUG_SYSCALLS_ERROR
    117 printk("\n[ERROR] in %s GETVALUE: unmapped target buffer %x / thread %x in process %x / cycle %d\n",
     112printk("\n[ERROR] in %s GETVALUE: unmapped buffer %x / thread %x in process %x / cycle %d\n",
    118113__FUNCTION__ , (intptr_t)current_value, this->trdid, process->pid, (uint32_t)hal_get_cycles() );
    119114vmm_display( process , false );
     
    124119
    125120            // get extended pointer on remote semaphore
    126             sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );
     121            xptr_t sem_xp = remote_sem_from_ident( (intptr_t)vaddr );
    127122
    128123            // check semaphore registered
     
    139134
    140135            // call relevant kernel function to get semaphore current value
     136            uint32_t current;
    141137                    remote_sem_get_value( sem_xp , &current );
    142138 
    143139            // return value to user
    144140            hal_copy_to_uspace( current_value , &current , sizeof(uint32_t) );
    145 
    146             break;
    147         }
     141        }
     142        break;
    148143        //////////////
    149144            case SEM_WAIT:
    150145        { 
    151146            // get extended pointer on remote semaphore
    152             sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );
     147            xptr_t sem_xp = remote_sem_from_ident( (intptr_t)vaddr );
    153148
    154149            // check semaphore registered
     
    167162            // call relevant kernel function to wait semaphore available
    168163            remote_sem_wait( sem_xp );
    169            
    170             break;
    171         }
     164        }
     165        break;
    172166        //////////////
    173167            case SEM_POST:
    174168        {
    175169            // get extended pointer on remote semaphore
    176             sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );
     170            xptr_t sem_xp = remote_sem_from_ident( (intptr_t)vaddr );
    177171
    178172            // check semaphore registered
     
    190184            // call relevant kernel function to release semaphore
    191185            remote_sem_post( sem_xp );
    192 
    193                         break;
    194         }
     186        }
     187                break;
    195188        /////////////////
    196189            case SEM_DESTROY:
    197190        {
    198191            // get extended pointer on remote semaphore
    199             sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );
     192            xptr_t sem_xp = remote_sem_from_ident( (intptr_t)vaddr );
    200193
    201194            // check semaphore registered
     
    213206            // destroy semaphore
    214207            remote_sem_destroy( sem_xp );
    215 
    216             break;
    217208            }   
     209        break;
    218210        ///////
    219211            default:  // undefined operation                       
     
    234226tm_end = hal_get_cycles();
    235227if( DEBUG_SYS_SEM < tm_end )
    236 {
    237     cxy_t          sem_cxy = GET_CXY( sem_xp );
    238     remote_sem_t * sem_ptr = GET_PTR( sem_xp );
    239     uint32_t       value   = hal_remote_lw( XPTR( sem_cxy , &sem_ptr->count ) );
    240     printk("\n[DBG] %s : thread %x in process %x exit for %s / value %d / cost = %d / cycle %d\n",
    241     __FUNCTION__, this->trdid, process->pid, sys_sem_op_str( operation ), value,
    242     (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    243 }
     228printk("\n[DBG] %s : thread %x in process %x exit for %s / cost = %d / cycle %d\n",
     229__FUNCTION__, this->trdid, process->pid, sys_sem_op_str( operation ),
     230(uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    244231#endif
    245232
  • trunk/kernel/syscalls/sys_stat.c

    r509 r566  
    3535
    3636/////////////////////////////////////
    37 int sys_stat( const char  * pathname,
     37int sys_stat( char        * pathname,
    3838              struct stat * u_stat )
    3939{
     
    7979
    8080    // get extended pointer on cwd inode
    81     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
     81    xptr_t cwd_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    8282
    8383    // get the cwd lock in read mode from reference process
    84     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     84    remote_rwlock_rd_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    8585
    8686    // get extended pointer on remote file descriptor
     
    9191
    9292    // release the cwd lock
    93     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     93    remote_rwlock_rd_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    9494
    9595    if( error )
  • trunk/kernel/syscalls/sys_thread_create.c

    r506 r566  
    3535#include <kmem.h>
    3636#include <process.h>
    37 #include <spinlock.h>
    3837#include <dqdt.h>
    3938#include <rpc.h>
     
    4140#include <syscalls.h>
    4241
    43 ///////////////////////////////////////////////////
    44 int sys_thread_create(
    45   struct thread_s             * new_thread,
    46   const struct pthread_attr_s * user_attr,
    47   const void                  * start_func,
    48   const void                  * start_args )
     42/////////////////////////////////////////////////////////
     43int sys_thread_create( trdid_t               * trdid_ptr,
     44                       struct pthread_attr_s * user_attr,
     45                       void                  * start_func,
     46                       void                  * start_args )
    4947{
    5048        pthread_attr_t   kern_attr;        // copy of pthread attributes in kernel space
    5149        thread_t       * parent;           // pointer on thread executing the pthread_create
    52         xptr_t           parent_xp;        // extended pointer on created thread
     50        xptr_t           parent_xp;        // extended pointer on calling thread
     51    cxy_t            child_cxy;        // created child thread cluster identifier
    5352        thread_t       * child_ptr;        // pointer on created child thread
    5453        xptr_t           child_xp;         // extended pointer on created thread
     
    5655        process_t      * process;          // pointer on local process descriptor
    5756        vseg_t         * vseg;             // required for user space checking
    58     cxy_t            target_cxy;       // target cluster identifier
    5957        error_t          error;
    6058
     
    6967tm_start = hal_get_cycles();
    7068if( DEBUG_SYS_THREAD_CREATE < tm_start )
    71 printk("\n[DBG] %s : thread %x (cxy %x) enter / process %x / cycle %d\n",
    72 __FUNCTION__, parent, local_cxy, process->pid, (uint32_t)tm_start );
     69printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
     70__FUNCTION__, parent->trdid, process->pid, (uint32_t)tm_start );
    7371#endif
    7472
    7573    // check trdid buffer in user space
    76     error = vmm_get_vseg( process , (intptr_t)new_thread , &vseg );
     74    error = vmm_get_vseg( process , (intptr_t)trdid_ptr , &vseg );
    7775
    7876    if ( error )
     
    8078
    8179#if DEBUG_SYSCALLS_ERROR
    82 printk("\n[ERROR] in %s : trdid buffer unmapped %x / thread %x / process %x\n",
    83 __FUNCTION__ , (intptr_t)new_thread, parent->trdid, process->pid );
     80printk("\n[ERROR] in %s : thread %x in process %x / trdid buffer %x unmapped %x\n",
     81__FUNCTION__, parent->trdid, process->pid, (intptr_t)trdid_ptr );
    8482vmm_display( process , false );
    8583#endif
     
    9795
    9896#if DEBUG_SYSCALLS_ERROR
    99 printk("\n[ERROR] in %s : user_attr buffer unmapped %x / thread %x / process %x\n",
    100 __FUNCTION__ , (intptr_t)user_attr , parent->trdid , process->pid );
     97printk("\n[ERROR] in %s : thread %x in process %x / user_attr buffer unmapped %x\n",
     98__FUNCTION__, parent->trdid, process->pid, (intptr_t)user_attr );
    10199vmm_display( process , false );
    102100#endif
     
    115113
    116114#if DEBUG_SYSCALLS_ERROR
    117 printk("\n[ERROR] in %s : start_func unmapped %x / thread %x / process %x\n",
    118 __FUNCTION__ , (intptr_t)start_func , parent->trdid , process->pid );
     115printk("\n[ERROR] in %s : thread %x in process %x / start_func unmapped %x\n",
     116__FUNCTION__, parent->trdid, process->pid, (intptr_t)start_func );
    119117vmm_display( process , false );
    120118#endif
     
    132130
    133131#if DEBUG_SYSCALLS_ERROR
    134 printk("\n[ERROR] in %s : start_args buffer unmapped %x / thread %x / process %x\n",
    135 __FUNCTION__ , (intptr_t)start_args , parent->trdid , process->pid );
     132printk("\n[ERROR] in %s : thread %x in process %x / start_args buffer unmapped %x\n",
     133__FUNCTION__, parent->trdid, process->pid, (intptr_t)start_args );
    136134vmm_display( process , false );
    137135#endif
     
    141139        }
    142140
    143     // define attributes and target_cxy
     141    // define attributes and child_cxy
    144142    if( user_attr != NULL )                      // user defined attributes
    145143    {
    146             // check / get target_cxy
     144            // check / get child_cxy
    147145            if( kern_attr.attributes & PT_ATTR_CLUSTER_DEFINED )
    148146            {
     
    151149
    152150#if DEBUG_SYSCALLS_ERROR
    153 printk("\n[ERROR] in %s : illegal target cluster = %x / thread %x / process %x\n",
    154 __FUNCTION__ , kern_attr.cxy, parent->trdid, process->pid );
     151printk("\n[ERROR] in %s : thread %x in process %x / illegal target cluster %x\n",
     152__FUNCTION__, parent->trdid, process->pid, kern_attr.cxy );
    155153#endif
    156154                            parent->errno = EINVAL;
    157155                            return -1;
    158156            }
    159             target_cxy = kern_attr.cxy;
     157            child_cxy = kern_attr.cxy;
    160158                }
    161159        else
    162160        {
    163             target_cxy = dqdt_get_cluster_for_process();
     161            child_cxy = dqdt_get_cluster_for_process();
    164162        }
    165163        }
     
    167165        {
    168166        kern_attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED;
    169         target_cxy           = dqdt_get_cluster_for_process();
     167        child_cxy           = dqdt_get_cluster_for_process();
    170168        }
    171169
     
    173171        // this returns "error", "child_ptr", and "child_xp"
    174172
    175         if( target_cxy == local_cxy )                         // target cluster is local
     173        if( child_cxy == local_cxy )                         // target cluster is local
    176174        {
    177175                // create thread in local cluster
     
    186184        else                                                 // target cluster is remote
    187185        {
    188                 rpc_thread_user_create_client( target_cxy,
     186                rpc_thread_user_create_client( child_cxy,
    189187                                               process->pid,
    190188                                               start_func,
     
    202200
    203201#if DEBUG_SYSCALLS_ERROR
    204 printk("\n[ERROR] in %s : cannot create new thread / thread %x / process %x\n",
     202printk("\n[ERROR] in %s : thread %x in process %x cannot create new thread\n",
    205203__FUNCTION__ , parent->trdid, process->pid );
    206204#endif
     
    210208
    211209        // returns trdid to user space
    212         trdid = hal_remote_lw( XPTR( target_cxy , &child_ptr->trdid ) );
    213         hal_copy_to_uspace( new_thread , &trdid , sizeof(pthread_t) );
     210        trdid = hal_remote_l32( XPTR( child_cxy , &child_ptr->trdid ) );
     211        hal_copy_to_uspace( trdid_ptr , &trdid , sizeof(pthread_t) );
    214212
    215213    // activate new thread
     
    221219tm_end = hal_get_cycles();
    222220if( DEBUG_SYS_THREAD_CREATE < tm_end )
    223 printk("\n[DBG] %s : thread %x (cxy %x) created thread %x (cxy %x) / process %x / cycle %d\n",
    224 __FUNCTION__, parent, local_cxy, child_ptr, target_cxy, process->pid, (uint32_t)tm_end );
     221printk("\n[DBG] %s : thread %x in process %x created thread %x / cycle %d\n",
     222__FUNCTION__, parent->trdid, process->pid, child_ptr->trdid, (uint32_t)tm_end );
    225223#endif
    226224
  • trunk/kernel/syscalls/sys_thread_detach.c

    r506 r566  
    4848
    4949    // check trdid argument
    50         if( (target_ltid >= CONFIG_THREAD_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
     50        if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
    5151        {
    5252        printk("\n[ERROR] in %s : illegal trdid argument\n", __FUNCTION__ );
     
    6969
    7070    // get target thread flags
    71     flags = hal_remote_lw( XPTR( target_cxy , &target_ptr->flags ) );
     71    flags = hal_remote_l32( XPTR( target_cxy , &target_ptr->flags ) );
    7272
    7373    // check target thread joinable
  • trunk/kernel/syscalls/sys_thread_exit.c

    r506 r566  
    6262tm_start = hal_get_cycles();
    6363if( DEBUG_SYS_THREAD_EXIT < tm_start )
    64 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
    65 __FUNCTION__ , this, pid , (uint32_t)tm_start );
     64printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n",
     65__FUNCTION__ , this->trdid, pid , (uint32_t)tm_start );
    6666#endif
    6767
     
    9898tm_end = hal_get_cycles();
    9999if( DEBUG_SYS_THREAD_EXIT < tm_end )
    100 printk("\n[DBG] %s : thread %x exit / process %x / cost %d / cycle %d\n",
    101 __FUNCTION__, this, pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
     100printk("\n[DBG] %s : thread %x in process %x exit / cost %d / cycle %d\n",
     101__FUNCTION__, this->trdid, pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    102102#endif
    103103
  • trunk/kernel/syscalls/sys_thread_join.c

    r506 r566  
    3131#include <errno.h>
    3232#include <printk.h>
    33 #include <remote_spinlock.h>
     33#include <remote_busylock.h>
    3434
    3535#include <syscalls.h>
     
    6767tm_start = hal_get_cycles();
    6868if( DEBUG_SYS_THREAD_JOIN < tm_start )
    69 printk("\n[DBG] %s : parent thread %x enter / process %x / target trdid %x / cycle %d\n",
    70 __FUNCTION__ , joining_ptr , process->pid , trdid , (uint32_t)tm_start );
     69printk("\n[DBG] %s : thread %x in process %x enter / target thread %x / cycle %d\n",
     70__FUNCTION__ , joining_ptr->trdid, process->pid, trdid , (uint32_t)tm_start );
    7171#endif
    7272
    7373    // check trdid argument
    74         if( (target_ltid >= CONFIG_THREAD_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
     74        if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
    7575        {
    7676
     
    126126
    127127    // check target thread joinable
    128     if( (hal_remote_lw( target_flags_xp ) & THREAD_FLAG_DETACHED) == 0 )
     128    if( (hal_remote_l32( target_flags_xp ) & THREAD_FLAG_DETACHED) != 0 )
    129129    {
    130130
     
    140140
    141141    // get the lock protecting the join in target thread
    142     remote_spinlock_lock( target_join_lock_xp );
     142    remote_busylock_acquire( target_join_lock_xp );
    143143
    144144    // test the kill_done flag from the target thread
    145     if( hal_remote_lw( target_flags_xp ) & THREAD_FLAG_KILL_DONE )  // killer thread is first
    146     {
     145    if( hal_remote_l32( target_flags_xp ) & THREAD_FLAG_KILL_DONE )  // killer thread is first
     146    {
     147
     148#if (DEBUG_SYS_THREAD_JOIN & 1)
     149if( DEBUG_SYS_THREAD_JOIN < tm_start )
     150printk("\n[DBG] %s : thread %x in process %x / killer thread arrived first\n",
     151__FUNCTION__ , joining_ptr->trdid, process->pid );
     152#endif
    147153        // get pointers on killer thread
    148         killer_xp  = (xptr_t)hal_remote_lwd( target_join_xp_xp );
     154        killer_xp  = (xptr_t)hal_remote_l64( target_join_xp_xp );
    149155
    150156        // reset the kill_done flag in target thread
     
    155161
    156162        // release the lock protecting join     
    157         remote_spinlock_unlock( target_join_lock_xp );
     163        remote_busylock_release( target_join_lock_xp );
    158164
    159165        // restore IRQs
     
    162168    else                                                          // joining thread is first
    163169    {
     170
     171#if (DEBUG_SYS_THREAD_JOIN & 1)
     172if( DEBUG_SYS_THREAD_JOIN < tm_start )
     173printk("\n[DBG] %s : thread %x in process %x / joining thread arrived first\n",
     174__FUNCTION__ , joining_ptr->trdid, process->pid );
     175#endif
    164176        // set the join_done flag in target thread
    165177        hal_remote_atomic_or( target_flags_xp , THREAD_FLAG_JOIN_DONE );
     
    169181
    170182        // register the joining thread extended pointer in target thread
    171         hal_remote_swd( target_join_xp_xp , joining_xp );
     183        hal_remote_s64( target_join_xp_xp , joining_xp );
    172184
    173185        // release the lock protecting the join     
    174         remote_spinlock_unlock( target_join_lock_xp );
    175 
     186        remote_busylock_release( target_join_lock_xp );
     187
     188#if (DEBUG_SYS_THREAD_JOIN & 1)
     189if( DEBUG_SYS_THREAD_JOIN < tm_start )
     190printk("\n[DBG] %s : thread %x in process %x / joining thread deschedule\n",
     191__FUNCTION__ , joining_ptr->trdid, process->pid );
     192#endif
    176193        // deschedule
    177194        sched_yield( "joining thread waiting killer thread" );
    178195   
     196#if (DEBUG_SYS_THREAD_JOIN & 1)
     197if( DEBUG_SYS_THREAD_JOIN < tm_start )
     198printk("\n[DBG] %s : thread %x in process %x / joining thread resume\n",
     199__FUNCTION__ , joining_ptr->trdid, process->pid );
     200#endif
    179201        // restore IRQs
    180202        hal_restore_irq( save_sr );
     
    184206tm_end = hal_get_cycles();
    185207if( DEBUG_SYS_THREAD_JOIN < tm_end )
    186 printk("\n[DBG] %s : parent thread %x exit / process %x / target trdid %x / cycle %d\n",
    187 __FUNCTION__, joining_ptr, process->pid, trdid, (uint32_t)tm_end );
     208printk("\n[DBG] %s : thread %x in process %x exit / target thread %x / cycle %d\n",
     209__FUNCTION__, joining_ptr->trdid, process->pid, (uint32_t)tm_end );
    188210#endif
    189211
  • trunk/kernel/syscalls/sys_thread_sleep.c

    r506 r566  
    3939tm_start = hal_get_cycles();
    4040if( DEBUG_SYS_THREAD_SLEEP < tm_start )
    41 printk("\n[DBG] %s : thread %x blocked / process %x / cycle %d\n",
    42 __FUNCTION__ , this, this->process->pid , (uint32_t)tm_start );
     41printk("\n[DBG] %s : thread %x n process %x blocked / cycle %d\n",
     42__FUNCTION__ , this->trdid, this->process->pid , (uint32_t)tm_start );
    4343#endif
    4444
     
    4949tm_end = hal_get_cycles();
    5050if( DEBUG_SYS_THREAD_SLEEP < tm_end )
    51 printk("\n[DBG] %s : thread %x resume / process %x / cycle %d\n",
    52 __FUNCTION__ , this, this->process->pid , (uint32_t)tm_end );
     51printk("\n[DBG] %s : thread %x in process %x resume / cycle %d\n",
     52__FUNCTION__ , this->trdid, this->process->pid , (uint32_t)tm_end );
    5353#endif
    5454
  • trunk/kernel/syscalls/sys_thread_wakeup.c

    r506 r566  
    4141tm_start = hal_get_cycles();
    4242if( DEBUG_SYS_THREAD_WAKEUP < tm_start )
    43 printk("\n[DBG] %s : thread %x enter / activate thread %x in process %x / cycle %d\n",
    44 __FUNCTION__ , this, trdid, this->process->pid, (uint32_t)tm_start );
     43printk("\n[DBG] %s : thread %x in process enter to activate thread %x / cycle %d\n",
     44__FUNCTION__, this->trdid, process->pid, trdid, (uint32_t)tm_start );
    4545#endif
    4646
     
    5050
    5151    // check trdid argument
    52         if( (target_ltid >= CONFIG_THREAD_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
     52        if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 
    5353        {
    5454
    5555#if DEBUG_SYSCALLS_ERROR
    56 printk("\n[ERROR] in %s : illegal trdid argument %x\n", __FUNCTION__, trdid );
     56printk("\n[ERROR] in %s : thread %x in process %x / illegal trdid argument %x\n",
     57__FUNCTION__, this->trdid, process->pid, trdid );
    5758#endif
    5859                this->errno = EINVAL;
     
    6768
    6869#if DEBUG_SYSCALLS_ERROR
    69 printk("\n[ERROR] in %s : cannot find thread %x in process %x/n",
    70 __FUNCTION__ , trdid , this->process->pid );
     70printk("\n[ERROR] in %s : thread %x in process %x cannot find thread %x/n",
     71__FUNCTION__ , this->trdid, process->pid, trdid );
    7172#endif
    7273        CURRENT_THREAD->errno = EINVAL;
     
    8081tm_end = hal_get_cycles();
    8182if( DEBUG_SYS_THREAD_WAKEUP < tm_end )
    82 printk("\n[DBG] %s : thread %x exit / thread %x in process %x activated / cycle %d\n",
    83 __FUNCTION__ , this, trdid, this->process->pid, (uint32_t)tm_end );
     83printk("\n[DBG] %s : thread %x in process %x exit / thread %x activated / cycle %d\n",
     84__FUNCTION__ , this->trdid, process->pid, trdid, (uint32_t)tm_end );
    8485#endif
    8586
  • trunk/kernel/syscalls/sys_thread_yield.c

    r506 r566  
    3737tm_start = hal_get_cycles();
    3838if( DEBUG_SYS_THREAD_YIELD < tm_start )
    39 printk("\n[DBG] %s : thread %x deschedule / process %x / cycle %d\n",
     39printk("\n[DBG] %s : thread %x in process %x deschedule / cycle %d\n",
    4040__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, (uint32_t)tm_start );
    4141#endif
     
    4747tm_end = hal_get_cycles();
    4848if( DEBUG_SYS_THREAD_YIELD < tm_start )
    49 printk("\n[DBG] %s : thread %x resume / process %x / cycle %d\n",
     49printk("\n[DBG] %s : thread %x in process %x resume / cycle %d\n",
    5050__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, (uint32_t)tm_end );
    5151#endif
  • trunk/kernel/syscalls/sys_trace.c

    r457 r566  
    6262
    6363    // check core local index
    64     ncores = hal_remote_lw( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) );
     64    ncores = hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) );
    6565    if( lid >= ncores )
    6666    {
     
    8080    xptr_t trace_xp = XPTR( cxy , &core->scheduler.trace );
    8181
    82     if ( active ) hal_remote_sw( trace_xp , 1 );
    83     else          hal_remote_sw( trace_xp , 0 );
     82    if ( active ) hal_remote_s32( trace_xp , 1 );
     83    else          hal_remote_s32( trace_xp , 0 );
    8484   
    8585    hal_fence();
  • trunk/kernel/syscalls/sys_unlink.c

    r506 r566  
    3131
    3232//////////////////////////////////
    33 int sys_unlink ( const char * pathname )
     33int sys_unlink ( char * pathname )
    3434{
    3535    error_t   error;
     
    5555    cxy_t       ref_cxy = GET_CXY( ref_xp );
    5656
    57     // get the cwd lock in read mode from reference process
    58     remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     57    // get the cwd lock in write mode from reference process
     58    remote_rwlock_wr_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    5959
    6060    // get extended pointer on cwd inode
    61     xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
     61    xptr_t cwd_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    6262
    6363    // call relevant VFS function
     
    6565
    6666    // release the cwd lock in reference process
    67     remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     67    remote_rwlock_wr_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    6868
    6969    if( error )
  • trunk/kernel/syscalls/sys_wait.c

    r506 r566  
    2525#include <hal_uspace.h>
    2626#include <hal_irqmask.h>
     27#include <remote_queuelock.h>
    2728#include <core.h>
    2829#include <thread.h>
     
    9596    xptr_t children_lock_xp = XPTR( owner_cxy , &process->children_lock );
    9697
    97     // exit this blocking loop only when a child processes change state
     98    // exit this loop only when a child processes change state
    9899    while( 1 )
    99100    {
     
    102103 
    103104        // get lock protecting children list
    104         remote_spinlock_lock( children_lock_xp );
     105        remote_queuelock_acquire( children_lock_xp );
    105106
    106107        // scan the list of child process
     
    113114
    114115            // get PID, term_state, and main thread from child process
    115             child_pid    = hal_remote_lw (XPTR( child_cxy , &child_ptr->pid ));
    116             child_state  = hal_remote_lw ( XPTR(child_cxy , &child_ptr->term_state ) );
     116            child_pid    = hal_remote_l32 (XPTR( child_cxy , &child_ptr->pid ));
     117            child_state  = hal_remote_l32 ( XPTR(child_cxy , &child_ptr->term_state ) );
    117118            child_thread = hal_remote_lpt(XPTR( child_cxy , &child_ptr->th_tbl[0] ));
    118119
    119 #if (DEBUG_SYS_WAIT &1)
     120#if (DEBUG_SYS_WAIT & 1)
    120121cycle = hal_get_cycles();
    121122if( DEBUG_SYS_WAIT < cycle )
     
    130131                 ((child_state & PROCESS_TERM_WAIT) == 0) )
    131132            {
    132                 // set the PROCESS_FLAG_WAIT in child process descriptor
     133                // set the PROCESS_TERM_WAIT in child process descriptor
    133134                hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ),
    134135                                      PROCESS_TERM_WAIT );
     
    140141
    141142                // release lock protecting children list
    142                 remote_spinlock_unlock( children_lock_xp );
     143                remote_queuelock_release( children_lock_xp );
    143144
    144145#if DEBUG_SYS_WAIT
     
    163164        }  // end loop on children
    164165       
     166        // we execute this code when no child terminated:
     167        // - release the lock protecting children list,
     168        // - block on the WAIT condition
     169        // - deschedule to keep waiting in the while loop
     170
     171        // release lock protecting children list
     172        remote_queuelock_release( children_lock_xp );
     173
    165174        // block on WAIT condition
    166175        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_WAIT );
    167 
    168         // release lock protecting children list
    169         remote_spinlock_unlock( children_lock_xp );
    170176
    171177#if (DEBUG_SYS_WAIT & 1)
  • trunk/kernel/syscalls/sys_write.c

    r492 r566  
    11/*
    2  * sys_write.c - write bytes to a file
     2 * sys_write.c - Kernel function implementing the "write" system call.
    33 *
    44 * Author        Alain Greiner (2016,2017,2018)
     
    2929#include <errno.h>
    3030#include <vfs.h>
     31#include <vmm.h>
    3132#include <thread.h>
    3233#include <printk.h>
    3334#include <process.h>
    3435
    35 /* TODO: concurrent user page(s) unmap need to be handled [AG] */
    3636
    3737extern uint32_t enter_sys_write;
     
    6464        process_t  * process = this->process;
    6565
     66#if (DEBUG_SYS_WRITE || CONFIG_INSTRUMENTATION_SYSCALLS)
     67uint64_t     tm_start = hal_get_cycles();
     68#endif
     69
    6670#if DEBUG_SYS_WRITE
    67 uint32_t     tm_start;
    68 uint32_t     tm_end;
    6971tm_start = hal_get_cycles();
    7072if( DEBUG_SYS_WRITE < tm_start )
     
    123125 
    124126    // get file type
    125     vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
     127    vfs_inode_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );
    126128
    127129    // enable IRQs
     
    132134    {
    133135        // check file writable
    134         uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) );
     136        uint32_t attr = hal_remote_l32( XPTR( file_cxy , &file_ptr->attr ) );
    135137        if( (attr & FD_ATTR_WRITE_ENABLE) == 0 )
    136138            {
     
    192194    hal_fence();
    193195
     196#if (DEBUG_SYS_WRITE || CONFIG_INSTRUMENTATION_SYSCALLS)
     197uint64_t     tm_end = hal_get_cycles();
     198#endif
     199
    194200#if DEBUG_SYS_WRITE
    195 tm_end = hal_get_cycles();
    196201if( DEBUG_SYS_WRITE < tm_end )
    197 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d / cost %d\n",
    198 __FUNCTION__, this->trdid, process->pid, (uint32_t)tm_start, (uint32_t)(tm_end - tm_start) );
    199 #endif
    200  
     202printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n",
     203__FUNCTION__, this->trdid, process->pid, (uint32_t)tm_end );
     204#endif
     205 
     206#if CONFIG_INSTRUMENTATION_SYSCALLS
     207hal_atomic_add( &syscalls_cumul_cost[SYS_WRITE] , tm_end - tm_start );
     208hal_atomic_add( &syscalls_occurences[SYS_WRITE] , 1 );
     209#endif
     210
    201211#if (DEBUG_SYS_WRITE & 1)
    202212exit_sys_write = (uint32_t)tm_end;
  • trunk/kernel/syscalls/syscalls.h

    r527 r566  
    3636struct mmap_attr_s;               // defined in vmm.h
    3737
    38 // debug:
    39 const char * syscall_str( syscalls_t index );
    40 
    4138/******************************************************************************************
    4239 * [0] This function terminates the execution of the calling user thread,
     
    6764 * on astructure containing the thread attributes, defined in thread.h file.
    6865 ******************************************************************************************
    69  * @ new_thread  : [out] local pointer on created thread descriptor.
     66 * @ trdid_ptr   : [out] pointer on buffer for created thread trdid.
    7067 * @ user_attr   : [in]  pointer on thread attributes structure.
    7168 * @ start_func  : [in]  pointer on start function.
     
    7370 * @ return 0 if success / return -1 if failure.
    7471 *****************************************************************************************/
    75 int sys_thread_create(
    76   struct thread_s             * new_thread,
    77   const struct pthread_attr_s * user_attr,
    78   const void                  * start_func,
    79   const void                  * start_args );
     72int sys_thread_create( trdid_t               * trdid_ptr,
     73                       struct pthread_attr_s * user_attr,
     74                       void                  * start_func,
     75                       void                  * start_args );
    8076
    8177/******************************************************************************************
     
    133129/******************************************************************************************
    134130 * [7] This function implement all operations on a POSIX condition variable.
    135  * The kernel structure representing a cond_var is defined in the remote_cv.h file,
    136  * The code implementing the operations is defined in the remote_cv.c file.
     131 * The kernel structure representing a condvar is defined in the remote_condvar.h file,
     132 * The code implementing the operations is defined in the remote_condvar.c file.
    137133 ******************************************************************************************
    138134 * @ vaddr     : condvar virtual address in user space == identifier.
     
    205201 * @ return file descriptor index in fd_array if success / return -1 if failure.
    206202 *****************************************************************************************/
    207 int sys_open( const char * pathname,
     203int sys_open( char      * pathname,
    208204              uint32_t     flags,
    209205              uint32_t     mode );
     
    280276 * @ return 0 if success / returns -1 if failure.
    281277 *****************************************************************************************/
    282 int sys_unlink( const char * pathname );
     278int sys_unlink( char * pathname );
    283279
    284280/******************************************************************************************
     
    299295 * @ return 0 if success / returns -1 if failure.
    300296 *****************************************************************************************/
    301 int sys_chdir( const char * pathname );
     297int sys_chdir( char * pathname );
    302298
    303299/******************************************************************************************
     
    387383 * @ return 0 if success / returns -1 if failure.
    388384 *****************************************************************************************/
    389 int sys_rmdir( const char * pathname );
     385int sys_rmdir( char * pathname );
    390386
    391387/******************************************************************************************
     
    408404 * @ return 0 if success / returns -1 if failure.
    409405 *****************************************************************************************/
    410 int sys_chmod( const char * pathname,
     406int sys_chmod( char      * pathname,
    411407               uint32_t     rights );
    412408
     
    494490 * @ does not return if success / returns -1 if failure.
    495491 *****************************************************************************************/
    496 int sys_exec( const char  * filename,
    497               char        ** argv,
    498               char        ** envp );
     492int sys_exec( char  * filename,
     493              char ** argv,
     494              char ** envp );
    499495
    500496/******************************************************************************************
     
    506502 * @ returns O if success / returns -1 if failure.
    507503 *****************************************************************************************/
    508 int sys_stat( const char  * pathname,
     504int sys_stat( char        * pathname,
    509505              struct stat * stat );
    510506
     
    538534 * @ x_size   : [out] number of clusters in a row.
    539535 * @ y_size   : [out] number of clusters in a column.
    540  * @ y_width  : [out] number of bits in Y field for CXY.
    541536 * @ ncores   : [out] number of cores per cluster.
    542537 * @ return 0 if success / return -1 if illegal arguments
     
    544539int sys_get_config( uint32_t * x_size,
    545540                    uint32_t * y_size,
    546                     uint32_t * y_width,
    547541                    uint32_t * ncores );
    548542
Note: See TracChangeset for help on using the changeset viewer.