Changeset 416 for trunk/kernel/syscalls


Ignore:
Timestamp:
Jan 4, 2018, 10:05:47 AM (4 years ago)
Author:
alain
Message:

Improve sys_exec.

Location:
trunk/kernel/syscalls
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/shared_syscalls.h

    r410 r416  
    8686        SYSCALLS_NR        = 47,
    8787};
     88
     89/*******************************************************************************************
     90 * This defines the signal type mnemonics for the kill() syscall.
     91 * WARNING : Only the three SIGKILL / SIGSTOP / SIGCONT are supported (december 2017)
     92 ******************************************************************************************/
     93
     94#define SIGHUP     1       /*! hangup                                                     */
     95#define SIGINT     2       /*! interrupt                                                  */
     96#define SIGQUIT    3       /*! quit                                                       */
     97#define SIGILL     4       /*! illegal instruction (not reset when caught)                */
     98#define SIGTRAP    5       /*! trace trap (not reset when caught)                         */
     99#define SIGABRT    6       /*! used by abort, replace SIGIOT in the future                */
     100#define SIGEMT     7       /*! EMT instruction                                            */
     101#define SIGFPE     8       /*! floating point exception                                   */
     102#define SIGKILL    9       /*! kill (cannot be caught or ignored)                         */
     103#define SIGBUS     10      /*! bus error                                                  */
     104#define SIGSEGV    11      /*! segmentation violation                                     */
     105#define SIGSYS     12      /*! bad argument to system call                                */
     106#define SIGPIPE    13      /*! write on a pipe with no one to read it                     */
     107#define SIGALRM    14      /*! alarm clock                                                */
     108#define SIGTERM    15      /*! software termination signal from kill                      */
     109#define SIGURG     16      /*! urgent condition on IO channel                             */
     110#define SIGSTOP    17      /*! sendable stop signal not from tty                          */
     111#define SIGTSTP    18      /*! stop signal from tty                                       */
     112#define SIGCONT    19      /*! continue a stopped process                                 */
     113#define SIGCHLD    20      /*! to parent on child stop or exit                            */
     114#define SIGTTIN    21      /*! to readers pgrp upon background tty read                   */
     115#define SIGTTOU    22      /*! like TTIN for output if (tp->t_local&LTOSTOP)              */
     116#define SIGIO      23      /*! input/output possible signal                               */
     117#define SIGXCPU    24      /*! exceeded CPU time limit                                    */
     118#define SIGXFSZ    25      /*! exceeded file size limit                                   */
     119#define SIGVTALRM  26      /*! virtual time alarm                                         */
     120#define SIGPROF    27      /*! profiling time alarm                                       */
     121#define SIGWINCH   28      /*! window changed                                             */
     122#define SIGLOST    29      /*! resource lost (eg, record-lock lost)                       */
     123#define SIGUSR1    30      /*! user defined signal 1                                      */
     124#define SIGUSR2    31      /*! user defined signal 2                                      */
    88125
    89126/*******************************************************************************************
  • trunk/kernel/syscalls/sys_exec.c

    r408 r416  
    160160// and this sys_exec() function uses a RPC to access the owner cluster if required.
    161161//
    162 // TODO : the args & envs arguments are not supported yet : both must be NULL
     162// TODO : the args & envs arguments are not supported yet : both must be NULL  [AG]
    163163/////////////////////////////////////////////////////////////////////////////////////////
    164164int sys_exec( char  * pathname,     // .elf file pathname
     
    169169    error_t       error;
    170170
    171         uint64_t      tm_start;
    172         uint64_t      tm_end;
    173 
    174         tm_start = hal_get_cycles();
    175 
    176171    // get parent process pid
    177172    thread_t   * this    = CURRENT_THREAD;
     
    179174    pid_t        pid     = process->pid;
    180175
    181 exec_dmsg("\n[DBG] %s : core[%x,%d] enters for process %x / cycle %d\n",
    182 __FUNCTION__, local_cxy, this->core->lid, pid, (uint32_t)hal_get_cycles() );
     176#if CONFIG_SYSCALL_DEBUG
     177uint64_t      tm_start;
     178uint64_t      tm_end;
     179tm_start = hal_get_cycles();
     180printk("\n[DBG] %s : core[%x,%d] enter / process %x / path = %s / cycle = %d\n",
     181__FUNCTION__, local_cxy, this->core->lid, pid, exec_info.path, (uint32_t)tm_start );
     182#endif
    183183
    184184    // get owner cluster
     
    249249    }
    250250
    251     tm_end = hal_get_cycles();
    252 
    253 exec_dmsg("\n[DBG] %s : core[%x,%d] exit for process %x / cycle %d\n"
    254 "     pathname = %s / cost = %d\n",
    255 __FUNCTION__, local_cxy, this->core->lid, pid, (uint32_t)tm_start,
    256 exec_info.path , (uint32_t)(tm_end - tm_start) );
     251#if CONFIG_SYSCALL_DEBUG
     252tm_end = hal_get_cycles();
     253printk("\n[DBG] %s : core[%x,%d] exit / process %x / path = %s / cost = %d\n",
     254__FUNCTION__, local_cxy, this->core->lid, pid, exec_info.path, (uint32_t)(tm_end - tm_start) );
     255#endif
    257256
    258257    return 0;
  • trunk/kernel/syscalls/sys_exit.c

    r410 r416  
    11/*
    2  * sys_exit.c: Terminate the calling process.
     2 * sys_exit.c - Kernel function implementing the "exit" system call.
    33 *
    44 * Author    Alain Greiner (2016,2017)
     
    3838    uint32_t    save_sr;       // required to enable IRQs
    3939
     40    thread_t  * this = CURRENT_THREAD;
     41    pid_t       pid  = this->process->pid;
     42
    4043#if CONFIG_SYSCALL_DEBUG
    4144uint64_t    tm_start;
    4245uint64_t    tm_end;
    4346tm_start = hal_get_cycles();
     47printk("\n[DBG] %s : core[%x,%d] enter / process %x / status %x / cycle %d\n",
     48__FUNCTION__ , local_cxy , this->core->lid , pid , status , (uint32_t)tm_start );
    4449#endif
    4550
    46     thread_t  * this    = CURRENT_THREAD;
    47     process_t * process = this->process;
    48 
    4951    // get owner process cluster
    50     cxy_t   owner_cxy  = CXY_FROM_PID( process->pid );
     52    cxy_t   owner_cxy  = CXY_FROM_PID( pid );
    5153
    5254    // enable IRQs
     
    5658    if( local_cxy == owner_cxy )                                // owner is local
    5759    {
    58         process_make_exit( process , status );
     60        process_make_exit( pid , status );
    5961    }
    6062    else                                                        // owner is remote
    6163    {
    62         rpc_process_make_exit_client( owner_cxy, process , status );
     64        rpc_process_make_exit_client( owner_cxy, pid , status );
    6365    }
    6466
     
    7072#if CONFIG_SYSCALL_DEBUG
    7173tm_end = hal_get_cycles();
    72 syscall_dmsg("\n[DBG] %s exit : core[%x,%d] / thread %x in process %x / cycle %d\n"
    73 "process %x killed / cost = %d\n",
    74 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
    75 tm_start , pid , (uint32_t)(tm_end - tm_start) );
     74printk("\n[DBG] %s : core[%x,%d] exit / process %x / status %x / cost = %d\n",
     75__FUNCTION__ , local_cxy , this->core->lid , pid , status , (uint32_t)(tm_end - tm_start) );
    7676#endif
    7777
  • trunk/kernel/syscalls/sys_fork.c

    r409 r416  
    5656        error_t           error;
    5757   
    58         uint64_t          tm_start;
    59         uint64_t          tm_end;
    60 
    61         tm_start = hal_get_cycles();
    6258
    6359    // get pointers on local parent process and thread
     
    6763    parent_pid         = parent_process_ptr->pid;
    6864
    69 fork_dmsg("\n[DBG] %s : core[%x,%d] parent process %x enters / cycle %d\n",
    70 __FUNCTION__, local_cxy, parent_thread_ptr->core->lid, parent_pid, (uint32_t)tm_start );
     65#if CONFIG_SYSCALL_DEBUG
     66uint64_t          tm_start;
     67uint64_t          tm_end;
     68tm_start = hal_get_cycles();
     69printk("\n[DBG] %s : core[%x,%d] enter / process %x / cycle =  %d\n",
     70__FUNCTION__, local_cxy, parent_thread_ptr->core->lid, parent_pid,
     71(uint32_t)tm_start );
     72#endif
    7173
    7274    // get infos on reference process
     
    146148        thread_unblock( XPTR( target_cxy , child_thread_ptr ) , THREAD_BLOCKED_GLOBAL );
    147149
    148         tm_end = hal_get_cycles();
    149 
    150 fork_dmsg("\n[DBG] %s : core[%x,%d] parent_process %x exit / cycle %d\n"
    151 "     child_process %x / child_thread = %x / cost = %d\n",
    152 __FUNCTION__, local_cxy, parent_thread_ptr->core->lid,  parent_pid, (uint32_t)tm_end,
    153 child_pid, child_thread_ptr->trdid , (uint32_t)(tm_end - tm_start) );
     150#if CONFIG_SYSCALL_DEBUG
     151tm_end = hal_get_cycles();
     152printk("\n[DBG] %s : core[%x,%d] parent_process %x exit / cost = %d\n",
     153__FUNCTION__, local_cxy, parent_thread_ptr->core->lid,  parent_pid,
     154(uint32_t)(tm_end - tm_start) );
     155#endif
    154156
    155157        return child_pid;
     
    158160    {
    159161
    160         tm_end = hal_get_cycles();
    161 
    162 fork_dmsg("\n[DBG] %s : core[%x,%d] child process %x exit / cycle %d\n",
    163 __FUNCTION__, local_cxy, parent_thread_ptr->core->lid, child_pid, (uint32_t)tm_end );
     162#if CONFIG_SYSCALL_DEBUG
     163tm_end = hal_get_cycles();
     164printk("\n[DBG] %s : core[%x,%d] child process %x exit / cost =  %d\n",
     165__FUNCTION__, local_cxy, parent_thread_ptr->core->lid, child_pid,
     166(uint32_t)(tm_end - tm_start) );
     167#endif
    164168
    165169        return 0;
  • trunk/kernel/syscalls/sys_kill.c

    r409 r416  
    11/*
    2  * sys_kill.c - Send a signal to a given process.
     2 * sys_kill.c - Kernel function implementing the "kill" system call.
    33 *
    44 * Author    Alain Greiner (2016,2017)
     
    2929#include <printk.h>
    3030#include <process.h>
    31 #include <signal.h>
     31#include <shared_syscalls.h>
    3232#include <cluster.h>
    3333#include <rpc.h>
     
    3939    uint32_t    save_sr;       // required to enable IRQs
    4040
     41    thread_t  * this    = CURRENT_THREAD;
     42
    4143#if CONFIG_SYSCALL_DEBUG
    4244uint64_t    tm_start;
    4345uint64_t    tm_end;
    4446tm_start = hal_get_cycles();
     47printk("\n[DBG] %s : core[%x,%d] enter / process %x / sig %d / cycle %d\n",
     48__FUNCTION__ , local_cxy , this->core->lid , pid, sig_id, (uint32_t)tm_start );
    4549#endif
    46 
    47     thread_t  * this    = CURRENT_THREAD;
    48     process_t * process = this->process;
    4950
    5051    // get owner process cluster and lpid
     
    7677    if( local_cxy == owner_cxy )                                // owner is local
    7778    {
    78         process_make_kill( process , sig_id );
     79        process_make_kill( pid , sig_id );
    7980    }
    8081    else                                                        // owner is remote
    8182    {
    82         rpc_process_make_kill_client( owner_cxy , process , sig_id );
     83        rpc_process_make_kill_client( owner_cxy , pid , sig_id );
    8384    }
    8485
     
    9091#if CONFIG_SYSCALL_DEBUG
    9192tm_end = hal_get_cycles();
    92 syscall_dmsg("\n[DBG] %s exit : core[%x,%d] / thread %x in process %x / cycle %d\n"
    93 "process %x killed / cost = %d\n",
    94 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
    95 tm_start , pid , (uint32_t)(tm_end - tm_start) );
     93printk("\n[DBG] %s : core[%x,%d] exit / process %x / sig %d / cost = %d\n",
     94__FUNCTION__ , local_cxy , this->core->lid , pid, sig_id, (uint32_t)(tm_end - tm_start) );
    9695#endif
    9796 
  • trunk/kernel/syscalls/sys_read.c

    r409 r416  
    164164#if CONFIG_SYSCALL_DEBUG
    165165tm_end = hal_get_cycles();
    166 syscall_dmsg("\n[DBG] %s exit : core[%x,%d] / thread %x in process %x / cycle %d\n"
     166printk("\n[DBG] %s : core[%x,%d] / thread %x in process %x / cycle %d\n"
    167167"nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
    168168__FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
    169 tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id , tm_end - tm_start );
     169(uint32_t)tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id ,
     170(uint32_t)(tm_end - tm_start) );
    170171#endif
    171172
  • trunk/kernel/syscalls/sys_write.c

    r409 r416  
    141141#if CONFIG_SYSCALL_DEBUG
    142142tm_end = hal_get_cycles();
    143 syscall_dmsg("\n[DBG] %s : core[%x,%d] / thread %x in process %x / cycle %d\n"
     143printk("\n[DBG] %s : core[%x,%d] / thread %x in process %x / cycle %d\n"
    144144"nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
    145145__FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
    146 tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id , tm_end - tm_start );
     146(uint32_t)tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id ,
     147(uint32_t)(tm_end - tm_start) );
    147148#endif
    148149 
Note: See TracChangeset for help on using the changeset viewer.