Changeset 435


Ignore:
Timestamp:
Feb 20, 2018, 5:32:17 PM (7 years ago)
Author:
alain
Message:

Fix a bad bug in scheduler...

Location:
trunk
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.tsar

    r434 r435  
    8787              build/kernel/kern/do_syscall.o      \
    8888              build/kernel/kern/do_interrupt.o    \
    89               build/kernel/kern/rpc.o             \
    90               build/kernel/kern/signal.o
     89              build/kernel/kern/rpc.o
    9190
    9291HAL_OBJS    = build/kernel/hal/hal_special.o      \
  • trunk/hal/tsar_mips32/core/hal_exception.c

    r432 r435  
    3333#include <scheduler.h>
    3434#include <core.h>
    35 #include <signal.h>
    3635#include <syscalls.h>
    3736#include <remote_spinlock.h>
  • trunk/hal/tsar_mips32/core/hal_interrupt.c

    r432 r435  
    3232void hal_do_interrupt()
    3333{
    34 
    35 irq_dmsg("\n[DBG] %s : core[%x,%d] enter at cycle %d\n",
    36 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    37 
    38     // As ALMOS-MKH does not define a generic interrupt handler,
    39     // we directly access the local TSAR ICU to call the relevant ISR
     34    // ALMOS-MKH does not define a generic interrupt handler.
     35    // we call the specific TSAR IRQ handler to select the relevant ISR
    4036    soclib_pic_irq_handler();
    41 
    42 irq_dmsg("\n[DBG] %s : core[%x,%d] exit at cycle %d\n",
    43 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    44 
    4537}
  • trunk/hal/tsar_mips32/drivers/soclib_pic.c

    r432 r435  
    130130                           &pti_status );
    131131
    132     irq_dmsg("\n[DBG] %s : core[%x,%d] enter / WTI = %x / HWI = %x / PTI = %x\n",
    133              __FUNCTION__ , local_cxy , core->lid , wti_status , hwi_status , pti_status );
     132#if CONFIG_DEBUG_HAL_IRQS
     133uint32_t cycle = (uint32_t)hal_get_cycles();
     134if (CONFIG_DEBUG_HAL_IRQS < cycle )
     135printk("\n[DBG] %s : core[%x,%d] enter / WTI = %x / HWI = %x / PTI = %x / cycle %d\n",
     136__FUNCTION__ , local_cxy , core->lid , wti_status , hwi_status , pti_status, cycle );
     137#endif
    134138
    135139    // analyse status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI)
     
    143147            assert( (index == core->lid) , __FUNCTION__ , "illegal IPI index" );
    144148
    145             irq_dmsg("\n[DBG] %s : core[%x,%d] received an IPI / cycle %d\n",
    146              __FUNCTION__ , local_cxy , core->lid , hal_time_stamp() );
    147 
     149#if CONFIG_DEBUG_HAL_IRQS
     150if (CONFIG_DEBUG_HAL_IRQS < cycle )
     151printk("\n[DBG] %s : core[%x,%d] received an IPI\n", __FUNCTION__ , local_cxy , core->lid );
     152#endif
    148153            // acknowledge WTI (this require an XCU read)
    149154            uint32_t   ack  = xcu_base[(XCU_WTI_REG << 5) | core->lid];
     
    171176            else                                 // call relevant ISR
    172177            {
    173                 irq_dmsg("\n[DBG] %s : core[%x,%d] received external WTI %d / cycle %d\n",
    174                 __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() );
    175 
     178
     179#if CONFIG_DEBUG_HAL_IRQS
     180if (CONFIG_DEBUG_HAL_IRQS < cycle )
     181printk("\n[DBG] %s : core[%x,%d] received external WTI %d\n",
     182__FUNCTION__ , local_cxy , core->lid , index );
     183#endif
    176184                // call ISR
    177185                    src_chdev->isr( src_chdev );
     
    199207        else                    // call relevant ISR
    200208        {
    201             irq_dmsg("\n[DBG] %s : core[%x,%d] received HWI %d / cycle %d\n",
    202             __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() );
    203 
     209
     210#if CONFIG_DEBUG_HAL_IRQS
     211if (CONFIG_DEBUG_HAL_IRQS < cycle )
     212printk("\n[DBG] %s : core[%x,%d] received HWI %d\n",
     213__FUNCTION__ , local_cxy , core->lid , index );
     214#endif
    204215            // call ISR
    205216                    src_chdev->isr( src_chdev );
     
    211222        index = pti_status - 1;
    212223
    213         irq_dmsg("\n[DBG] %s : core[%x,%d] received PTI %d / cycle %d\n",
    214         __FUNCTION__ , core->lid , local_cxy , index , hal_time_stamp() );
    215 
    216224        assert( (index == core->lid) , __FUNCTION__ , "unconsistent PTI index\n");
    217225
     226#if CONFIG_DEBUG_HAL_IRQS
     227if (CONFIG_DEBUG_HAL_IRQS < cycle )
     228printk("\n[DBG] %s : core[%x,%d] received PTI %d\n",
     229__FUNCTION__ , core->lid , local_cxy , index );
     230#endif
    218231        // acknowledge PTI (this require a read access to XCU)
    219232        uint32_t   ack  = xcu_base[(XCU_PTI_ACK << 5) | core->lid];
     
    345358                          chdev_t * src_chdev )
    346359{
     360
     361#if CONFIG_DEBUG_HAL_IRQS
     362uint32_t cycle = (uint32_t)hal_get_cycles();
     363if( CONFIG_DEBUG_HAL_IRQS < cycle )
     364printk("\n[DBG] %s : thread %x enter for core[%x,%d] / cycle %d\n",
     365__FUNCTION__ , CURRENT_THREAD , local_cxy , lid , cycle );
     366#endif
     367
    347368    // get extended & local pointers on PIC chdev descriptor
    348369    xptr_t     pic_xp  = chdev_dir.pic;
     
    401422        ((soclib_pic_core_t *)core->pic_extend)->wti_vector[wti_id] = src_chdev;
    402423
    403 pic_dmsg("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n",
     424#if CONFIG_DEBUG_HAL_IRQS
     425if( CONFIG_DEBUG_HAL_IRQS < cycle )
     426printk("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n",
    404427__FUNCTION__ , chdev_func_str( func ) , channel , is_rx , hwi_id , wti_id , local_cxy );
     428#endif
    405429
    406430    }
     
    420444        ((soclib_pic_core_t *)core->pic_extend)->wti_vector[hwi_id] = src_chdev;
    421445
    422 pic_dmsg("\n[DBG] %s : %s / channel = %d / hwi_id = %d / cluster = %x\n",
     446#if CONFIG_DEBUG_HAL_IRQS
     447if( CONFIG_DEBUG_HAL_IRQS < cycle )
     448printk("\n[DBG] %s : %s / channel = %d / hwi_id = %d / cluster = %x\n",
    423449__FUNCTION__ , chdev_func_str( func ) , channel , hwi_id , local_cxy );
     450#endif
    424451
    425452    }
  • trunk/hal/tsar_mips32/drivers/soclib_tty.c

    r432 r435  
    3030#include <hal_special.h>
    3131
    32 #if CONFIG_READ_DEBUG
    33 extern uint32_t  enter_tty_cmd;
    34 extern uint32_t  exit_tty_cmd;
    35 
    36 extern uint32_t  enter_tty_isr;
    37 extern uint32_t  exit_tty_isr;
     32#if (CONFIG_DEBUG_SYS_READ & 1)
     33extern uint32_t  enter_tty_cmd_read;
     34extern uint32_t  exit_tty_cmd_read;
     35
     36extern uint32_t  enter_tty_isr_read;
     37extern uint32_t  exit_tty_isr_read;
     38#endif
     39
     40#if (CONFIG_DEBUG_SYS_WRITE & 1)
     41extern uint32_t  enter_tty_cmd_write;
     42extern uint32_t  exit_tty_cmd_write;
     43
     44extern uint32_t  enter_tty_isr_write;
     45extern uint32_t  exit_tty_isr_write;
    3846#endif
    3947
     
    5361    // get SOCLIB_TTY device cluster and local pointer
    5462    cxy_t      tty_cxy = GET_CXY( tty_xp );
    55     uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
    56 
    57     // reset TTY_RX_IRQ_ENABLE
     63    uint32_t * tty_ptr = GET_PTR( tty_xp );
     64
     65    // set TTY_RX_IRQ_ENABLE
    5866    reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE );
    59     hal_remote_sw( reg_xp , 0 );
     67    hal_remote_sw( reg_xp , 1 );
    6068
    6169    // reset TTY_TX_IRQ_ENABLE
     
    6876{
    6977
    70 #if CONFIG_READ_DEBUG
    71 enter_tty_cmd = hal_time_stamp();
    72 #endif
     78#if (CONFIG_DEBUG_SYS_READ & 1)
     79if( type == TXT_READ) enter_tty_cmd_read = (uint32_t)hal_get_cycles();
     80#endif
     81
     82#if (CONFIG_DEBUG_SYS_WRITE & 1)
     83if( type == TXT_WRITE) enter_tty_cmd_write = (uint32_t)hal_get_cycles();
     84#endif
     85
     86    // get client thread cluster and local pointer
     87    cxy_t      th_cxy = GET_CXY( th_xp );
     88    thread_t * th_ptr = GET_PTR( th_xp );
     89
     90    // get command type and extended pointer on TXT device
     91    uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) );
    7392
    7493#if CONFIG_DEBUG_HAL_TXT
    7594uint32_t cycle = (uint32_t)hal_get_cycles();
    7695if (CONFIG_DEBUG_HAL_TXT < cycle )
    77 printk("\n[DBG] %s : thread %x enter / cycle %d\n",
    78 __FUNCTION__ , CURRENT_THREAD , cycle );
    79 #endif
    80 
    81     // get client thread cluster and local pointer
    82     cxy_t      th_cxy = GET_CXY( th_xp );
    83     thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
    84 
    85     // get command type and extended pointer on TXT device
    86     uint32_t type   =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) );
    87     xptr_t   dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
    88 
    89     assert( (type == TXT_READ) || (type == TXT_WRITE) , __FUNCTION__, "illegal command type");
    90 
    91     // get TXT device cluster and local pointer
    92     cxy_t     dev_cxy = GET_CXY( dev_xp );
    93     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    94 
    95     // get extended pointer on SOCLIB_TTY base segment
    96     xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    97 
    98     // get SOCLIB_TTY base segment cluster and local pointer
    99     cxy_t      tty_cxy = GET_CXY( tty_xp );
    100     uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
    101 
    102     // get TTY channel index and channel base address
    103     uint32_t   channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) );
    104     uint32_t * base    = tty_ptr + TTY_SPAN * channel;
    105 
    106     // compute extended pointer on relevant TTY register
    107     xptr_t reg_xp;
    108     if( type == TXT_READ )  reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
    109     else                    reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
    110 
    111     // enable relevant IRQ : data transfer will be done by the TTY_RX ISR)
    112     hal_remote_sw( reg_xp , 1 );
     96printk("\n[DBG] %s : thread %x enter for %s / cycle %d\n",
     97__FUNCTION__ , CURRENT_THREAD , dev_txt_type_str(type) , cycle );
     98#endif
     99
     100    if( type == TXT_WRITE )         // block, enable TX_IRQ, and dechedule for a WRITE
     101    {
     102        xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
     103
     104        // get TXT device cluster and local pointer
     105        cxy_t     dev_cxy = GET_CXY( dev_xp );
     106        chdev_t * dev_ptr = GET_PTR( dev_xp );
     107
     108        // get extended pointer on SOCLIB_TTY base segment
     109        xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
     110
     111        // get SOCLIB_TTY base segment cluster and local pointer
     112        cxy_t      tty_cxy = GET_CXY( tty_xp );
     113        uint32_t * tty_ptr = GET_PTR( tty_xp );
     114
     115        // get TTY channel index and channel base address
     116        uint32_t   channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) );
     117        uint32_t * base    = tty_ptr + TTY_SPAN * channel;
     118
     119        // block server thread
     120        thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
     121
     122        // enable relevant TX_IRQ for a WRITE
     123        hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
     124
     125        // deschedule
     126        sched_yield( "waiting TXT_TX_ISR completion" );
     127    }
     128    else if( type == TXT_READ )        // block, and deschedule for a READ
     129    {
     130        // block server thread
     131        thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
     132
     133        // deschedule
     134        sched_yield( "waiting TXT_RX_ISR completion" );
     135    }
     136    else
     137    {
     138        assert( false , __FUNCTION__ , "illegal TXT command\n" );
     139    }
    113140
    114141#if CONFIG_DEBUG_HAL_TXT
    115142cycle = (uint32_t)hal_get_cycles();
    116143if (CONFIG_DEBUG_HAL_TXT < cycle )
    117 printk("\n[DBG] %s : thread %x deschedule / cycle %d\n",
    118 __FUNCTION__ , CURRENT_THREAD , cycle );
    119 #endif
    120 
    121     // Block and deschedule server thread
    122     thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
    123     sched_yield("blocked on ISR");
    124 
    125 #if CONFIG_DEBUG_HAL_TXT
    126 cycle = (uint32_t)hal_get_cycles();
    127 if (CONFIG_DEBUG_HAL_TXT < cycle )
    128 printk("\n[DBG] %s : thread %x resume / cycle %d\n",
    129 __FUNCTION__ , CURRENT_THREAD , cycle );
    130 #endif
    131 
    132 #if CONFIG_READ_DEBUG
    133 exit_tty_cmd = hal_time_stamp();
     144printk("\n[DBG] %s : thread %x exit after %s / cycle %d\n",
     145__FUNCTION__ , CURRENT_THREAD , dev_txt_type_str( type ) , cycle );
     146#endif
     147
     148#if (CONFIG_DEBUG_SYS_READ & 1)
     149if( type == TXT_READ ) exit_tty_cmd_read = (uint32_t)hal_get_cycles();
     150#endif
     151
     152#if (CONFIG_DEBUG_SYS_WRITE & 1)
     153if( type == TXT_WRITE ) exit_tty_cmd_write = (uint32_t)hal_get_cycles();
    134154#endif
    135155
     
    143163    uint32_t   i;
    144164
    145     xptr_t     dev_xp = ((txt_aux_t *)args)->dev_xp;
    146     char     * buffer = ((txt_aux_t *)args)->buffer;
    147     uint32_t   count  = ((txt_aux_t *)args)->count;
     165    xptr_t     dev_xp = ((txt_sync_args_t *)args)->dev_xp;
     166    char     * buffer = ((txt_sync_args_t *)args)->buffer;
     167    uint32_t   count  = ((txt_sync_args_t *)args)->count;
    148168   
    149169    // get TXT0 chdev cluster and local pointer
     
    182202void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
    183203{
    184     uint32_t   type;         // command type
    185     uint32_t   count;        // number of bytes in buffer
    186     xptr_t     buf_xp;       // extended pointer on buffer
    187     xptr_t     status_xp;    // extended pointer on TTY_STATUS register
    188     xptr_t     write_xp;     // extended pointer on TTY_WRITE register
    189     xptr_t     read_xp;      // extended pointer on TTY_READ register
    190     uint32_t   status;       // TTY terminal status
    191     char       byte;         // read byte
    192     uint32_t   i;
    193 
    194 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    195 enter_tty_isr = hal_time_stamp();
     204    uint32_t    type;         // command type
     205    uint32_t    count;        // number of bytes in buffer
     206    xptr_t      buf_xp;       // extended pointer on buffer
     207    xptr_t      error_xp;     // extended pointer on error field in command
     208    xptr_t      status_xp;    // extended pointer on TTY_STATUS register
     209    xptr_t      write_xp;     // extended pointer on TTY_WRITE register
     210    xptr_t      read_xp;      // extended pointer on TTY_READ register
     211    uint32_t    status;       // TTY terminal status
     212    char        byte;         // read byte
     213    xptr_t      client_xp;    // first client thread in waiting queue
     214    cxy_t       client_cxy;   // firts client thread cluster
     215    thread_t  * client_ptr;   // first client thread pointer
     216    pid_t       pid;          // foreground process identifier
     217    xptr_t      owner_xp;     // extended pointer on foreground process in owner cluster
     218    cxy_t       owner_cxy;   
     219    process_t * owner_ptr;
     220    uint32_t    i;
     221
     222#if (CONFIG_DEBUG_SYS_READ & 1)
     223enter_tty_isr_read = (uint32_t)hal_get_cycles();
     224#endif
     225
     226#if (CONFIG_DEBUG_SYS_WRITE & 1)
     227enter_tty_isr_write = (uint32_t)hal_get_cycles();
    196228#endif
    197229
     
    202234#endif
    203235
    204     // get extended pointer on client thread
    205     xptr_t root      = XPTR( local_cxy , &chdev->wait_root );
    206     xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list );
    207 
    208     // get client thread cluster and local pointer
    209     cxy_t      client_cxy = GET_CXY( client_xp );
    210     thread_t * client_ptr = (thread_t *)GET_PTR( client_xp );
    211 
    212     // get command arguments
    213     type    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
    214     count   = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
    215     buf_xp  = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
     236    // get extended pointer on chdev queue root
     237    xptr_t root_xp   = XPTR( local_cxy , &chdev->wait_root );
     238
     239    // get chdev channel
     240    uint32_t channel = chdev->channel;
     241
     242    // get first command if queue non empty
     243    if( xlist_is_empty( root_xp ) == false )
     244    {
     245        // get extended pointer on first client thread
     246        client_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list );
     247
     248        // get client thread cluster and local pointer
     249        client_cxy = GET_CXY( client_xp );
     250        client_ptr = GET_PTR( client_xp );
     251
     252        // get command arguments
     253        type     = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
     254        count    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
     255        buf_xp   = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
     256        error_xp =                 XPTR( client_cxy , &client_ptr->txt_cmd.error  );
     257    }
     258    else
     259    {
     260        type     = 0xFFFFFFFF;
     261
     262        // these lines to avoid a GCC warning
     263        count      = 0;
     264        buf_xp     = XPTR_NULL;
     265        error_xp   = XPTR_NULL;
     266        client_cxy = 0;
     267        client_ptr = NULL;
     268    }
    216269
    217270    // get SOCLIB_TTY peripheral cluster and local pointer
    218271    cxy_t      tty_cxy = GET_CXY( chdev->base );
    219     uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );
     272    uint32_t * tty_ptr = GET_PTR( chdev->base );
    220273
    221274    // get channel base address
     
    227280    read_xp   = XPTR( tty_cxy , base + TTY_READ );
    228281
    229     if( type == TXT_READ )              // read one single character
    230     {
    231         // get TTY_STATUS
    232         status = hal_remote_lw( status_xp );
    233 
    234         if( status & TTY_STATUS_RX_FULL )   // TTY_RX full => move one byte
    235         {
    236             // get a byte from TTY_READ, and acknowledge RX_IRQ
    237             byte = (char)hal_remote_lb( read_xp );
    238 
    239             // write it to command buffer
     282    // get TTY_STATUS register value
     283    status = hal_remote_lw( status_xp );
     284
     285    // 1. handle RX if TTY_READ buffer full
     286    if( status & TTY_STATUS_RX_FULL )   
     287    {
     288        // get a byte from TTY_READ / acknowledge RX_IRQ
     289        byte = (char)hal_remote_lb( read_xp );
     290
     291        // check character value
     292        if( byte == 0x1A )          // ^Z  =>  stop onwner process
     293        {
     294            // get pid of terminal owner process
     295            pid = process_get_txt_owner( channel );
     296
     297            // get cluster and pointers on owner process descriptor
     298            owner_xp  = cluster_get_owner_process_from_pid( pid );
     299            owner_cxy = GET_CXY( owner_xp );
     300            owner_ptr = GET_PTR( owner_xp );
     301
     302            // send stop signal to owner process
     303            process_sigaction( pid , BLOCK_ALL_THREADS );
     304               
     305            // atomically update owner process termination state
     306            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
     307                                  PROCESS_TERM_STOP );
     308            return;
     309        }
     310        else if( byte == 0x03 )     // ^C  => kill owner process
     311        {
     312            // get pid of terminal owner process
     313            pid = process_get_txt_owner( channel );
     314
     315            // get cluster and pointers on owner process descriptor
     316            owner_xp  = cluster_get_owner_process_from_pid( pid );
     317            owner_cxy = GET_CXY( owner_xp );
     318            owner_ptr = GET_PTR( owner_xp );
     319
     320            // send kill signal to owner process
     321            process_sigaction( pid , DELETE_ALL_THREADS );
     322               
     323            // atomically update owner process termination state
     324            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
     325                                  PROCESS_TERM_KILL );
     326            return;
     327        }
     328        else if( type == TXT_READ ) // pending TXT_READ
     329        {
     330            // write character to command buffer
    240331            hal_remote_sb( buf_xp , byte );
    241         }
    242         else                               // buffer empty => exit ISR for retry
    243         {
    244             return;
    245         }
    246 
    247         // disable RX_IRQ
    248         xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
    249         hal_remote_sw( reg_xp , 0 );
    250     }
    251     else   // type == TXT_WRITE           // write all characters in string
     332
     333            // set I/O operation status in command
     334            hal_remote_sw( error_xp , 0 );
     335
     336            // unblock server thread
     337            thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
     338        }
     339    }
     340
     341    // 3. handle TX if TXT_WRITE
     342    if( type == TXT_WRITE )
    252343    {
    253344        // loop on characters
     
    262353                byte = (char)hal_remote_lb( buf_xp + i );
    263354
    264                 // write byte to TTY_WRITE, and acknowledge TX_IRQ
     355                // write byte to TTY_WRITE / acknowledge TX_IRQ
    265356                hal_remote_sb( write_xp , byte );
    266357            }
     
    273364        }
    274365
     366        // set I/O operation status in command
     367        hal_remote_sw( error_xp , 0 );
     368
    275369        // disable TX_IRQ
    276         xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
    277         hal_remote_sw( reg_xp , 0 );
    278     }
    279 
    280     // The I/O operation completed when we reach this point
    281 
    282     // set I/O operation status in command
    283     hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
    284 
    285     // unblock server thread
    286     thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
    287 
    288     // unblock client thread
    289     // thread_unblock( client_xp , THREAD_BLOCKED_IO );
     370        hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
     371
     372        // unblock server thread
     373        thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
     374    }
    290375
    291376    hal_fence();
     
    294379cycle = (uint32_t)hal_get_cycles();
    295380if (CONFIG_DEBUG_HAL_TXT < cycle)
    296 {
    297     if( type == TXT_READ)
    298         printk("\n[DBG] %s : exit after RX / cycle %d\n", __FUNCTION__ , cycle );
    299     else
    300         printk("\n[DBG] %s : exit after TX / cycle %d\n", __FUNCTION__ , cycle );
    301 }     
    302 #endif
    303 
    304 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    305 exit_tty_isr = hal_time_stamp();
     381printk("\n[DBG] %s : exit after %s / cycle %d\n",
     382__FUNCTION__ , dev_txt_type_str( type ) , cycle );
     383#endif
     384
     385#if (CONFIG_DEBUG_SYS_READ & 1)
     386if( type == TXT_READ) exit_tty_isr_read = (uint32_t)hal_get_cycles();
     387#endif
     388
     389#if (CONFIG_DEBUG_SYS_WRITE & 1)
     390if( type == TXT_WRITE) exit_tty_isr_write = (uint32_t)hal_get_cycles();
    306391#endif
    307392
    308393}  // end soclib_tty_isr()
    309394
    310 /*
    311 /////////////////////////////////////////////////////////////////
    312 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
    313 {
    314     xptr_t     root_xp;      // extended pointer on command list root
    315     xptr_t     client_xp;    // extended pointer on client thread
    316     cxy_t      client_cxy;   // client thread cluster
    317     thread_t * client_ptr;   // client_thread local pointer
    318     uint32_t   type;         // command type
    319     uint32_t   count;        // number of bytes in buffer
    320     xptr_t     buf_xp;       // extended pointer on buffer
    321     xptr_t     status_xp;    // extended pointer on TTY_STATUS register
    322     xptr_t     write_xp;     // extended pointer on TTY_WRITE register
    323     xptr_t     read_xp;      // extended pointer on TTY_READ register
    324     uint32_t   status;       // TTY terminal status
    325     char       byte;         // read byte
    326     uint32_t   i;
    327 
    328 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    329 enter_tty_isr = hal_time_stamp();
    330 #endif
    331 
    332 txt_dmsg("\n[DBG] %s : core[%x,%d] enter / cycle %d\n",
    333 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid , hal_time_stamp() );
    334 
    335     // get SOCLIB_TTY peripheral cluster and local pointer
    336     cxy_t      tty_cxy = GET_CXY( chdev->base );
    337     uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );
    338 
    339     // get channel base address
    340     uint32_t * base = tty_ptr + TTY_SPAN * chdev->channel;
    341 
    342     // get extended pointer on TTY registers
    343     status_xp = XPTR( tty_cxy , base + TTY_STATUS );
    344     write_xp  = XPTR( tty_cxy , base + TTY_WRITE );
    345     read_xp   = XPTR( tty_cxy , base + TTY_READ );
    346 
    347     // get TTY_STATUS
    348     status = hal_remote_lw( status_xp );
    349 
    350     // get extended pointer on the command list root
    351     root_xp = XPTR( local_cxy , &chdev->wait_root );
    352 
    353     // get extended pointer on client thread
    354     if(xlist_is_empty(root_xp)) client_xp = XLIST_FIRST_ELEMENT(root, thread_t, wait_list);
    355     else                        client_xp = XPTR_NULL;
    356 
    357     if( client_xp )
    358     {
    359         // get client thread cluster and local pointer
    360         client_cxy = GET_CXY( client_xp );
    361         client_ptr = (thread_t *)GET_PTR( client_xp );
    362 
    363         // get command arguments
    364         type    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
    365         count   = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
    366         buf_xp  = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
    367     }
    368 
    369     ///////////// handle RX if TTY_RX full
    370     if( status & TTY_STATUS_RX_FULL )   
    371     {
    372         // get a byte from TTY_READ, and acknowledge RX_IRQ
    373         byte = (char)hal_remote_lb( read_xp );
    374 
    375         // FIXME The RX_IRQ must be always enabled !!! 
    376         // xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
    377         // hal_remote_sw( reg_xp , 0 );
    378 
    379         // analyse received character
    380         switch( byte )
    381         {
    382             case CONTROL_C:          // SIGINT to process
    383             case CONTROL_D:
    384             {
    385                 // TODO SIGINT
    386                 return
    387             }
    388             break;
    389             default:                 
    390             {
    391                 if( (type == TXT_READ) && (client_xp != XPTR_NULL) ) 
    392                 {
    393                     // write byte to command buffer
    394                     hal_remote_sb( buf_xp , byte );
    395 
    396                     // set status in command
    397                     hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
    398 
    399                     hal_fence();
    400 
    401                     // unblock server thread
    402                     thread_unblock( XPTR(local_cxy,chdev->server), THREAD_BLOCKED_DEV_ISR );
    403                 }
    404                 else                    // discard byte
    405                 {
    406                     // TODO WARNING
    407                     return
    408                 }
    409             }
    410         }
    411     } // end RX handling
    412 
    413     //////////////// handle TX if WRITE command pending
    414     if( (type == TXT_WRITE) && (client_xp != XPTR_NULL) )
    415     {
    416         // loop on characters
    417         for( i = 0 ; i < count ; i++ )
    418         {
    419             // get TTY_STATUS
    420             status = hal_remote_lw( status_xp );
    421 
    422             if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => move one byte
    423             {
    424                 // get one byte from command buffer
    425                 byte = (char)hal_remote_lb( buf_xp + i );
    426 
    427                 // write byte to TTY_WRITE, and acknowledge TX_IRQ
    428                 hal_remote_sb( write_xp , byte );
    429             }
    430             else         // TTY_TX full => update command arguments and exit ISR for retry
    431             {
    432                 hal_remote_sw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ), count-i );
    433                 hal_remote_swd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ), buf_xp+i );
    434                 return;
    435             }
    436         }
    437 
    438         // disable TX_IRQ
    439         xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
    440         hal_remote_sw( reg_xp , 0 );
    441 
    442         // set I/O operation status in command
    443         hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
    444 
    445         hal_fence();
    446 
    447         // unblock server thread
    448         thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
    449 
    450     }  // end TX handling
    451 
    452 txt_dmsg("\n[DBG] %s : core[%x,%d] exit / cycle %d\n",
    453 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    454 
    455 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
    456 exit_tty_isr = hal_time_stamp();
    457 #endif
    458 
    459 }  // end soclib_tty_isr()
    460 
    461 */
  • trunk/hal/tsar_mips32/drivers/soclib_tty.h

    r424 r435  
    2828
    2929/****************************************************************************************
    30  * This driver supports the soclib_multi_tty component.
     30 * This driver supports the vci_tty_tsar component.
    3131 * It implements the generic TXT device API:
    3232 * - transfer one single character from TTY to command "buffer" if to_mem is non-zero.
     
    6262
    6363/****************************************************************************************
    64  * This function implements the TXT_READ & TXT_WRITE commands registered in the client
    65  * thread descriptor (in the txt_cmd field), identified by the <xp_thread> argument.
    66  * Depending on the command type, it only unmasks the relevant TTY_RX / TTY_TX IRQ,
     64 * This function implements both the TXT_READ & TXT_WRITE commands registered in the
     65 * client thread descriptor (in the txt_cmd field), even if ALMOS-MKH defines two
     66 * different chdevs (and consequently two diffeerent server threads) for the RX and TX
     67 * directions. The client thread is identified by the <thread_xp> argument.
     68 * Depending on the command type, it unmasks the relevant TTY_RX / TTY_TX IRQ,
    6769 * and blocks the TXT device server thread on the THREAD_BLOCKED_DEV_ISR, as the data
    6870 * transfer is done by the ISR.
     
    8385
    8486/****************************************************************************************
    85  * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ.
    86  * - the TTY_RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is set in the
    87  *   TTY status register, indicating a character registered in the TTY_READ register.
     87 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ, even if
     88 *   The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the
     89 *   TTY_STATUS register, when the TTY_RX_IRQ_ENABLE is non zero, indicating that
     90 *   the TTY_READ buffer is full and can be read.
     91 *   The TX_IRQ is activated as soon as the TTY_STATUS_TX_FULL bit is 0 in the
     92 *   TTY_STATUS register, when the TTY_TX_IRQ_ENABLE is non zero, indicating that
     93 *   the TTY_WRITE buffer is empty, and can be written.
     94 * WARNING : In ALMOS-MKH, the RX_IRQ is always enabled to catch the control signals,
     95 * but the TX_IRQ is dynamically enabled by the TXT_WRITE command, and disabled when
     96 * the command is completed.
    8897 *
    89  *   . if it exist a TXT_READ command registered in the command queue, and thit copies the
     98 * 1) The ISR first read the TTY_STATUS to get the current state of the TTY_READ and
     99 *   the TTY_WRITE buffers.
     100 *
     101 * 2) It try to read the first command registered in the server thread queue associated
     102 *    to the TTY channel
     103 *
     104 * 2) The ISR handles the RX when the TTY_READ buffer is full :
     105 *   . it read the available character from the TTY_READ buffer, and this
     106 *     acknowledges the RX_IRQ.
     107 *   . if it is a control character ( ^C / ^D / ^Z ) it translate it to the proper
     108 *     signal and execute the relevant sigaction for the foreground process.
     109 *   . if it is a normal character, it try to get the first command registered in the
     110 *     server thread queue. If it is a TXT_READ, it returns this character to the
     111 *     command buffer in the client thread.
     112 *
     113 * 3) The ISR handles the TX when the TTY_WRITE buffer is empty and a TXT_WRITE
     114 *   . it try to get it copies the
    90115 *     character to the command buffer, acknowledges the TTY_RX_IRQ, and unblock the
    91116 *     associated server thread.
    92117     
    93  *   . the control characters are directly handled by the txt ^C / ^D /  and the this IRQ ca
    94  *
     118 *   . the control characters ^C / ^D / ^Z  are directly handled by the ISR and
     119 *     translated to the foreground process.
     120
     121 * - the
    95122 the TXT_READ and TXT_WRITE commands.
    96123 * It gets the command arguments from the first client thread in the TXT chdev queue:
  • trunk/kernel/devices/dev_txt.c

    r433 r435  
    3838extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
    3939
    40 #if CONFIG_READ_DEBUG
     40#if (CONFIG_DEBUG_SYS_READ & 1)
    4141extern uint32_t enter_txt_read;
    4242extern uint32_t exit_txt_read;
    4343#endif
     44
     45#if (CONFIG_DEBUG_SYS_WRITE & 1)
     46extern uint32_t enter_txt_write;
     47extern uint32_t exit_txt_write;
     48#endif
     49
     50////////////////////////////////////////
     51char * dev_txt_type_str( uint32_t type )
     52{
     53    if     ( type == TXT_SYNC_WRITE ) return "TXT_SYNC_WRITE";
     54    else if( type == TXT_READ       ) return "TXT_READ";
     55    else if( type == TXT_WRITE      ) return "TXT_WRITE";
     56    else                              return "undefined";
     57}
    4458
    4559//////////////////////////////////
     
    117131    thread_t * this = CURRENT_THREAD;
    118132
     133#if (CONFIG_DEBUG_SYS_READ & 1)
     134enter_txt_read = hal_time_stamp();
     135#endif
     136
     137#if (CONFIG_DEBUG_SYS_WRITE & 1)
     138enter_txt_write = hal_time_stamp();
     139#endif
     140
    119141#if CONFIG_DEBUG_DEV_TXT
    120142uint32_t cycle = (uint32_t)hal_get_cycles();
     
    151173#endif
    152174
     175#if (CONFIG_DEBUG_SYS_READ & 1)
     176exit_txt_read = hal_time_stamp();
     177#endif
     178
     179#if (CONFIG_DEBUG_SYS_WRITE & 1)
     180exit_txt_write = hal_time_stamp();
     181#endif
     182
    153183    // return I/O operation status from calling thread descriptor
    154184    return this->txt_cmd.error;
     
    160190                       uint32_t   count )
    161191{
    162     error_t error = dev_txt_access( TXT_WRITE , channel , buffer , count );
    163     return error;
     192    return dev_txt_access( TXT_WRITE , channel , buffer , count );
    164193}
    165194
     
    168197                      char     * buffer )
    169198{
    170 
    171 #if CONFIG_READ_DEBUG
    172 enter_txt_read = hal_time_stamp();
    173 #endif
    174 
    175     error_t error = dev_txt_access( TXT_READ , channel , buffer , 1 );
    176 
    177 #if CONFIG_READ_DEBUG
    178 exit_txt_read = hal_time_stamp();
    179 #endif
    180 
    181     return error;
    182 
     199    return dev_txt_access( TXT_READ , channel , buffer , 1 );
    183200}
    184201
     
    201218
    202219    // build arguments structure
    203     txt_aux_t  args;
     220    txt_sync_args_t  args;
    204221    args.dev_xp = dev_xp;
    205222    args.buffer = buffer;
  • trunk/kernel/devices/dev_txt.h

    r422 r435  
    8282    TXT_READ       = 0,
    8383    TXT_WRITE      = 1,
     84    TXT_SYNC_WRITE = 2,
    8485};
    8586
     
    8788{
    8889    xptr_t      dev_xp;    /*! extended pointer on the relevant TXT device descriptor    */
    89     uint32_t    type;      /*! TXT_READ / TXT_WRITE / TXT_SYNC_WRITE                     */
     90    uint32_t    type;      /*! TXT_READ / TXT_WRITE                                      */
    9091    xptr_t      buf_xp;    /*! extended pointer on characters array                      */
    9192    uint32_t    count;     /*! number of characters in buffer (must be 1 if to_mem)      */
     
    99100 *****************************************************************************************/
    100101
    101 typedef struct txt_aux_s
     102typedef struct txt_sync_args_s
    102103{
    103     xptr_t      dev_xp;    /*! extended pointer on the TXT0 device descriptor            */
     104    xptr_t      dev_xp;    /*! extended pointer on the TXT0_TX device descriptor            */
    104105    char      * buffer;    /*! local pointer on characters array                         */
    105106    uint32_t    count;     /*! number of characters in buffer                            */
    106107}
    107 txt_aux_t;
     108txt_sync_args_t;
     109
     110/******************************************************************************************
     111 * This function returns a printable string for the comman type.
     112 ******************************************************************************************
     113 * @ type     : command type (TXT_READ / TXT_WRITE / TXT_SYNC_WRITE)
     114 *****************************************************************************************/
     115char * dev_txt_type_str( uint32_t type );
    108116
    109117/******************************************************************************************
     
    157165 * As it is used for debug, the command arguments <buffer> and <count> are registerd
    158166 * in a specific "dbg_cmd" field of the calling thread.
    159  * other TXT accesses.
    160167 ****************************************************************************************
    161168 * @ buffer    : local pointer on source buffer containing the string.
  • trunk/kernel/fs/devfs.c

    r433 r435  
    4242extern chdev_directory_t    chdev_dir;      // allocated in kernel_init.c
    4343
    44 #if CONFIG_READ_DEBUG
    45 extern uint32_t  enter_devfs_move;
    46 extern uint32_t  exit_devfs_move;
     44#if (CONFIG_DEBUG_SYS_READ & 1)
     45extern uint32_t  enter_devfs_read;
     46extern uint32_t  exit_devfs_read;
     47#endif
     48
     49#if (CONFIG_DEBUG_SYS_WRITE & 1)
     50extern uint32_t  enter_devfs_write;
     51extern uint32_t  exit_devfs_write;
    4752#endif
    4853
     
    375380    char               k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
    376381
     382#if (CONFIG_DEBUG_SYS_READ & 1)
     383enter_devfs_read = hal_time_stamp();
     384#endif
     385
     386#if (CONFIG_DEBUG_SYS_WRITE & 1)
     387enter_devfs_write = hal_time_stamp();
     388#endif
     389
    377390#if CONFIG_DEBUG_DEVFS_MOVE
    378391uint32_t cycle = (uint32_t)hal_get_cycles();
     
    380393printk("\n[DBG] %s : thread %x enter / to_mem %d / cycle %d\n",
    381394__FUNCTION__ , CURRENT_THREAD , to_buffer , cycle );
    382 #endif
    383 
    384 #if CONFIG_READ_DEBUG
    385 enter_devfs_move = hal_time_stamp();
    386395#endif
    387396
     
    424433#endif
    425434
    426 #if CONFIG_READ_DEBUG
    427 exit_devfs_move = hal_time_stamp();
     435#if (CONFIG_DEBUG_SYS_READ & 1)
     436exit_devfs_read = hal_time_stamp();
    428437#endif
    429438            return size;
     
    448457#endif
    449458
     459#if (CONFIG_DEBUG_SYS_WRITE & 1)
     460exit_devfs_write = hal_time_stamp();
     461#endif
    450462                return size;
    451463            }
  • trunk/kernel/fs/fatfs.c

    r407 r435  
    262262    "no FAT access required for first page\n");
    263263
    264 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enters / first_cluster_id = %d / searched_index = %d\n",
    265 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first_cluster_id, searched_page_index );
     264#if CONFIG_DEBUG_FATFS_GET_CLUSTER
     265uint32_t cycle = (uint32_t)hal_get_cycles();
     266if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     267printk("\n[DBG] %s : thread %x enter / first_cluster_id %d / searched_index / cycle %d\n",
     268__FUNCTION__, CURRENT_THREAD, first_cluster_id, searched_page_index, cycle );
     269#endif
    266270
    267271    // get number of FAT slots per page
     
    289293        next_cluster_id = current_page_buffer[current_page_offset];
    290294
    291 fatfs_dmsg("\n[DBG] %s : core[%x,%d] traverse FAT / current_page_index = %d\n"
     295#if (CONFIG_DEBUG_FATFS_GET_CLUSTER & 1)
     296if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     297printk("\n[DBG] %s : traverse FAT / current_page_index = %d\n"
    292298"current_page_offset = %d / next_cluster_id = %d\n",
    293 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, current_page_index,
    294 current_page_offset , next_cluster_id );
     299__FUNCTION__, current_page_index, current_page_offset , next_cluster_id );
     300#endif
    295301
    296302        // update loop variables
     
    302308    if( next_cluster_id == 0xFFFFFFFF ) return EIO;
    303309   
    304 fatfs_dmsg("\n[DBG] %s : core[%x;%d] exit / cluster_id = %d\n",
    305 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, next_cluster_id );
     310#if CONFIG_DEBUG_FATFS_GET_CLUSTER
     311cycle = (uint32_t)hal_get_cycles();
     312if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     313printk("\n[DBG] %s : thread %x exit / searched_cluster_id = %d / cycle %d\n",
     314__FUNCTION__, CURRENT_THREAD, next_cluster_id / cycle );
     315#endif
    306316
    307317    *searched_cluster_id = next_cluster_id;
     
    335345    uint8_t     * buffer;
    336346
    337     fatfs_dmsg("\n[DBG] %s : enter for fatfs_ctx = %x\n",
    338                __FUNCTION__ , fatfs_ctx );
     347#if CONFIG_DEBUG_FATFS_INIT
     348uint32_t cycle = (uint32_t)hal_get_cycles();
     349if( CONFIG_DEBUG_FATFS_INIT < cycle )
     350printk("\n[DBG] %s : thread %x enter for fatfs_ctx = %x / cycle %d\n",
     351__FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle );
     352#endif
    339353
    340354    assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
    341                    "cannot allocate memory for FATFS context\n" );
     355    "cannot allocate memory for FATFS context\n" );
    342356
    343357    // allocate a 512 bytes buffer to store the boot record
     
    347361
    348362    assert( (buffer != NULL) , __FUNCTION__ ,
    349                    "cannot allocate memory for 512 bytes buffer\n" );
     363    "cannot allocate memory for 512 bytes buffer\n" );
    350364     
    351     fatfs_dmsg("\n[DBG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );
    352 
    353365    // load the boot record from device
    354366    // using a synchronous access to IOC device 
    355367    error = dev_ioc_sync_read( buffer , 0 , 1 );
    356368
    357 fatfs_dmsg("\n[DBG] %s : buffer loaded\n", __FUNCTION__ );
    358 
    359     assert( (error == 0) , __FUNCTION__ , "cannot access boot record\n" );
    360 
    361 #if (CONFIG_FATFS_DEBUG & 0x1)
    362 if( hal_time_stamp() > CONFIG_FATFS_DEBUG )
     369    assert( (error == 0) , __FUNCTION__ ,
     370    "cannot access boot record\n" );
     371
     372#if (CONFIG_DEBUG_FATFS_INIT & 0x1)
     373if( CONFIG_DEBUG_FATFS_INIT < cycle )
    363374{
    364375    uint32_t   line;
     
    389400
    390401    assert( (nb_sectors == 8) , __FUNCTION__ ,
    391             "cluster size must be 8 sectors\n" );
     402    "cluster size must be 8 sectors\n" );
    392403
    393404    // check number of FAT copies from boot record
     
    395406
    396407    assert( (nb_fats == 1) , __FUNCTION__ ,
    397             "number of FAT copies must be 1\n" );
     408    "number of FAT copies must be 1\n" );
    398409
    399410    // get & check number of sectors in FAT from boot record
     
    401412
    402413    assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ ,
    403             "FAT not multiple of 16 sectors\n");
     414    "FAT not multiple of 16 sectors\n");
    404415
    405416    // get and check root cluster from boot record
     
    407418
    408419    assert( (root_cluster == 2) , __FUNCTION__ ,
    409             "root cluster index must be  2\n");
     420    "root cluster index must be  2\n");
    410421
    411422    // get FAT lba from boot record
     
    417428    kmem_free( &req );
    418429
    419     fatfs_dmsg("\n[DBG] %s : boot record read & released\n",
    420                __FUNCTION__ );
    421 
    422430    // allocate a mapper for the FAT itself
    423431    mapper_t * fat_mapper = mapper_create( FS_TYPE_FATFS );
    424432
    425     assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" );
     433    assert( (fat_mapper != NULL) , __FUNCTION__ ,
     434    "no memory for FAT mapper" );
    426435
    427436    // WARNING : the inode field MUST be NULL for the FAT mapper
     
    439448    fatfs_ctx->fat_mapper_xp         = XPTR( local_cxy , fat_mapper );
    440449
    441 fatfs_dmsg("\n[DBG] %s : exit for fatfs_ctx = %x\n", __FUNCTION__ , fatfs_ctx );
     450#if CONFIG_DEBUG_FATFS_INIT
     451cycle = (uint32_t)hal_get_cycles();
     452if( CONFIG_DEBUG_FATFS_INIT < cycle )
     453printk("\n[DBG] %s : thread %x exit for fatfs_ctx = %x / cycle %d\n",
     454__FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle );
     455#endif
    442456
    443457}  // end fatfs_ctx_init()
     
    472486    inode = mapper->inode;
    473487
    474 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enter for page %d / inode %x / mapper %x\n",
    475 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
     488#if CONFIG_DEBUG_FATFS_MOVE
     489uint32_t cycle = (uint32_t)hal_get_cycles();
     490if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     491printk("\n[DBG] %s : thread %x enter / page %d / inode %x / mapper %x / cycle %d\n",
     492__FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle );
     493#endif
    476494
    477495    // get page base address
     
    489507        lba = fatfs_ctx->fat_begin_lba + (count * index);
    490508 
    491 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access FAT on device / lba = %d\n",
    492 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba );
     509#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     510if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     511printk("\n[DBG] %s : access FAT on device / lba = %d\n", __FUNCTION__ , lba );
     512#endif
    493513
    494514        // access device
     
    521541            {
    522542
    523 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access local FAT mapper\n"
     543#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     544if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     545print("\n[DBG] %s : access local FAT mapper\n"
    524546"fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n",
    525 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ,
    526 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
    527 
     547__FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
     548#endif
    528549                error = fatfs_get_cluster( fat_mapper_ptr,
    529550                                           first_cluster_id,
     
    534555            {
    535556
    536 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access remote FAT mapper\n"
     557#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     558if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     559printk("\n[DBG] %s : access remote FAT mapper\n"
    537560"fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n",
    538 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ,
    539 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
    540 
     561__FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
     562#endif
    541563                rpc_fatfs_get_cluster_client( fat_mapper_cxy,
    542564                                              fat_mapper_ptr,
     
    550572        }
    551573
    552 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access device for inode %x / cluster_id %d\n",
    553 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , searched_cluster_id );
     574#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     575if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     576printk("\n[DBG] %s : access device for inode %x / cluster_id %d\n",
     577__FUNCTION__ , inode , searched_cluster_id );
     578#endif
    554579
    555580        // get lba from cluster_id
     
    563588    }
    564589
    565 fatfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / inode %x / mapper %x\n",
    566 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
    567 
    568 #if (CONFIG_FATFS_DEBUG & 0x1)
    569 if( hal_time_stamp() > CONFIG_FATFS_DEBUG )
     590#if CONFIG_DEBUG_FATFS_MOVE
     591cycle = (uint32_t)hal_get_cycles();
     592if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     593printk("\n[DBG] %s : thread %x exit / page %d / inode %x / mapper %x / cycle %d\n",
     594__FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle );
     595#endif
     596
     597#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     598if( CONFIG_DEBUG_FATFS_MOVE < cycle )
    570599{
    571600    uint32_t * tab = (uint32_t *)buffer;
     
    594623    // - scan the directory entries in each 4 Kbytes page
    595624
    596 fatfs_dmsg("\n[DBG] %s : enter for child <%s> in parent inode %l\n",
    597 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     625#if CONFIG_DEBUG_FATFS_LOAD
     626uint32_t cycle = (uint32_t)hal_get_cycles();
     627if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     628printk("\n[DBG] %s : thread %x enter for child <%s> in parent inode %x / cycle %d\n",
     629__FUNCTION__ , CURRENT_THREAD , name , parent_inode , cycle );
     630#endif
    598631
    599632    mapper_t * mapper = parent_inode->mapper;
     
    632665        base = (uint8_t *)GET_PTR( base_xp );
    633666
    634 #if (CONFIG_FATFS_DEBUG & 0x1)
    635 if( hal_time_stamp() > CONFIG_FATFS_DEBUG )
     667#if (CONFIG_DEBUG_FATFS_LOAD & 0x1)
     668if( CONFIG_DEBUG_FATFS_LOAD < cycle )
    636669{
    637670    uint32_t * buf = (uint32_t *)base;
     
    716749    {
    717750
    718 fatfs_dmsg("\n[DBG] %s : exit / child <%s> not found in parent inode %l\n",
    719 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     751#if CONFIG_DEBUG_FATFS_LOAD
     752cycle = (uint32_t)hal_get_cycles();
     753if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     754printk("\n[DBG] %s : thread %x exit / child <%s> not found / cycle %d\n",
     755__FUNCTION__ , CURRENT_THREAD, name, cycle );
     756#endif
    720757
    721758        return ENOENT;
     
    734771        hal_remote_sw( XPTR( child_cxy , &child_ptr->extend ) , cluster );
    735772
    736 fatfs_dmsg("\n[DBG] %s : exit / child <%s> found in parent inode %l\n",
    737 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     773#if CONFIG_DEBUG_FATFS_LOAD
     774cycle = (uint32_t)hal_get_cycles();
     775if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     776printk("\n[DBG] %s : thread %x exit / child <%s> loaded / cycle %d\n",
     777__FUNCTION__ , CURRENT_THREAD, name, cycle );
     778#endif
    738779
    739780        return 0;
  • trunk/kernel/kern/chdev.c

    r433 r435  
    3939extern chdev_directory_t    chdev_dir;   // allocated in kernel_init.c
    4040
    41 #if CONFIG_READ_DEBUG
    42 extern uint32_t enter_chdev_cmd;
    43 extern uint32_t exit_chdev_cmd;
    44 extern uint32_t enter_chdev_server;
    45 extern uint32_t exit_chdev_server;
     41#if (CONFIG_DEBUG_SYS_READ & 1)
     42extern uint32_t enter_chdev_cmd_read;
     43extern uint32_t exit_chdev_cmd_read;
     44extern uint32_t enter_chdev_server_read;
     45extern uint32_t exit_chdev_server_read;
     46#endif
     47
     48#if (CONFIG_DEBUG_SYS_WRITE & 1)
     49extern uint32_t enter_chdev_cmd_write;
     50extern uint32_t exit_chdev_cmd_write;
     51extern uint32_t enter_chdev_server_write;
     52extern uint32_t exit_chdev_server_write;
    4653#endif
    4754
     
    123130    uint32_t   save_sr;       // for critical section
    124131
    125 #if CONFIG_READ_DEBUG
    126 enter_chdev_cmd = hal_time_stamp();
     132#if (CONFIG_DEBUG_SYS_READ & 1)
     133enter_chdev_cmd_read = (uint32_t)hal_get_cycles();
     134#endif
     135
     136#if (CONFIG_DEBUG_SYS_WRITE & 1)
     137enter_chdev_cmd_write = (uint32_t)hal_get_cycles();
    127138#endif
    128139
     
    178189    if( different ) dev_pic_send_ipi( chdev_cxy , lid );
    179190   
     191    // deschedule
     192    assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" );
     193    sched_yield("blocked on I/O");
     194
     195    // exit critical section
     196    hal_restore_irq( save_sr );
     197
    180198#if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    181199cycle = (uint32_t)hal_get_cycles();
     
    185203#endif
    186204
    187     // deschedule
    188     assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" );
    189     sched_yield("blocked on I/O");
    190 
    191     // exit critical section
    192     hal_restore_irq( save_sr );
    193 
    194 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    195 cycle = (uint32_t)hal_get_cycles();
    196 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle )
    197 printk("\n[DBG] %s : client_thread %x (%s) resumes / cycle %d\n",
    198 __FUNCTION__, this, thread_type_str(this->type) , cycle );
    199 #endif
    200 
    201 #if CONFIG_READ_DEBUG
    202 exit_chdev_cmd = hal_time_stamp();
     205#if (CONFIG_DEBUG_SYS_READ & 1)
     206exit_chdev_cmd_read = (uint32_t)hal_get_cycles();
     207#endif
     208
     209#if (CONFIG_DEBUG_SYS_WRITE & 1)
     210exit_chdev_cmd_write = (uint32_t)hal_get_cycles();
    203211#endif
    204212
     
    240248            remote_spinlock_unlock( lock_xp );
    241249
    242 chdev_dmsg("\n[DBG] %s : thread %x deschedule /cycle %d\n",
    243 __FUNCTION__ , server , hal_time_stamp() );
    244 
    245250            // deschedule
    246251            sched_yield("I/O queue empty");
    247 
    248 chdev_dmsg("\n[DBG] %s : thread %x resume /cycle %d\n",
    249 __FUNCTION__ , server , hal_time_stamp() );
    250 
    251252        }
    252253        else                            // waiting queue not empty
    253254        {
    254255
    255 #if CONFIG_READ_DEBUG
    256 enter_chdev_server = hal_time_stamp();
    257 #endif
     256#if (CONFIG_DEBUG_SYS_READ & 1)
     257enter_chdev_server_read = (uint32_t)hal_get_cycles();
     258#endif
     259
     260#if (CONFIG_DEBUG_SYS_WRITE & 1)
     261enter_chdev_server_write = (uint32_t)hal_get_cycles();
     262#endif
     263
    258264            // release lock
    259265            remote_spinlock_unlock( lock_xp );
     
    284290#endif
    285291
    286 #if CONFIG_READ_DEBUG
    287 exit_chdev_server = hal_time_stamp();
     292#if (CONFIG_DEBUG_SYS_READ & 1)
     293exit_chdev_server_read = (uint32_t)hal_get_cycles();
     294#endif
     295
     296#if (CONFIG_DEBUG_SYS_WRITE & 1)
     297exit_chdev_server_write = (uint32_t)hal_get_cycles();
    288298#endif
    289299
  • trunk/kernel/kern/kernel_init.c

    r428 r435  
    123123
    124124
    125 // TODO remove these debug variables used dans sys_read()
     125// these debug variables are used to analyse the sys_read() syscall timing
    126126
    127127#if CONFIG_READ_DEBUG   
     
    129129uint32_t   exit_sys_read;
    130130
    131 uint32_t   enter_devfs_move;
    132 uint32_t   exit_devfs_move;
     131uint32_t   enter_devfs_read;
     132uint32_t   exit_devfs_read;
    133133
    134134uint32_t   enter_txt_read;
    135135uint32_t   exit_txt_read;
    136136
    137 uint32_t   enter_chdev_cmd;
    138 uint32_t   exit_chdev_cmd;
    139 
    140 uint32_t   enter_chdev_server;
    141 uint32_t   exit_chdev_server;
    142 
    143 uint32_t   enter_tty_cmd;
    144 uint32_t   exit_tty_cmd;
    145 
    146 uint32_t   enter_tty_isr;
    147 uint32_t   exit_tty_isr;
     137uint32_t   enter_chdev_cmd_read;
     138uint32_t   exit_chdev_cmd_read;
     139
     140uint32_t   enter_chdev_server_read;
     141uint32_t   exit_chdev_server_read;
     142
     143uint32_t   enter_tty_cmd_read;
     144uint32_t   exit_tty_cmd_read;
     145
     146uint32_t   enter_tty_isr_read;
     147uint32_t   exit_tty_isr_read;
     148#endif
     149
     150// these debug variables are used to analyse the sys_write() syscall timing
     151
     152#if CONFIG_WRITE_DEBUG   
     153uint32_t   enter_sys_write;
     154uint32_t   exit_sys_write;
     155
     156uint32_t   enter_devfs_write;
     157uint32_t   exit_devfs_write;
     158
     159uint32_t   enter_txt_write;
     160uint32_t   exit_txt_write;
     161
     162uint32_t   enter_chdev_cmd_write;
     163uint32_t   exit_chdev_cmd_write;
     164
     165uint32_t   enter_chdev_server_write;
     166uint32_t   exit_chdev_server_write;
     167
     168uint32_t   enter_tty_cmd_write;
     169uint32_t   exit_tty_cmd_write;
     170
     171uint32_t   enter_tty_isr_write;
     172uint32_t   exit_tty_isr_write;
    148173#endif
    149174
  • trunk/kernel/kern/process.c

    r433 r435  
    5151#include <elf.h>
    5252#include <syscalls.h>
    53 #include <signal.h>
     53#include <shared_syscalls.h>
    5454
    5555//////////////////////////////////////////////////////////////////////////////////////////
     
    114114    // get model process cluster and local pointer
    115115    model_cxy = GET_CXY( model_xp );
    116     model_ptr = (process_t *)GET_PTR( model_xp );
     116    model_ptr = GET_PTR( model_xp );
    117117
    118118    // get parent process cluster and local pointer
    119119    parent_cxy = GET_CXY( parent_xp );
    120     parent_ptr = (process_t *)GET_PTR( parent_xp );
     120    parent_ptr = GET_PTR( parent_xp );
    121121
    122122    // get model_pid and parent_pid
     
    209209        // get cluster and local pointer on chdev
    210210        chdev_cxy = GET_CXY( chdev_xp );
    211         chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     211        chdev_ptr = GET_PTR( chdev_xp );
    212212 
    213213        // get TXT terminal index
     
    289289    // get reference process cluster and local pointer
    290290    cxy_t       ref_cxy = GET_CXY( reference_process_xp );
    291     process_t * ref_ptr = (process_t *)GET_PTR( reference_process_xp );
     291    process_t * ref_ptr = GET_PTR( reference_process_xp );
    292292
    293293    // initialize PID, REF_XP, PARENT_XP, and STATE
     
    364364    process_t * parent_ptr;
    365365    cxy_t       parent_cxy;
    366     xptr_t      parent_thread_xp;
    367366    xptr_t      children_lock_xp;
    368367    xptr_t      copies_lock_xp;
     
    450449}
    451450
    452 ////////////////////////////////////////////
    453 void process_sigaction( process_t * process,
     451////////////////////////////////////////
     452void process_sigaction( pid_t       pid,
    454453                        uint32_t    action_type )
    455454{
     
    467466    rpc_desc_t         rpc;               // rpc descriptor allocated in stack
    468467
     468    thread_t * client = CURRENT_THREAD;
     469
    469470#if CONFIG_DEBUG_PROCESS_SIGACTION
    470471uint32_t cycle = (uint32_t)hal_get_cycles();
    471472if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
    472 printk("\n[DBG] %s : thread %x enter to %s process %x in cluster %x / cycle %d\n",
    473 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,
    474 process->pid , local_cxy , cycle );
    475 #endif
    476 
    477     thread_t         * client = CURRENT_THREAD;
     473printk("\n[DBG] %s : thread %x enter to %s process %x / cycle %d\n",
     474__FUNCTION__ , client, process_action_str( action_type ) , pid , cycle );
     475#endif
    478476
    479477    // get local pointer on local cluster manager
     
    481479
    482480    // get owner cluster identifier and process lpid
    483     owner_cxy = CXY_FROM_PID( process->pid );
    484     lpid      = LPID_FROM_PID( process->pid );
    485 
    486     // check owner cluster
    487     assert( (owner_cxy == local_cxy) , __FUNCTION__ , "must be executed in owner cluster\n" );
    488    
    489     // get number of remote copies
    490     responses = cluster->pmgr.copies_nr[lpid] - 1;
     481    owner_cxy = CXY_FROM_PID( pid );
     482    lpid      = LPID_FROM_PID( pid );
     483
     484    // get root of list of copies, lock, and number of copies from owner cluster
     485    responses = hal_remote_lw ( XPTR( owner_cxy , &cluster->pmgr.copies_nr[lpid] ) );
     486    root_xp   = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ) );
     487    lock_xp   = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ) );
     488
    491489    rsp_count = 0;
    492490
     
    502500    rpc.thread   = client;
    503501
    504     // get extended pointers on copies root and lock
    505     root_xp   = XPTR( local_cxy , &cluster->pmgr.copies_root[lpid] );
    506     lock_xp   = XPTR( local_cxy , &cluster->pmgr.copies_lock[lpid] );
    507 
    508502    // take the lock protecting the copies
    509503    remote_spinlock_lock( lock_xp );
     
    514508        process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
    515509        process_cxy = GET_CXY( process_xp );
    516         process_ptr = (process_t *)GET_PTR( process_xp );
    517 
    518         // send RPC to remote clusters
    519         if( process_cxy != local_cxy ) 
    520         {
     510        process_ptr = GET_PTR( process_xp );
    521511
    522512#if CONFIG_DEBUG_PROCESS_SIGACTION
    523513if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
    524 printk("\n[DBG] %s : send RPC to remote cluster %x\n", __FUNCTION__ , process_cxy );
    525 #endif
    526 
    527             rpc.args[0] = (uint64_t)action_type;
    528             rpc.args[1] = (uint64_t)(intptr_t)process_ptr;
    529             rpc_process_sigaction_client( process_cxy , &rpc );
    530             rsp_count++;
    531         }
     514printk("\n[DBG] %s : send RPC to cluster %x\n", __FUNCTION__ , process_cxy );
     515#endif
     516
     517        // check PID
     518        assert( (hal_remote_lw( XPTR( process_cxy , &process_ptr->pid) ) == pid),
     519        __FUNCTION__ , "unconsistent PID value\n" );
     520
     521        rpc.args[0] = (uint64_t)action_type;
     522        rpc.args[1] = (uint64_t)pid;
     523        rpc_process_sigaction_client( process_cxy , &rpc );
     524        rsp_count++;
    532525    }
    533526   
     
    540533    rsp_count , responses );
    541534
    542     // block and deschedule to wait RPC responses if required
    543     if( responses )
    544     {   
    545         thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC );
    546         sched_yield("BLOCKED on RPC_PROCESS_SIGACTION");
    547     }
    548 
    549 #if CONFIG_DEBUG_PROCESS_SIGACTION
    550 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
    551 printk("\n[DBG] %s : make action in owner cluster %x\n", __FUNCTION__ , local_cxy );
    552 #endif
    553 
    554     // call directly the relevant function in local owner cluster
    555     if      (action_type == DELETE_ALL_THREADS  ) process_delete_threads ( process );
    556     else if (action_type == BLOCK_ALL_THREADS   ) process_block_threads  ( process );
    557     else if (action_type == UNBLOCK_ALL_THREADS ) process_unblock_threads( process );
     535    // block and deschedule to wait RPC responses
     536    thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC );
     537    sched_yield("BLOCKED on RPC_PROCESS_SIGACTION");
    558538
    559539#if CONFIG_DEBUG_PROCESS_SIGACTION
     
    561541if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
    562542printk("\n[DBG] %s : thread %x exit after %s process %x in cluster %x / cycle %d\n",
    563 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,
     543__FUNCTION__ , client, process_action_str( action_type ) ,
    564544process->pid , local_cxy , cycle );
    565545#endif
     
    778758    {
    779759        process_xp  = XLIST_ELEMENT( iter , process_t , local_list );
    780         process_ptr = (process_t *)GET_PTR( process_xp );
     760        process_ptr = GET_PTR( process_xp );
    781761        if( process_ptr->pid == pid )
    782762        {
     
    838818
    839819    // get reference process cluster and local pointer
    840     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     820    process_t * ref_ptr = GET_PTR( ref_xp );
    841821    cxy_t       ref_cxy = GET_CXY( ref_xp );
    842822
     
    858838    // get reference process cluster and local pointer
    859839    xptr_t ref_xp = process->ref_xp;
    860     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     840    process_t * ref_ptr = GET_PTR( ref_xp );
    861841    cxy_t       ref_cxy = GET_CXY( ref_xp );
    862842
     
    900880        xptr_t      ref_xp  = process->ref_xp;
    901881        cxy_t       ref_cxy = GET_CXY( ref_xp );
    902         process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     882        process_t * ref_ptr = GET_PTR( ref_xp );
    903883
    904884        // access reference process descriptor
     
    925905    // get cluster and local pointer for src fd_array
    926906    cxy_t        src_cxy = GET_CXY( src_xp );
    927     fd_array_t * src_ptr = (fd_array_t *)GET_PTR( src_xp );
     907    fd_array_t * src_ptr = GET_PTR( src_xp );
    928908
    929909    // get cluster and local pointer for dst fd_array
    930910    cxy_t        dst_cxy = GET_CXY( dst_xp );
    931     fd_array_t * dst_ptr = (fd_array_t *)GET_PTR( dst_xp );
     911    fd_array_t * dst_ptr = GET_PTR( dst_xp );
    932912
    933913    // get the remote lock protecting the src fd_array
     
    10441024    // get cluster and local pointer for parent process
    10451025    cxy_t       parent_process_cxy = GET_CXY( parent_process_xp );
    1046     process_t * parent_process_ptr = (process_t *)GET_PTR( parent_process_xp );
     1026    process_t * parent_process_ptr = GET_PTR( parent_process_xp );
    10471027
    10481028    // get parent process PID and extended pointer on .elf file
     
    13491329}  // end process_make_exec()
    13501330
    1351 ////////////////////////////////////////////
    1352 void process_make_kill( process_t * process,
    1353                         bool_t      is_exit,
    1354                         uint32_t    exit_status )
    1355 {
    1356     thread_t * this = CURRENT_THREAD;
    1357 
    1358     assert( (CXY_FROM_PID( process->pid ) == local_cxy) , __FUNCTION__ ,
    1359     "must be executed in process owner cluster\n" );
    1360 
    1361     assert( ( this->type == THREAD_RPC ) , __FUNCTION__ ,
    1362     "must be executed by an RPC thread\n" );
    1363 
    1364 #if CONFIG_DEBUG_PROCESS_MAKE_KILL
    1365 uint32_t cycle = (uint32_t)hal_get_cycles();
    1366 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )
    1367 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",
    1368 __FUNCTION__, this , process->pid , cycle );
    1369 #endif
    1370 
    1371     // register exit_status in owner process descriptor
    1372     if( is_exit ) process->term_state = exit_status;
    1373 
    1374     // atomically update owner process descriptor flags
    1375     if( is_exit ) hal_atomic_or( &process->term_state , PROCESS_FLAG_EXIT );
    1376     else          hal_atomic_or( &process->term_state , PROCESS_FLAG_KILL );
    1377 
    1378     // remove TXT ownership from owner process descriptor
    1379     process_txt_reset_ownership( XPTR( local_cxy , process ) );
    1380 
    1381     // block all process threads in all clusters
    1382     process_sigaction( process , BLOCK_ALL_THREADS );
    1383 
    1384     // mark all process threads in all clusters for delete
    1385     process_sigaction( process , DELETE_ALL_THREADS );
    1386 
    1387 /* unused if sys_wait deschedules without blocking [AG]
    1388 
    1389     // get cluster and pointers on reference parent process
    1390     xptr_t      parent_xp  = process->parent_xp;
    1391     process_t * parent_ptr = GET_PTR( parent_xp );
    1392     cxy_t       parent_cxy = GET_CXY( parent_xp );
    1393 
    1394     // get loal pointer on parent main thread
    1395     thread_t * main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );
    1396  
    1397     // reset THREAD_BLOCKED_WAIT bit in parent process main thread
    1398     thread_unblock( XPTR( parent_cxy , main_ptr ) , THREAD_BLOCKED_WAIT );
    1399 */
    1400 
    1401 #if CONFIG_DEBUG_PROCESS_MAKE_KILL
    1402 cycle = (uint32_t)hal_get_cycles();
    1403 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )
    1404 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",
    1405 __FUNCTION__, this, process->pid , cycle );
    1406 #endif
    1407 
    1408 }  // end process_make_kill()
    1409 
    14101331///////////////////////////////////////////////
    14111332void process_zero_create( process_t * process )
     
    16791600if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
    16801601printk("\n[DBG] %s : thread %x enter for process %x / txt_id = %d  / cycle %d\n",
    1681 __FUNCTION__, CURRENT_THREAD, process->pid, txt_id, cycle );
     1602__FUNCTION__, CURRENT_THREAD, process, txt_id, cycle );
    16821603#endif
    16831604
     
    17081629if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
    17091630printk("\n[DBG] %s : thread %x exit for process %x / txt_id = %d / cycle %d\n",
    1710 __FUNCTION__, CURRENT_THREAD, process->pid, txt_id , cycle );
     1631__FUNCTION__, CURRENT_THREAD, process, txt_id , cycle );
    17111632#endif
    17121633
     
    17211642    xptr_t      lock_xp;      // extended pointer on list lock in chdev
    17221643
    1723 #if CONFIG_DEBUG_PROCESS_TXT_DETACH
     1644#if CONFIG_DEBUG_PROCESS_TXT_ATTACH
    17241645uint32_t cycle = (uint32_t)hal_get_cycles();
    1725 if( CONFIG_DEBUG_PROCESS_TXT_DETACH < cycle )
     1646if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
    17261647printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",
    1727 __FUNCTION__, CURRENT_THREAD, process->pid , cycle );
     1648__FUNCTION__, CURRENT_THREAD, process, cycle );
    17281649#endif
    17291650
     
    17451666    remote_spinlock_unlock( lock_xp );
    17461667   
    1747 #if CONFIG_DEBUG_PROCESS_TXT_DETACH
    1748 cycle = (uint32_t)hal_get_cycles();
    1749 if( CONFIG_DEBUG_PROCESS_TXT_DETACH < cycle )
     1668#if CONFIG_DEBUG_PROCESS_TXT_ATTACH
     1669cycle = (uint32_t)hal_get_cycles();
     1670if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
    17501671printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",
    1751 __FUNCTION__, CURRENT_THREAD, process->pid, cycle );
     1672__FUNCTION__, CURRENT_THREAD, process, cycle );
    17521673#endif
    17531674
     
    17661687    // get cluster and local pointer on process
    17671688    process_cxy = GET_CXY( process_xp );
    1768     process_ptr = (process_t *)GET_PTR( process_xp );
     1689    process_ptr = GET_PTR( process_xp );
    17691690
    17701691    // get extended pointer on stdin pseudo file
     
    17741695    txt_xp  = chdev_from_file( file_xp );
    17751696    txt_cxy = GET_CXY( txt_xp );
    1776     txt_ptr = (chdev_t *)GET_PTR( txt_xp );
     1697    txt_ptr = GET_PTR( txt_xp );
    17771698
    17781699    // set owner field in TXT chdev
     
    18041725    // get cluster and local pointer on process
    18051726    process_cxy = GET_CXY( process_xp );
    1806     process_ptr = (process_t *)GET_PTR( process_xp );
     1727    process_ptr = GET_PTR( process_xp );
    18071728
    18081729    // get extended pointer on stdin pseudo file
     
    18311752            current_ptr = GET_PTR( current_xp );
    18321753            parent_xp   = hal_remote_lwd( XPTR( current_cxy , &current_ptr->parent_xp ) );
    1833 
    18341754            parent_cxy  = GET_CXY( parent_xp );
    18351755            parent_ptr  = GET_PTR( parent_xp );
    18361756            ppid        = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
     1757
     1758printk("\n@@@ %s : pid = %x / process = %x\n", __FUNCTION__ , current_ptr->pid, current_ptr );
    18371759
    18381760            if( ppid == 1 )  // current is KSH
     
    18491771
    18501772
    1851      
     1773//////////////////////////////////////////////////////     
     1774inline pid_t process_get_txt_owner( uint32_t channel )
     1775{
     1776    xptr_t      txt_rx_xp  = chdev_dir.txt_rx[channel];
     1777    cxy_t       txt_rx_cxy = GET_CXY( txt_rx_xp );
     1778    chdev_t *   txt_rx_ptr = GET_PTR( txt_rx_xp );
     1779
     1780    xptr_t process_xp = (xptr_t)hal_remote_lwd( XPTR( txt_rx_cxy,
     1781                                                &txt_rx_ptr->ext.txt.owner_xp ) );
     1782
     1783    cxy_t       process_cxy = GET_CXY( process_xp );
     1784    process_t * process_ptr = GET_PTR( process_xp );
     1785
     1786    return (pid_t)hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) );
     1787}
     1788
     1789///////////////////////////////////////////
     1790void process_txt_display( uint32_t txt_id )
     1791{
     1792    xptr_t      chdev_xp;
     1793    cxy_t       chdev_cxy;
     1794    chdev_t   * chdev_ptr;
     1795    xptr_t      root_xp;
     1796    xptr_t      lock_xp;
     1797    xptr_t      current_xp;
     1798    xptr_t      iter_xp;
     1799
     1800    // check terminal index
     1801    assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) ,
     1802    __FUNCTION__ , "illegal TXT terminal index" );
     1803
     1804    // get pointers on TXT_RX[txt_id] chdev
     1805    chdev_xp  = chdev_dir.txt_rx[txt_id];
     1806    chdev_cxy = GET_CXY( chdev_xp );
     1807    chdev_ptr = GET_PTR( chdev_xp );
     1808
     1809    // get extended pointer on root & lock of attached process list
     1810    root_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.root );
     1811    lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock );
     1812
     1813    // display header
     1814    printk("\n***** processes attached to TXT_%d\n", txt_id );
     1815
     1816    // get lock
     1817    remote_spinlock_lock( lock_xp );
     1818
     1819    // scan attached process list to find KSH process
     1820    XLIST_FOREACH( root_xp , iter_xp )
     1821    {
     1822        current_xp  = XLIST_ELEMENT( iter_xp , process_t , txt_list );
     1823        process_display( current_xp );
     1824    }
     1825
     1826    // release lock
     1827    remote_spinlock_unlock( lock_xp );
     1828
     1829}  // end process_txt_display
  • trunk/kernel/kern/process.h

    r433 r435  
    3636#include <hal_atomic.h>
    3737#include <vmm.h>
    38 #include <signal.h>
    3938#include <cluster.h>
    4039#include <vfs.h>
     
    6362    DELETE_ALL_THREADS   = 33,
    6463};
    65 
    66 /*********************************************************************************************
    67  * The termination state is a 32 bits word:
    68  * - the 8 LSB bits contain the user defined exit status
    69  * - the 24 other bits contain the flags defined below
    70  ********************************************************************************************/
    71 
    72 #define PROCESS_FLAG_BLOCK 0x100  /*! process received as SIGSTOP signal                    */
    73 #define PROCESS_FLAG_KILL  0x200  /*! process terminated by a sys_kill()                    */
    74 #define PROCESS_FLAG_EXIT  0x400  /*! process terminated by a sys_exit()                    */
    75 #define PROCESS_FLAG_WAIT  0x800  /*! parent process executed successfully a sys_wait()     */
    7664
    7765/*********************************************************************************************
     
    291279
    292280/*********************************************************************************************
    293  * This function allows a client thread running in the owner cluster of a process identified
    294  * by the <process> argument to block, unblock or delete all threads of the target process,
    295  * depending on the <action_type> argument.  The scenario is the following:
     281 * This function allows a client thread running in any cluster to block, unblock or delete
     282 * all threads of a process identified by the <pid> argument, depending on the
     283 * <action_type> argument.  The scenario is the following:
    296284 * - It uses the multicast, non blocking rpc_process_sigaction_client() function to send
    297285 *   parallel requests to all remote clusters containing a process copy. Then it blocks
     
    305293 * It is used by the sys_kill() & sys_exit() functions to handle the "kill" & "exit" syscalls.
    306294 * It is also used by the process_make_exec() function to handle the "exec" syscall.
    307  * WARNING : the DELETE and the BLOCK actions are NOT executed on the client thread.
    308  *********************************************************************************************
    309  * @ process     : pointer on the process descriptor in owner cluster.
     295 * It is also called by the TXT device to execute the ctrl C & ctrl Z commands.
     296 * WARNING : the DELETE action is NOT executed on the main thread (thread 0 in owner cluster).
     297 *********************************************************************************************
     298 * @ pid         : target process identifier.
    310299 * @ action_type : BLOCK_ALL_THREADS / UNBLOCK_ALL_THREADS / DELETE_ALL_THREADS
    311300 ********************************************************************************************/
    312 void process_sigaction( process_t * process,
     301void process_sigaction( pid_t       pid,
    313302                        uint32_t    action_type );
    314303
     
    403392                            struct thread_s ** child_thread_ptr );
    404393
    405 /*********************************************************************************************
    406  * This function is called by both the sys_kill() and sys_exit() system calls.
    407  * It must be executed by an RPC thread running in the target process owner cluster.
    408  * It uses twice the process_sigaction() function:
    409  * - first, to block all target process threads, in all clusters.
    410  * - second, to delete all target process threads in all clusters.
    411  * Finally, it synchronizes with the parent process sys_wait() function that MUST be called
    412  * by the parent process main thread.
    413  *********************************************************************************************
    414  * @ process      : pointer on process descriptor in owner cluster.
    415  * @ is_exit      : true when called by sys_exit() / false when called by sys_kill().
    416  * @ exit_status  : exit status, when called by sys_exit().
    417  ********************************************************************************************/
    418 void process_make_kill( process_t * process,
    419                         bool_t      is_exit,
    420                         uint32_t    exit_status );
    421 
    422394
    423395/********************   File Management Operations   ****************************************/
     
    573545void process_txt_reset_ownership( xptr_t process_xp );
    574546
     547/*********************************************************************************************
     548 * This function returns the terminal owner process (foreground process)
     549 * for a given TXT terminal identified by its <channel> index.
     550 *********************************************************************************************
     551 * @ channel  : TXT terminal channel.
     552 * @ return owner process identifier.
     553 ********************************************************************************************/
     554pid_t process_get_txt_owner( uint32_t channel );
     555
     556/*********************************************************************************************
     557 * This debug function diplays on the kernel terminal the list of processes attached
     558 * to a given terminal identified by the <txt_id> argument.
     559 *********************************************************************************************
     560 * @ txt_id  : TXT terminal channel.
     561 ********************************************************************************************/
     562void process_txt_display( uint32_t txt_id );
     563
     564
    575565#endif  /* _PROCESS_H_ */
  • trunk/kernel/kern/rpc.c

    r433 r435  
    3939#include <vfs.h>
    4040#include <fatfs.h>
    41 #include <signal.h>
    4241#include <rpc.h>
    4342
     
    8079    &rpc_process_make_fork_server,      // 3
    8180    &rpc_undefined,                     // 4    unused slot
    82     &rpc_process_make_kill_server,      // 5
     81    &rpc_undefined,                     // 5    unused slot
    8382    &rpc_thread_user_create_server,     // 6
    8483    &rpc_thread_kernel_create_server,   // 7
     
    610609
    611610/////////////////////////////////////////////////////////////////////////////////////////
    612 // [5]      Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking)
    613 /////////////////////////////////////////////////////////////////////////////////////////
    614 
    615 ///////////////////////////////////////////////////
    616 void rpc_process_make_kill_client( cxy_t       cxy,
    617                                    process_t * process,
    618                                    bool_t      is_exit,
    619                                    uint32_t    status )
    620 {
    621 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    622 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    623 CURRENT_THREAD->core->lid , hal_time_stamp() );
    624 
    625     // initialise RPC descriptor header
    626     rpc_desc_t  rpc;
    627     rpc.index    = RPC_PROCESS_MAKE_KILL;
    628     rpc.response = 1;
    629     rpc.blocking = true;
    630 
    631     // set input arguments in RPC descriptor 
    632     rpc.args[0] = (uint64_t)(intptr_t)process;
    633     rpc.args[1] = (uint64_t)is_exit;
    634     rpc.args[2] = (uint64_t)status;
    635 
    636     // register RPC request in remote RPC fifo (blocking function)
    637     rpc_send( cxy , &rpc );
    638 
    639 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    640 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    641 CURRENT_THREAD->core->lid , hal_time_stamp() );
    642 
    643 
    644 //////////////////////////////////////////////
    645 void rpc_process_make_kill_server( xptr_t xp )
    646 {
    647 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    648 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    649 CURRENT_THREAD->core->lid , hal_time_stamp() );
    650 
    651     process_t * process;
    652     bool_t      is_exit;
    653     uint32_t    status;
    654 
    655     // get client cluster identifier and pointer on RPC descriptor
    656     cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
    657     rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
    658 
    659     // get arguments from RPC descriptor
    660     process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
    661     is_exit = (bool_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
    662     status  = (uint32_t)             hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
    663 
    664     // call local kernel function
    665     process_make_kill( process , is_exit , status );
    666 
    667 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    668 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    669 CURRENT_THREAD->core->lid , hal_time_stamp() );
    670 }
     611// [5]      undefined slot
     612/////////////////////////////////////////////////////////////////////////////////////////
    671613
    672614/////////////////////////////////////////////////////////////////////////////////////////
     
    906848                                   rpc_desc_t * rpc_ptr )
    907849{
    908 sigaction_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",
     850rpc_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",
    909851__FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) ,
    910852((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() );
     
    913855    rpc_send( cxy , rpc_ptr );
    914856
    915 sigaction_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",
     857rpc_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",
    916858__FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) ,
    917859((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() );
     
    921863void rpc_process_sigaction_server( xptr_t xp )
    922864{
     865    pid_t        pid;              // target process identifier
    923866    process_t  * process;          // pointer on local process descriptor
    924867    uint32_t     action;           // sigaction index
     
    934877
    935878    // get arguments from RPC descriptor
    936     action      = (uint32_t)             hal_remote_lwd( XPTR( client_cxy , &rpc->args[0] ) );
    937     process     = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) );
     879    action      = (uint32_t)  hal_remote_lwd( XPTR( client_cxy , &rpc->args[0] ) );
     880    pid         = (pid_t)     hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) );
    938881    client_ptr  = (thread_t *)hal_remote_lpt( XPTR( client_cxy , &rpc->thread ) );
     882
     883rpc_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n",
     884__FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() );
     885
     886    // get local process descriptor
     887    process = process_get_local_copy( pid );
    939888
    940889    // build extended pointer on client thread
    941890    client_xp = XPTR( client_cxy , client_ptr );
    942 
    943 sigaction_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n",
    944 __FUNCTION__ , process_action_str( action ) , process->pid , (uint32_t)hal_get_cycles() );
    945891
    946892    // call relevant kernel function
     
    958904    }
    959905
    960 sigaction_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n",
    961 __FUNCTION__ , process_action_str( action ) , process->pid , (uint32_t)hal_get_cycles() );
     906rpc_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n",
     907__FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() );
    962908}
    963909
  • trunk/kernel/kern/rpc.h

    r433 r435  
    3232#include <vseg.h>
    3333#include <remote_fifo.h>
    34 #include <signal.h>
    3534
    3635/**** Forward declarations ****/
     
    6564    RPC_PROCESS_MAKE_FORK      = 3,
    6665    RPC_UNDEFINED_4            = 4,
    67     RPC_PROCESS_MAKE_KILL      = 5,
     66    RPC_UNDEFINED_5            = 5,
    6867    RPC_THREAD_USER_CREATE     = 6,
    6968    RPC_THREAD_KERNEL_CREATE   = 7,
     
    242241
    243242/***********************************************************************************
    244  * [5] The RPC_PROCESS_MAKE_KILL can be called by any thread to request the owner
    245  * cluster to execute the process_make_kill() function for a target process.
    246  ***********************************************************************************
    247  * @ cxy      : owner cluster identifier.
    248  * @ process  : pointer on process in owner cluster.
    249  * @ is_exit  : true if called by sys_exit() / false if called by sys_kill()
    250  * @ status   : exit status (only when called by sys_exit()
    251  **********************************************************************************/
    252 void rpc_process_make_kill_client( cxy_t              cxy,
    253                                    struct process_s * process,
    254                                    bool_t             is_exit,
    255                                    uint32_t           status );
    256 
    257 void rpc_process_make_kill_server( xptr_t xp );
     243 * [5] undefined slot
     244 **********************************************************************************/
    258245
    259246/***********************************************************************************
     
    314301/***********************************************************************************
    315302 * [9] The RPC_PROCESS_SIGACTION allows the owner cluster to request any other
    316  * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all threads
    317  * of a given process.
     303 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all
     304 * threads of a given process.
    318305 *
    319306 * WARNING : It is implemented as a NON BLOCKING multicast RPC, that can be sent
  • trunk/kernel/kern/scheduler.c

    r433 r435  
    280280    }
    281281
    282     // enter critical section / save SR in current thread context
    283     hal_disable_irq( &current->save_sr );
     282    // enter critical section / save SR in current thread descriptor
     283    hal_disable_irq( &CURRENT_THREAD->save_sr );
    284284
    285285    // loop on threads to select next thread
     
    321321        }
    322322
    323         // switch CPU from calling thread context to new thread context
     323        // switch CPU from current thread context to new thread context
    324324        hal_do_cpu_switch( current->cpu_context, next->cpu_context );
    325325    }
     
    330330uint32_t cycle = (uint32_t)hal_get_cycles();
    331331if( CONFIG_DEBUG_SCHED_YIELD < cycle )
    332 printk("\n[DBG] %s : core[%x,%d] / cause = %s / thread %x (%s) (%x,%x) continue / cycle %d\n",
     332printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
     333"      thread %x (%s) (%x,%x) continue / cycle %d\n",
    333334__FUNCTION__, local_cxy, core->lid, cause,
    334335current, thread_type_str(current->type), current->process->pid, current->trdid, cycle );
     
    340341    sched_handle_signals( core );
    341342
    342     // exit critical section / restore SR from next thread context
    343     hal_restore_irq( next->save_sr );
     343    // exit critical section / restore SR from current thread descriptor
     344    hal_restore_irq( CURRENT_THREAD->save_sr );
    344345
    345346}  // end sched_yield()
  • trunk/kernel/kern/signal.h

    r409 r435  
    2828
    2929#include <hal_types.h>
    30 
    31 #define SIG_DEFAULT    (void*)0L
    32 #define SIG_IGNORE     (void*)1L
    33 #define SIG_ERROR     -1L
    34 
    35 #define SIGHUP     1       /*! hangup                                                     */
    36 #define SIGINT     2       /*! interrupt                                                  */
    37 #define SIGQUIT    3       /*! quit                                                       */
    38 #define SIGILL     4       /*! illegal instruction (not reset when caught)                */
    39 #define SIGTRAP    5       /*! trace trap (not reset when caught)                         */
    40 #define SIGIOT     6       /*! IOT instruction                                            */
    41 #define SIGABRT    6       /*! used by abort, replace SIGIOT in the future                */
    42 #define SIGEMT     7       /*! EMT instruction                                            */
    43 #define SIGFPE     8       /*! floating point exception                                   */
    44 #define SIGKILL    9       /*! kill (cannot be caught or ignored)                         */
    45 #define SIGBUS     10      /*! bus error                                                  */
    46 #define SIGSEGV    11      /*! segmentation violation                                     */
    47 #define SIGSYS     12      /*! bad argument to system call                                */
    48 #define SIGPIPE    13      /*! write on a pipe with no one to read it                     */
    49 #define SIGALRM    14      /*! alarm clock                                                */
    50 #define SIGTERM    15      /*! software termination signal from kill                      */
    51 #define SIGURG     16      /*! urgent condition on IO channel                             */
    52 #define SIGSTOP    17      /*! sendable stop signal not from tty                          */
    53 #define SIGTSTP    18      /*! stop signal from tty                                       */
    54 #define SIGCONT    19      /*! continue a stopped process                                 */
    55 #define SIGCHLD    20      /*! to parent on child stop or exit                            */
    56 #define SIGCLD     20      /*! System V name for SIGCHLD                                  */
    57 #define SIGTTIN    21      /*! to readers pgrp upon background tty read                   */
    58 #define SIGTTOU    22      /*! like TTIN for output if (tp->t_local&LTOSTOP)              */
    59 #define SIGIO      23      /*! input/output possible signal                               */
    60 #define SIGPOLL    SIGIO   /*! System V name for SIGIO                                    */
    61 #define SIGXCPU    24      /*! exceeded CPU time limit                                    */
    62 #define SIGXFSZ    25      /*! exceeded file size limit                                   */
    63 #define SIGVTALRM  26      /*! virtual time alarm                                         */
    64 #define SIGPROF    27      /*! profiling time alarm                                       */
    65 #define SIGWINCH   28      /*! window changed                                             */
    66 #define SIGLOST    29      /*! resource lost (eg, record-lock lost)                       */
    67 #define SIGUSR1    30      /*! user defined signal 1                                      */
    68 #define SIGUSR2    31      /*! user defined signal 2                                      */
    69 #define SIG_NR     32      /*! signal 0 implied                                           */
    70 
    71 #define SIG_DEFAULT_MASK         0xFFEEFFFF
    7230
    7331
  • trunk/kernel/libk/xlist.h

    r24 r435  
    7272 * extended double linked list, identified by the extended pointer on
    7373 * the root xlist_entry_t.
     74 * WARNING : check list non empty before using this macro.
    7475 * @ root_xp : extended pointer on the root xlist_entry_t
    7576 * @ type    : type of the linked elements
     
    8586 * extended double linked list, identified by the extended pointer on
    8687 * the root xlist_entry_t.
     88 * WARNING : check list non empty before using this macro.
    8789 * @ root_xp : extended pointer on the root xlist_entry_t
    8890 * @ type    : type of the linked elements
  • trunk/kernel/mm/kcm.c

    r433 r435  
    4848{
    4949
    50 #if CONFIG_DEBUG_KCM_ALLOC
     50#if CONFIG_DEBUG_KCM
    5151uint32_t cycle = (uint32_t)hal_get_cycles();
    52 if( CONFIG_DEBUG_KCM_ALLOC < cycle )
     52if( CONFIG_DEBUG_KCM < cycle )
    5353printk("\n[DBG] %s : thread %x enters for %s / page %x / count %d / active %d\n",
    5454__FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) ,
     
    8585                     + (index * kcm->block_size) );
    8686
    87 #if CONFIG_DEBUG_KCM_ALLOC
     87#if CONFIG_DEBUG_KCM
    8888cycle = (uint32_t)hal_get_cycles();
    89 if( CONFIG_DEBUG_KCM_ALLOC < cycle )
     89if( CONFIG_DEBUG_KCM < cycle )
    9090printk("\n[DBG] %s : thread %x exit / type  %s / ptr %p / page %x / count %d\n",
    9191__FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) , ptr ,
  • trunk/kernel/mm/kmem.c

    r433 r435  
    145145        assert( ((type > 1) && (type < KMEM_TYPES_NR) ) , __FUNCTION__ , "illegal KCM type" );
    146146
    147         kmem_dmsg("\n[DBG] %s : enters / KCM type %s missing in cluster %x\n",
    148                   __FUNCTION__ , kmem_type_str( type ) , local_cxy );
     147#if CONFIG_DEBUG_KMEM
     148uint32_t cycle = (uint32_t)hal_get_cycles();
     149if( CONFIG_DEBUG_KMEM < cycle )
     150printk("\n[DBG] %s : thread %x enter / KCM type %s missing in cluster %x / cycle %d\n",
     151__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle );
     152#endif
    149153
    150154        cluster_t * cluster = LOCAL_CLUSTER;
     
    169173        hal_fence();
    170174
    171         kmem_dmsg("\n[DBG] %s : exit / KCM type %s created in cluster %x\n",
    172                   __FUNCTION__ , kmem_type_str( type ) , local_cxy );
     175#if CONFIG_DEBUG_KMEM
     176cycle = (uint32_t)hal_get_cycles();
     177if( CONFIG_DEBUG_KMEM < cycle )
     178printk("\n[DBG] %s : thread %x exit / cycle %d\n",
     179__FUNCTION__, CURRENT_THREAD, cycle );
     180#endif
    173181
    174182        return 0;
     
    192200        assert( (type < KMEM_TYPES_NR) , __FUNCTION__ , "illegal KMEM request type" );
    193201
    194         kmem_dmsg("\n[DBG] %s : enters in cluster %x for type %s\n",
    195                       __FUNCTION__ , local_cxy , kmem_type_str( type ) );
     202#if CONFIG_DEBUG_KMEM
     203uint32_t cycle = (uint32_t)hal_get_cycles();
     204if( CONFIG_DEBUG_KMEM < cycle )
     205printk("\n[DBG] %s : thread %x enter / type %s / cluster %x / cycle %d\n",
     206__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle );
     207#endif
    196208
    197209        // analyse request type
    198210        if( type == KMEM_PAGE )                        // PPM allocator
    199211        {
    200 
    201 #if CONFIG_DEBUG_KMEM_ALLOC
    202 if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() )
    203 printk("\n[DBG] in %s : thread %x enter for %d page(s)\n",
    204 __FUNCTION__ , CURRENT_THREAD , 1<<size );
    205 #endif
    206 
    207212                // allocate the number of requested pages
    208213                ptr = (void *)ppm_alloc_pages( size );
     
    217222                if( flags & AF_ZERO ) page_zero( (page_t *)ptr );
    218223
    219                 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / page = %x / base = %x\n",
    220                           __FUNCTION__, local_cxy , kmem_type_str( type ) ,
    221                           (intptr_t)ptr , (intptr_t)ppm_page2base( ptr ) );
    222 
    223 #if CONFIG_DEBUG_KMEM_ALLOC
    224 if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() )
    225 printk("\n[DBG] in %s : thread %x exit / %d page(s) allocated / ppn = %x\n",
    226 __FUNCTION__ , CURRENT_THREAD , 1<<size , ppm_page2ppn( XPTR( local_cxy , ptr ) ) );
     224#if CONFIG_DEBUG_KMEM
     225cycle = (uint32_t)hal_get_cycles();
     226if( CONFIG_DEBUG_KMEM < cycle )
     227printk("\n[DBG] %s : thread %x exit / %d page(s) allocated / ppn %x / cycle %d\n",
     228__FUNCTION__, CURRENT_THREAD, 1<<size, ppm_page2ppn(XPTR(local_cxy,ptr)), cycle );
    227229#endif
    228230
     
    242244                if( flags & AF_ZERO ) memset( ptr , 0 , size );
    243245
    244                 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n",
    245                           __FUNCTION__, local_cxy , kmem_type_str( type ) ,
    246                           (intptr_t)ptr , req->size );
     246#if CONFIG_DEBUG_KMEM
     247cycle = (uint32_t)hal_get_cycles();
     248if( CONFIG_DEBUG_KMEM < cycle )
     249printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n",
     250__FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), (intptr_t)ptr, size, cycle );
     251#endif
     252
    247253        }
    248254        else                                           // KCM allocator
     
    269275                if( flags & AF_ZERO ) memset( ptr , 0 , kmem_type_size( type ) );
    270276
    271                 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n",
    272                           __FUNCTION__, local_cxy , kmem_type_str( type ) ,
    273                           (intptr_t)ptr , kmem_type_size( type ) );
     277#if CONFIG_DEBUG_KMEM
     278cycle = (uint32_t)hal_get_cycles();
     279if( CONFIG_DEBUG_KMEM < cycle )
     280printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n",
     281__FUNCTION__, CURRENT_THREAD, kmem_type_str(type), (intptr_t)ptr,
     282kmem_type_size(type), cycle );
     283#endif
     284
    274285        }
    275286
  • trunk/kernel/mm/mapper.c

    r408 r435  
    143143    error_t       error;
    144144
    145 mapper_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper %x\n",
    146 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , mapper );
     145#if CONFIG_DEBUG_MAPPER_GET_PAGE
     146uint32_t cycle = (uint32_t)hal_get_cycles();
     147if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
     148printk("\n[DBG] %s : thread %x enter for page %d / mapper %x / cycle %d\n",
     149__FUNCTION__ , CURRENT_THREAD , index , mapper , cycle );
     150#endif
    147151
    148152    thread_t * this = CURRENT_THREAD;
     
    171175        {
    172176
    173 mapper_dmsg("\n[DBG] %s : core[%x,%d] missing page => load from device\n",
    174 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid );
    175 
     177#if (CONFIG_DEBUG_MAPPER_GET_PAGE & 1)
     178if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
     179printk("\n[DBG] %s : missing page => load from device\n", __FUNCTION__ );
     180#endif
    176181            // allocate one page from PPM
    177182            req.type  = KMEM_PAGE;
     
    230235            // reset the page INLOAD flag to make the page available to all readers
    231236            page_clear_flag( page , PG_INLOAD );
    232 
    233 mapper_dmsg("\n[DBG] %s : missing page loaded / ppn = %x\n",
    234 __FUNCTION__ , ppm_page2ppn(XPTR(local_cxy,page)) );
    235 
    236237        }
    237238        else if( page_is_flag( page , PG_INLOAD ) )   // page is loaded by another thread
     
    256257    }
    257258
    258 mapper_dmsg("\n[DBG] %s : exit for page %d / mapper %x / page_desc = %x\n",
    259 __FUNCTION__ , index , mapper , page );
     259#if CONFIG_DEBUG_MAPPER_GET_PAGE
     260cycle = (uint32_t)hal_get_cycles();
     261if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle )
     262printk("\n[DBG] %s : thread %x exit for page %d / ppn %x / cycle %d\n",
     263__FUNCTION__, CURRENT_THREAD, index, ppm_page2ppn(XPTR(local_cxy, page)), cycle );
     264#endif
    260265
    261266    return page;
     
    312317    uint8_t  * buf_ptr;        // current buffer  address
    313318
    314     mapper_dmsg("\n[DBG] %s : enters / to_buf = %d / buffer = %x\n",
    315                 __FUNCTION__ , to_buffer , buffer );
     319#if CONFIG_DEBUG_MAPPER_MOVE_USER
     320uint32_t cycle = (uint32_t)hal_get_cycles();
     321if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
     322printk("\n[DBG] %s : thread %x enter / to_buf %d / buffer %x / cycle %d\n",
     323__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle );
     324#endif
    316325
    317326    // compute offsets of first and last bytes in file
     
    338347        else                       page_count = CONFIG_PPM_PAGE_SIZE;
    339348
    340         mapper_dmsg("\n[DBG] %s : index = %d / offset = %d / count = %d\n",
    341                     __FUNCTION__ , index , page_offset , page_count );
     349#if (CONFIG_DEBUG_MAPPER_MOVE_USER & 1)
     350if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
     351printk("\n[DBG] %s : index = %d / offset = %d / count = %d\n",
     352__FUNCTION__ , index , page_offset , page_count );
     353#endif
    342354
    343355        // get page descriptor
     
    353365        buf_ptr = (uint8_t *)buffer + done;
    354366
    355         mapper_dmsg("\n[DBG] %s : index = %d / buf_ptr = %x / map_ptr = %x\n",
    356                     __FUNCTION__ , index , buf_ptr , map_ptr );
    357 
    358367        // move fragment
    359368        if( to_buffer )
     
    370379    }
    371380
    372     mapper_dmsg("\n[DBG] %s : exit for buffer %x\n",
    373                 __FUNCTION__, buffer );
     381#if CONFIG_DEBUG_MAPPER_MOVE_USER
     382cycle = (uint32_t)hal_get_cycles();
     383if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle )
     384printk("\n[DBG] %s : thread %x exit / to_buf %d / buffer %x / cycle %d\n",
     385__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle );
     386#endif
    374387
    375388    return 0;
     
    399412    uint8_t * buffer_ptr = (uint8_t *)GET_PTR( buffer_xp );
    400413
    401 mapper_dmsg("\n[DBG] %s : core[%x,%d] / to_buf = %d / buf_cxy = %x / buf_ptr = %x / size = %x\n",
    402 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, to_buffer, buffer_cxy, buffer_ptr, size );
     414#if CONFIG_DEBUG_MAPPER_MOVE_KERNEL
     415uint32_t cycle = (uint32_t)hal_get_cycles();
     416if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
     417printk("\n[DBG] %s : thread %x enter / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
     418__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle );
     419#endif
    403420
    404421    // compute offsets of first and last bytes in file
     
    410427    uint32_t last  = max_byte >> CONFIG_PPM_PAGE_SHIFT;
    411428
    412 mapper_dmsg("\n[DBG] %s : core[%x,%d] / first_page = %d / last_page = %d\n",
    413 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first, last );
     429#if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1)
     430if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
     431printk("\n[DBG] %s : first_page %d / last_page %d\n", __FUNCTION__, first, last );
     432#endif
    414433
    415434    // compute source and destination clusters
     
    440459        else                       page_count = CONFIG_PPM_PAGE_SIZE;
    441460
    442 mapper_dmsg("\n[DBG] %s : core[%x;%d] / page_index = %d / offset = %d / bytes = %d\n",
    443 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, index, page_offset, page_count );
     461#if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1)
     462if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
     463printk("\n[DBG] %s : page_index = %d / offset = %d / bytes = %d\n",
     464__FUNCTION__ , index , page_offset , page_count );
     465#endif
    444466
    445467        // get page descriptor
     
    472494    }
    473495
    474 mapper_dmsg("\n[DBG] %s : core_cxy[%x,%d] / exit / buf_cxy = %x / buf_ptr = %x / size = %x\n",
    475 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, buffer_cxy, buffer_ptr, size );
     496#if CONFIG_DEBUG_MAPPER_MOVE_KERNEL
     497cycle = (uint32_t)hal_get_cycles();
     498if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle )
     499printk("\n[DBG] %s : thread %x exit / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n",
     500__FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle );
     501#endif
    476502
    477503    return 0;
  • trunk/kernel/mm/vmm.c

    r433 r435  
    16431643#if CONFIG_DEBUG_VMM_GET_PTE
    16441644uint32_t cycle = (uint32_t)hal_get_cycles();
    1645 if( CONFIG_DEBUG_VMM_GET_PTE > cycle )
     1645if( CONFIG_DEBUG_VMM_GET_PTE < cycle )
    16461646printk("\n[DBG] %s : thread %x enter for vpn = %x / process %x / cow = %d / cycle %d\n",
    16471647__FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cow , cycle );
     
    18001800    error_t          error;
    18011801
     1802#if CONFIG_DEBUG_VMM_GET_PTE
     1803uint32_t cycle = (uint32_t)hal_get_cycles();
     1804if( CONFIG_DEBUG_VMM_GET_PTE < cycle )
     1805printk("\n[DBG] %s : thread %x enter for vpn %x / process %x / cycle %d\n",
     1806__FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle );
     1807#endif
     1808
    18021809    // get reference process cluster and local pointer
    18031810    cxy_t       ref_cxy = GET_CXY( process->ref_xp );
     
    18331840    }
    18341841
     1842#if CONFIG_DEBUG_VMM_GET_PTE
     1843cycle = (uint32_t)hal_get_cycles();
     1844if( CONFIG_DEBUG_VMM_GET_PTE < cycle )
     1845printk("\n[DBG] %s : thread %x exit for vpn %x / process %x / cycle %d\n",
     1846__FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle );
     1847#endif
     1848
    18351849    return error;
    18361850
     
    18451859    error_t          error;
    18461860
     1861#if CONFIG_DEBUG_VMM_GET_PTE
     1862uint32_t cycle = (uint32_t)hal_get_cycles();
     1863if( CONFIG_DEBUG_VMM_GET_PTE < cycle )
     1864printk("\n[DBG] %s : thread %x enter for vpn %x / process %x / cycle %d\n",
     1865__FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle );
     1866#endif
    18471867   
    18481868    // get reference process cluster and local pointer
     
    18791899    }
    18801900
     1901#if CONFIG_DEBUG_VMM_GET_PTE
     1902cycle = (uint32_t)hal_get_cycles();
     1903if( CONFIG_DEBUG_VMM_GET_PTE < cycle )
     1904printk("\n[DBG] %s : thread %x exit for vpn %x / process %x / cycle %d\n",
     1905__FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle );
     1906#endif
     1907
    18811908    return error;
    18821909
  • trunk/kernel/syscalls/shared_syscalls.h

    r421 r435  
    321321typedef enum
    322322{
    323     DISPLAY_STRING  = 0,
    324     DISPLAY_VMM     = 1,
    325     DISPLAY_SCHED   = 2,
    326     DISPLAY_PROCESS = 3,
    327     DISPLAY_VFS     = 4,
    328     DISPLAY_CHDEV   = 5,
     323    DISPLAY_STRING            = 0,
     324    DISPLAY_VMM               = 1,
     325    DISPLAY_SCHED             = 2,
     326    DISPLAY_CLUSTER_PROCESSES = 3,
     327    DISPLAY_VFS               = 4,
     328    DISPLAY_CHDEV             = 5,
     329    DISPLAY_TXT_PROCESSES     = 6,
    329330}
    330331display_type_t;
     
    391392
    392393
     394/*********************************************************************************************
     395 * These macros can be used by the parent process to analyze a child process
     396 * termination status, as returned by the wait() syscall.
     397 * The termination state is a 32 bits word:
     398 * - the 8 LSB bits contain the user defined exit status
     399 * - the 24 other bits contain the flags defined below
     400 ********************************************************************************************/
     401
     402#define PROCESS_TERM_STOP  0x100            /*! process received a SIGSTOP signal           */
     403#define PROCESS_TERM_KILL  0x200            /*! process killed by a SIGKILL signal          */
     404#define PROCESS_TERM_EXIT  0x400            /*! process terminated by a sys_exit()          */
     405#define PROCESS_TERM_WAIT  0x800            /*! parent process executed a sys_wait()        */
     406
     407#define WIFEXITED( status )       (status & PROCESS_TERM_EXIT)
     408#define WIFSIGNALED( status )     (status & PROCESS_TERM_KILL)
     409#define WIFSTOPPED( status )      (status & PROCESS_TERM_STOP)
     410#define WEXITSTATUS( status )     (status & 0xFF)
     411
    393412
    394413#endif  // _SHARED_SYSCALLS_H_
  • trunk/kernel/syscalls/sys_display.c

    r433 r435  
    142142        }
    143143    }
    144     else if( type == DISPLAY_PROCESS )
     144    else if( type == DISPLAY_CLUSTER_PROCESSES )
    145145    {
    146146        cxy_t cxy = (cxy_t)arg0;
     
    155155
    156156        cluster_processes_display( cxy );
     157    }
     158    else if( type == DISPLAY_TXT_PROCESSES )
     159    {
     160        uint32_t txt_id = (uint32_t)arg0;
     161
     162        // check argument
     163            if( txt_id >= LOCAL_CLUSTER->nb_txt_channels )
     164        {
     165            printk("\n[ERROR] in %s : undefined TXT channel %x\n",
     166            __FUNCTION__ , txt_id );
     167            return -1;
     168        }
     169
     170        process_txt_display( txt_id );
    157171    }
    158172    else if( type == DISPLAY_VFS )
  • trunk/kernel/syscalls/sys_exec.c

    r433 r435  
    221221printk("\n[ERROR] in %s : cannot access args\n", __FUNCTION__ );
    222222#endif
    223             this->errno = error;
     223            this->errno = EINVAL;
    224224            return -1;
    225225        }
     
    235235printk("\n[ERROR] in %s : cannot access envs\n", __FUNCTION__ );
    236236#endif
    237             this->errno = error;
     237            this->errno = EINVAL;
    238238            return -1;
    239239        }
     
    248248#if CONFIG_DEBUG_SYSCALLS_ERROR
    249249printk("\n[ERROR] in %s : cannot create process %x in cluster %x\n",
    250 __FUNCTION__, pid, CXY_FROM_PID( pid );
     250__FUNCTION__, pid, CXY_FROM_PID(pid) );
    251251#endif
    252252        this->errno = error;
  • trunk/kernel/syscalls/sys_exit.c

    r433 r435  
    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>
     
    5151#endif
    5252
    53     // get cluster and pointers on process in owner cluster
    54     xptr_t      owner_xp  = cluster_get_owner_process_from_pid( pid );
    55     cxy_t       owner_cxy = GET_CXY( owner_xp );
    56     process_t * owner_ptr = GET_PTR( owner_xp );
     53    // get owner cluster
     54    cxy_t  owner_cxy = CXY_FROM_PID( pid );
    5755
    58     assert( (owner_xp != XPTR_NULL) , __FUNCTION__ , "owner_xp cannot be NULL\n" );
     56    // exit must be called by the main thread
     57    if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID( this->trdid ) != 0) )
     58    {
     59
     60#if CONFIG_DEBUG_SYSCALLS_ERROR
     61printk("\n[ERROR] %s must be called by thread 0 in process owner cluster\n"
     62       "         trdid = %x / pid = %x / local_cxy = %x\n",
     63__FUNCTION__, this->trdid, pid, local_cxy );
     64#endif
     65         this->errno = EINVAL;
     66         return -1;
     67    }
    5968
    6069    // enable IRQs
    6170    hal_enable_irq( &save_sr );
    6271
    63     // the process_make_kill() function must be executed
    64     // by an RPC thread in reference cluster
    65     rpc_process_make_kill_client( owner_cxy, owner_ptr, true , status );
     72    // register exit_status in owner process descriptor
     73    process->term_state = status;
     74
     75    // remove TXT ownership from owner process descriptor
     76    process_txt_reset_ownership( XPTR( local_cxy , process ) );
     77
     78    // block all process threads in all clusters
     79    process_sigaction( pid , BLOCK_ALL_THREADS );
     80
     81    // mark all process threads in all clusters for delete
     82    process_sigaction( pid , DELETE_ALL_THREADS );
    6683
    6784    // restore IRQs
    6885    hal_restore_irq( save_sr );
    6986
     87    // atomically update owner process descriptor term_state
     88    hal_remote_atomic_or( XPTR( local_cxy , &process->term_state ) ,
     89                          PROCESS_TERM_EXIT );
    7090    hal_fence();
    7191
  • trunk/kernel/syscalls/sys_fork.c

    r433 r435  
    8181    if( hal_remote_atomic_add( children_xp , 1 ) >= CONFIG_PROCESS_MAX_CHILDREN )
    8282        {
    83             printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__);
     83
     84#if CONFIG_DEBUG_SYSCALLS_ERROR
     85printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__);
     86#endif
    8487            hal_remote_atomic_add ( children_xp , -1 );
    8588        parent_thread_ptr->errno = EAGAIN;
     
    119122    if( error )
    120123    {
    121         printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n",
    122         __FUNCTION__, parent_pid, local_cxy );
     124
     125#if CONFIG_DEBUG_SYSCALLS_ERROR
     126printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n",
     127__FUNCTION__, parent_pid, local_cxy );
     128#endif
    123129        parent_thread_ptr->errno = EAGAIN;
    124130        return -1;
  • trunk/kernel/syscalls/sys_get_config.c

    r421 r435  
    3535int sys_get_config( uint32_t * x_size,
    3636                    uint32_t * y_size,
    37                     uint32_t * y_width,
    3837                    uint32_t * ncores )
    3938{
     
    4140    uint32_t  k_x_size;
    4241    uint32_t  k_y_size;
    43     uint32_t  k_y_width;
    4442    uint32_t  k_ncores;
    4543
     
    4947    process_t * process = this->process;
    5048
     49#if CONFIG_DEBUG_SYS_GET_CONFIG
     50uint64_t     tm_start;
     51uint64_t     tm_end;
     52tm_start = hal_get_cycles();
     53if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_start )
     54printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
     55__FUNCTION__, this, process->pid, (uint32_t)tm_start );
     56#endif
     57
    5158    // check buffer in user space
    5259    error |= vmm_v2p_translate( false , x_size  , &paddr );
    5360    error |= vmm_v2p_translate( false , y_size  , &paddr );
    54     error |= vmm_v2p_translate( false , y_width , &paddr );
    5561    error |= vmm_v2p_translate( false , ncores  , &paddr );
    5662
    5763        if( error )
    5864        {
    59         printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n",
    60                __FUNCTION__ , this->trdid , process->pid );
     65
     66#if CONFIG_DEBUG_SYSCALLS_ERROR
     67printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n",
     68__FUNCTION__ , this->trdid , process->pid );
     69#endif
    6170        this->errno = EFAULT;
    6271                return -1;
     
    6675        k_x_size  = LOCAL_CLUSTER->x_size;
    6776        k_y_size  = LOCAL_CLUSTER->y_size;
    68         k_y_width = LOCAL_CLUSTER->y_width;
    6977        k_ncores  = LOCAL_CLUSTER->cores_nr;
    7078
     
    7280        hal_copy_to_uspace( x_size  , &k_x_size  , sizeof(uint32_t) );
    7381        hal_copy_to_uspace( y_size  , &k_y_size  , sizeof(uint32_t) );
    74         hal_copy_to_uspace( y_width , &k_y_width , sizeof(uint32_t) );
    7582        hal_copy_to_uspace( ncores  , &k_ncores  , sizeof(uint32_t) );
     83
     84    hal_fence();
     85
     86#if CONFIG_DEBUG_SYS_GET_CONFIG
     87tm_end = hal_get_cycles();
     88if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_end )
     89printk("\n[DBG] %s : thread %x exit / process %x / cost %d / tycle %d\n",
     90__FUNCTION__, this, process->pid, (uint32_t)(tm_end-tm_start), (uint32_t)tm_end );
     91#endif
    7692
    7793        return 0;
  • trunk/kernel/syscalls/sys_kill.c

    r433 r435  
    4848
    4949    thread_t  * this    = CURRENT_THREAD;
     50    process_t * process = this->process;
    5051
    5152#if CONFIG_DEBUG_SYS_KILL
     
    5859#endif
    5960
    60     // get cluster and pointers on owner process
     61    // process cannot kill itself
     62    if( pid == process->pid )
     63    {
     64
     65#if CONFIG_DEBUG_SYSCALLS_ERROR
     66printk("\n[ERROR] in %s : process %d cannot kill itself\n", __FUNCTION__ , pid );
     67#endif
     68        this->errno = EINVAL;
     69        return -1;
     70    }
     71
     72    // get cluster and pointers on owner target process descriptor
    6173    owner_xp  = cluster_get_owner_process_from_pid( pid );
    6274    owner_cxy = GET_CXY( owner_xp );
     
    6779    {
    6880
    69 syscall_dmsg("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid );
    70 
     81#if CONFIG_DEBUG_SYSCALLS_ERROR
     82printk("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid );
     83#endif
    7184        this->errno = EINVAL;
    7285        return -1;
     
    7992    ppid       = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
    8093
    81     // processes INIT and processes KSH cannot be stoped or killed
    82     if( ppid < 2 )
     94    // processes INIT
     95    if( pid == 1 )
    8396    {
    8497
    85 syscall_dmsg("\n[ERROR] in %s : process %x cannot be killed\n", __FUNCTION__ , pid );
    86 
     98#if CONFIG_DEBUG_SYSCALLS_ERROR
     99printk("\n[ERROR] in %s : process_init cannot be killed\n", __FUNCTION__ );
     100#endif
    87101                this->errno = EINVAL;
    88102        return -1;
     
    92106    hal_enable_irq( &save_sr );
    93107
    94     // analyse signal type
    95     // supported values are : 0, SIGSTOP, SIGCONT, SIGKILL
     108    // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL
    96109    switch( sig_id )
    97110    {
     
    108121
    109122            // block all threads in all clusters
    110             process_sigaction( owner_ptr , BLOCK_ALL_THREADS );
     123            process_sigaction( pid , BLOCK_ALL_THREADS );
    111124
    112             // atomically update reference process termination state
     125            // atomically update owner process termination state
    113126            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    114                                   PROCESS_FLAG_BLOCK );
     127                                  PROCESS_TERM_STOP );
    115128 
    116129            retval = 0;
     
    120133        {
    121134            // unblock all threads in all clusters
    122             process_sigaction( owner_ptr , UNBLOCK_ALL_THREADS );
     135            process_sigaction( pid , UNBLOCK_ALL_THREADS );
    123136
    124137            // atomically update reference process termination state
    125138            hal_remote_atomic_and( XPTR( owner_cxy , &owner_ptr->term_state ) ,
    126                                    ~PROCESS_FLAG_BLOCK );
     139                                   ~PROCESS_TERM_STOP );
    127140            retval = 0;
    128141            break;
     
    131144        case SIGKILL:
    132145        {
    133             // the process_make_kill() function must be executed
    134             // by an RPC thread in process owner cluster
    135             // It deletes all target process threads in all clusters,
    136             // and updates the process termination state
    137             rpc_process_make_kill_client( owner_cxy , owner_ptr , false , 0 );
     146            // remove TXT ownership from owner process descriptor
     147            process_txt_reset_ownership( owner_xp );
     148
     149            // block all process threads in all clusters
     150            process_sigaction( pid , BLOCK_ALL_THREADS );
     151
     152            // mark all process threads in all clusters for delete
     153            process_sigaction( pid , DELETE_ALL_THREADS );
     154
     155            // atomically update owner process descriptor flags
     156            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
     157                                  PROCESS_TERM_KILL );
    138158
    139159            retval = 0;
     
    143163        {
    144164
    145 syscall_dmsg("\n[ERROR] in %s : illegal signal type %d for process %x\n",
    146 __FUNCTION__ , sig_id , pid );
    147 
     165#if CONFIG_DEBUG_SYSCALLS_ERROR
     166printk("\n[ERROR] in %s : illegal signal %d / process %x\n", __FUNCTION__, sig_id, pid );
     167#endif
    148168            this->errno = EINVAL;
    149169            retval = -1;
  • trunk/kernel/syscalls/sys_mmap.c

    r407 r435  
    2525#include <hal_types.h>
    2626#include <hal_uspace.h>
     27#include <hal_irqmask.h>
    2728#include <shared_syscalls.h>
    2829#include <errno.h>
     
    4445    error_t       error;
    4546    paddr_t       paddr;        // unused, but required for user space checking
    46 
    47         uint64_t      tm_start;
    48         uint64_t      tm_end;
    49 
    50         tm_start = hal_get_cycles();
     47    reg_t         save_sr;      // required to enable IRQs
    5148
    5249        thread_t    * this    = CURRENT_THREAD;
    5350        process_t   * process = this->process;
    5451
     52#if CONFIG_DEBUG_SYS_MMAP
     53uint64_t      tm_start;
     54uint64_t      tm_end;
     55tm_start = hal_get_cycles();
     56if ( CONFIG_DEBUG_SYS_MMAP < tm_start )
     57printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",
     58__FUNCTION__, this, process->pid, (uint32_t)tm_start );
     59#endif
     60
    5561    // check arguments in user space
    5662    error = vmm_v2p_translate( false , attr , &paddr );
     
    5864    if ( error )
    5965    {
    60         printk("\n[ERROR] in %s : arguments not in used space = %x\n",
    61         __FUNCTION__ , (intptr_t)attr );
     66
     67#if CONFIG_DEBUG_SYSCALLS_ERROR
     68printk("\n[ERROR] in %s : arguments not in used space = %x\n", __FUNCTION__ , (intptr_t)attr );
     69#endif
    6270                this->errno = EINVAL;
    6371                return -1;
     
    8290    if( map_fixed )
    8391    {
    84         printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ );
     92
     93#if CONFIG_DEBUG_SYSCALLS_ERROR
     94printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ );
     95#endif
    8596        this->errno = EINVAL;
    8697        return -1;
     
    89100    if( map_shared == map_private )
    90101    {
    91         printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ );
     102
     103#if CONFIG_DEBUG_SYSCALLS_ERROR
     104printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ );
     105#endif
    92106        this->errno = EINVAL;
    93107        return -1;
     
    108122                if( fdid >= CONFIG_PROCESS_FILE_MAX_NR )
    109123                {
    110                         printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid );
     124
     125#if CONFIG_DEBUG_SYSCALLS_ERROR
     126printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid );
     127#endif
    111128            this->errno = EBADFD;
    112129            return -1;
     
    118135        if( file_xp == XPTR_NULL )
    119136        {
    120                         printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid );
     137
     138#if CONFIG_DEBUG_SYSCALLS_ERROR
     139printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid );
     140#endif
    121141            this->errno = EBADFD;
    122142            return -1;
     
    138158                if( (offset + length) > size)
    139159                {
    140                         printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n",
    141                         __FUNCTION__, k_attr.offset, k_attr.length, size );
     160
     161#if CONFIG_DEBUG_SYSCALLS_ERROR
     162printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n",
     163__FUNCTION__, k_attr.offset, k_attr.length, size );
     164#endif
    142165            this->errno = ERANGE;
    143166            return -1;
     
    148171                    (prot_write && !(file_attr & FD_ATTR_WRITE_ENABLE)) )
    149172                {
    150                         printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n",
    151                         __FUNCTION__ , k_attr.prot , file_attr );
     173
     174#if CONFIG_DEBUG_SYSCALLS_ERROR
     175printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n",
     176__FUNCTION__ , k_attr.prot , file_attr );
     177#endif
    152178                        this->errno = EACCES;
    153179                        return -1;
     
    178204            if( cluster_is_undefined( vseg_cxy ) )
    179205            {
    180                 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ );
     206
     207#if CONFIG_DEBUG_SYSCALLS_ERROR
     208printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ );
     209#endif
    181210                this->errno = EINVAL;
    182211                return -1;
     
    184213        }
    185214    }
     215
     216    // enable IRQs
     217    hal_enable_irq( &save_sr );
    186218
    187219    // get reference process cluster and local pointer
     
    216248    }
    217249   
     250    // restore IRQs
     251    hal_restore_irq( save_sr );
     252
    218253    if( vseg == NULL )
    219254    {
    220         printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ );
     255
     256#if CONFIG_DEBUG_SYSCALLS_ERROR
     257printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ );
     258#endif
    221259        this->errno = ENOMEM;
    222260        return -1;
     
    226264    hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) );
    227265
    228     tm_end = hal_get_cycles();
    229 
    230 syscall_dmsg("\n[DBG] %s : core[%x,%d] created vseg %s in cluster %x / cycle %d\n"
    231 "      base = %x / length = %x / cost = %d\n",
    232 __FUNCTION__, local_cxy , this->core->lid , vseg_type_str(vseg->type) ,
    233 vseg->cxy , (uint32_t)tm_start , vseg->min , length , (uint32_t)(tm_end - tm_start) );
     266    hal_fence();
     267
     268#if CONFIG_DEBUG_SYS_MMAP
     269tm_end = hal_get_cycles();
     270if ( CONFIG_DEBUG_SYS_MMAP < tm_start )
     271printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n"
     272"vseg %s / cluster %x / base %x / size %x / cost %d\n",
     273__FUNCTION__, this, process->pid, (uint32_t)tm_end,
     274vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)(tm_end - tm_start) );
     275#endif
    234276
    235277        return 0;
  • trunk/kernel/syscalls/sys_read.c

    r433 r435  
    3636// TODO: concurrent user page(s) munmap need to be handled [AG]
    3737
    38 // TODO : remove these debug variables
    3938extern uint32_t enter_sys_read;
    4039extern uint32_t enter_devfs_move;
     
    6463    reg_t        save_sr;     // required to enable IRQs during syscall
    6564
    66 #if CONFIG_READ_DEBUG
     65#if (CONFIG_DEBUG_SYS_READ & 1)
    6766enter_sys_read = (uint32_t)tm_start;
    6867#endif
     
    7675tm_start = hal_get_cycles();
    7776if( CONFIG_DEBUG_SYS_READ < tm_start )
    78 printk("\n[DBG] %s : thread %d enter / process %x / vaddr = %x / count %d / cycle %d\n",
     77printk("\n[DBG] %s : thread %x enter / process %x / vaddr = %x / count %d / cycle %d\n",
    7978__FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start );
    8079#endif
     
    8382        if( file_id >= CONFIG_PROCESS_FILE_MAX_NR )
    8483        {
    85         printk("\n[ERROR] in %s : illegal file descriptor index = %d\n",
    86         __FUNCTION__ , file_id );
     84
     85#if CONFIG_DEBUG_SYSCALLS_ERROR
     86printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", __FUNCTION__ , file_id );
     87#endif
    8788                this->errno = EBADFD;
    8889                return -1;
     
    9495    if ( error )
    9596    {
    96         printk("\n[ERROR] in %s : user buffer unmapped = %x\n",
    97         __FUNCTION__ , (intptr_t)vaddr );
     97
     98#if CONFIG_DEBUG_SYSCALLS_ERROR
     99printk("\n[ERROR] in %s : user buffer unmapped = %x\n",
     100__FUNCTION__ , (intptr_t)vaddr );
     101#endif
    98102                this->errno = EINVAL;
    99103                return -1;
     
    108112    if( file_xp == XPTR_NULL )
    109113    {
    110         printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n",
    111         __FUNCTION__ , file_id , process->pid );
     114
     115#if CONFIG_DEBUG_SYSCALLS_ERROR
     116printk("\n[ERROR] in %s : undefined fd_id %d in process %x\n",
     117__FUNCTION__ , file_id , process->pid );
     118#endif
    112119        this->errno = EBADFD;
    113120        return -1;
     
    122129    if( (attr & FD_ATTR_READ_ENABLE) == 0 )
    123130        {
    124         printk("\n[ERROR] in %s : file %d not readable in process %x\n",
    125         __FUNCTION__ , file_id , process->pid );
     131
     132#if CONFIG_DEBUG_SYSCALLS_ERROR
     133printk("\n[ERROR] in %s : file %d not readable in process %x\n",
     134__FUNCTION__ , file_id , process->pid );
     135#endif
    126136                this->errno = EBADFD;
    127137                return -1;
     
    138148        if( (attr & FD_ATTR_READ_ENABLE) == 0 )
    139149            {
    140             printk("\n[ERROR] in %s : file %d not readable in process %x\n",
    141             __FUNCTION__ , file_id , process->pid );
     150
     151#if CONFIG_DEBUG_SYSCALLS_ERROR
     152printk("\n[ERROR] in %s : file %d not readable in process %x\n",
     153__FUNCTION__ , file_id , process->pid );
     154#endif
    142155                    this->errno = EBADFD;
    143156                    return -1;
     
    166179        if( XPTR( local_cxy , process ) != owner_xp )
    167180        {
    168             printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n",
    169             __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) );
     181
     182#if CONFIG_DEBUG_SYSCALLS_ERROR
     183printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n",
     184__FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) );
     185#endif
    170186                    this->errno = EBADFD;
    171187                    return -1;
     
    180196    if( nbytes != count )
    181197    {
    182         printk("\n[ERROR] in %s cannot read data from file %d in process %x\n",
    183         __FUNCTION__ , file_id , process->pid );
     198
     199#if CONFIG_DEBUG_SYSCALLS_ERROR
     200printk("\n[ERROR] in %s cannot read data from file %d in process %x\n",
     201__FUNCTION__ , file_id , process->pid );
     202#endif
    184203        this->errno = error;
    185204        return -1;
     
    194213tm_end = hal_get_cycles();
    195214if( CONFIG_DEBUG_SYS_READ < tm_end )
    196 printk("\n[DBG] %s : thread %x / process %x / cycle %d\n"
     215printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
    197216"nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
    198217__FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
     
    201220#endif
    202221
    203 #if (CONFIG_READ_DEBUG & 0x1)
     222#if (CONFIG_DEBUG_SYS_READ & 1)
    204223exit_sys_read = (uint32_t)tm_end;
    205224
    206225printk("\n@@@@@@@@@@@@ timing to read character %c\n"
    207 " - enter_sys_read     = %d / delta %d\n"
    208 " - enter_devfs_move   = %d / delta %d\n"
    209 " - enter_txt_read     = %d / delta %d\n"
    210 " - enter_chdev_cmd    = %d / delta %d\n"
    211 " - enter_chdev_server = %d / delta %d\n"
    212 " - enter_tty_cmd      = %d / delta %d\n"
    213 " - enter_tty_isr      = %d / delta %d\n"
    214 " - exit_tty_isr       = %d / delta %d\n"
    215 " - exit_tty_cmd       = %d / delta %d\n"
    216 " - exit_chdev_server  = %d / delta %d\n"
    217 " - exit_chdev_cmd     = %d / delta %d\n"
    218 " - exit_txt_read      = %d / delta %d\n"
    219 " - exit_devfs_move    = %d / delta %d\n"
    220 " - exit_sys_read      = %d / delta %d\n",
     226" - enter_sys_read          = %d / delta %d\n"
     227" - enter_devfs_read        = %d / delta %d\n"
     228" - enter_txt_read          = %d / delta %d\n"
     229" - enter_chdev_cmd_read    = %d / delta %d\n"
     230" - enter_chdev_server_read = %d / delta %d\n"
     231" - enter_tty_cmd_read      = %d / delta %d\n"
     232" - enter_tty_isr_read      = %d / delta %d\n"
     233" - exit_tty_isr_read       = %d / delta %d\n"
     234" - exit_tty_cmd_read       = %d / delta %d\n"
     235" - exit_chdev_server_read  = %d / delta %d\n"
     236" - exit_chdev_cmd_read     = %d / delta %d\n"
     237" - exit_txt_read           = %d / delta %d\n"
     238" - exit_devfs_read         = %d / delta %d\n"
     239" - exit_sys_read           = %d / delta %d\n",
    221240*((char *)(intptr_t)paddr) ,
    222 enter_sys_read     , 0 ,
    223 enter_devfs_move   , enter_devfs_move   - enter_sys_read     ,
    224 enter_txt_read     , enter_txt_read     - enter_devfs_move   ,
    225 enter_chdev_cmd    , enter_chdev_cmd    - enter_txt_read     ,
    226 enter_chdev_server , enter_chdev_server - enter_chdev_cmd    ,
    227 enter_tty_cmd      , enter_tty_cmd      - enter_chdev_server ,
    228 enter_tty_isr      , enter_tty_isr      - enter_tty_cmd      ,
    229 exit_tty_isr       , exit_tty_isr       - enter_tty_isr      ,
    230 exit_tty_cmd       , exit_tty_cmd       - exit_tty_isr       ,
    231 exit_chdev_server  , exit_chdev_server  - exit_tty_cmd       ,
    232 exit_chdev_cmd     , exit_chdev_cmd     - exit_chdev_server  ,
    233 exit_txt_read      , exit_txt_read      - exit_chdev_cmd     ,
    234 exit_devfs_move    , exit_devfs_move    - exit_txt_read      ,
    235 exit_sys_read      , exit_sys_read      - exit_devfs_move    );
     241enter_sys_read          , 0 ,
     242enter_devfs_read        , enter_devfs_read        - enter_sys_read          ,
     243enter_txt_read          , enter_txt_read          - enter_devfs_read        ,
     244enter_chdev_cmd_read    , enter_chdev_cmd_read    - enter_txt_read          ,
     245enter_chdev_server_read , enter_chdev_server_read - enter_chdev_cmd_read    ,
     246enter_tty_cmd_read      , enter_tty_cmd_read      - enter_chdev_server_read ,
     247enter_tty_isr_read      , enter_tty_isr_read      - enter_tty_cmd_read      ,
     248exit_tty_isr_read       , exit_tty_isr_read       - enter_tty_isr_read      ,
     249exit_tty_cmd_read       , exit_tty_cmd_read       - exit_tty_isr_read       ,
     250exit_chdev_server_read  , exit_chdev_server_read  - exit_tty_cmd_read       ,
     251exit_chdev_cmd_read     , exit_chdev_cmd_read     - exit_chdev_server_read  ,
     252exit_txt_read           , exit_txt_read           - exit_chdev_cmd_read     ,
     253exit_devfs_read         , exit_devfs_read         - exit_txt_read           ,
     254exit_sys_read           , exit_sys_read           - exit_devfs_read         );
    236255#endif
    237256 
  • trunk/kernel/syscalls/sys_signal.c

    r409 r435  
    2727#include <thread.h>
    2828#include <printk.h>
    29 #include <signal.h>
    3029
    3130//////////////////////////////////
  • trunk/kernel/syscalls/sys_wait.c

    r433 r435  
    2424#include <hal_types.h>
    2525#include <hal_uspace.h>
     26#include <hal_irqmask.h>
    2627#include <core.h>
    2728#include <thread.h>
     
    4243    int         child_state;
    4344    thread_t  * child_thread;
     45    reg_t       save_sr;
    4446
    4547    thread_t  * this    = CURRENT_THREAD;
     
    6163        if( error )
    6264        {
    63         printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n",
    64         __FUNCTION__ , this->trdid , process->pid );
     65
     66#if CONFIG_DEBUG_SYSCALLS_ERROR
     67printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n",
     68__FUNCTION__ , this->trdid , process->pid );
     69#endif
    6570        this->errno = EFAULT;
    6671                return -1;
     
    8590    while( 1 )
    8691    {
     92        // enable IRQS
     93        hal_enable_irq( &save_sr );
     94 
    8795        // get lock protecting children list
    8896        remote_spinlock_lock( children_lock_xp );
     
    101109            // test if child process is terminated,
    102110            // but termination not yet reported to parent process
    103             if( ((child_state & PROCESS_FLAG_EXIT)   ||
    104                  (child_state & PROCESS_FLAG_KILL)   ||
    105                  (child_state & PROCESS_FLAG_BLOCK)) &&
    106                  ((child_state & PROCESS_FLAG_WAIT) == 0) )
     111            if( ((child_state & PROCESS_TERM_EXIT)  ||
     112                 (child_state & PROCESS_TERM_KILL)  ||
     113                 (child_state & PROCESS_TERM_STOP)) &&
     114                 ((child_state & PROCESS_TERM_WAIT) == 0) )
    107115            {
    108116                // get pointer on main thread and PID from child owner process
     
    112120                // set the PROCESS_FLAG_WAIT in owner child descriptor
    113121                hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ),
    114                                       PROCESS_FLAG_WAIT );
     122                                      PROCESS_TERM_WAIT );
    115123
    116124                // set the THREAD_FLAG_REQ_DELETE in child main thread
     
    118126                                            THREAD_FLAG_REQ_DELETE );
    119127
     128                // release lock protecting children list
     129                remote_spinlock_unlock( children_lock_xp );
     130
    120131#if CONFIG_DEBUG_SYS_WAIT
    121132tm_end = hal_get_cycles();
    122133if( CONFIG_DEBUG_SYS_WAIT < tm_end )
    123 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n",
    124 __FUNCTION__, this, process->pid, (uint32_t)tm_end );
     134printk("\n[DBG] %s : thread %x exit / parent %x / child %x / cycle %d\n",
     135__FUNCTION__, this, process->pid, child_pid, (uint32_t)tm_end );
    125136#endif
    126 
    127137                 // return relevant info to calling parent process
    128138                 hal_copy_to_uspace( status , &child_state , sizeof(int) );
     
    131141        }
    132142       
    133         // release lock
     143        // release lock protecting children list
    134144        remote_spinlock_unlock( children_lock_xp );
    135145
    136146        // deschedule without blocking
    137147        sched_yield( "parent wait children termination" );
    138     }
     148
     149    }  // end while
    139150
    140151    // never executed
  • trunk/kernel/syscalls/sys_write.c

    r433 r435  
    4141{
    4242    error_t      error;
    43     paddr_t      paddr;           // unused, but required for user space checking
     43    paddr_t      paddr;           // required for user space checking
    4444        xptr_t       file_xp;         // remote file extended pointer
    4545    uint32_t     nbytes;          // number of bytes actually written
    4646    reg_t        save_sr;         // required to enable IRQs during syscall
     47
     48#if (CONFIG_DEBUG_SYS_WRITE_DEBUG & 1)
     49enter_sys_read = (uint32_t)tm_start;
     50#endif
    4751
    4852        thread_t   * this = CURRENT_THREAD;
     
    5458tm_start = hal_get_cycles();
    5559if( CONFIG_DEBUG_SYS_WRITE < tm_start )
    56 printk("\n[DBG] %s : thread %x / process %x / vaddr %x / count %d / cycle %d\n",
     60printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / count %d / cycle %d\n",
    5761__FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start );
    5862#endif
     
    162166tm_end = hal_get_cycles();
    163167if( CONFIG_DEBUG_SYS_WRITE < tm_end )
    164 printk("\n[DBG] %s : thread %x in process %x / cycle %d\n"
     168printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
    165169"nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
    166170__FUNCTION__, this, process->pid, (uint32_t)tm_start,
     
    168172#endif
    169173 
     174#if (CONFIG_DEBUG_SYS_WRITE & 1)
     175exit_sys_write = (uint32_t)tm_end;
     176
     177printk("\n@@@@@@@@@@@@ timing to write string %c\n"
     178" - enter_sys_write          = %d / delta %d\n"
     179" - enter_devfs_write        = %d / delta %d\n"
     180" - enter_txt_write          = %d / delta %d\n"
     181" - enter_chdev_cmd_write    = %d / delta %d\n"
     182" - enter_chdev_server_write = %d / delta %d\n"
     183" - enter_tty_cmd_write      = %d / delta %d\n"
     184" - enter_tty_isr_write      = %d / delta %d\n"
     185" - exit_tty_isr_write       = %d / delta %d\n"
     186" - exit_tty_cmd_write       = %d / delta %d\n"
     187" - exit_chdev_server_write  = %d / delta %d\n"
     188" - exit_chdev_cmd_write     = %d / delta %d\n"
     189" - exit_txt_write           = %d / delta %d\n"
     190" - exit_devfs_write         = %d / delta %d\n"
     191" - exit_sys_write           = %d / delta %d\n",
     192*((char *)(intptr_t)paddr) ,
     193enter_sys_write          , 0 ,
     194enter_devfs_write        , enter_devfs_write        - enter_sys_write          ,
     195enter_txt_write          , enter_txt_write          - enter_devfs_write        ,
     196enter_chdev_cmd_write    , enter_chdev_cmd_write    - enter_txt_write          ,
     197enter_chdev_server_write , enter_chdev_server_write - enter_chdev_cmd_write    ,
     198enter_tty_cmd_write      , enter_tty_cmd_write      - enter_chdev_server_write ,
     199enter_tty_isr_write      , enter_tty_isr_write      - enter_tty_cmd_write      ,
     200exit_tty_isr_write       , exit_tty_isr_write       - enter_tty_isr_write      ,
     201exit_tty_cmd_write       , exit_tty_cmd_write       - exit_tty_isr_write       ,
     202exit_chdev_server_write  , exit_chdev_server_write  - exit_tty_cmd_write       ,
     203exit_chdev_cmd_write     , exit_chdev_cmd_write     - exit_chdev_server_write  ,
     204exit_txt_write           , exit_txt_write           - exit_chdev_cmd_write     ,
     205exit_devfs_write         , exit_devfs_write         - exit_txt_write           ,
     206exit_sys_write           , exit_sys_write           - exit_devfs_write         );
     207#endif
     208 
    170209        return nbytes;
    171210
  • trunk/kernel/syscalls/syscalls.h

    r433 r435  
    508508 * The following macros can be used to extract information from status:
    509509 * - WIFEXITED(status)   : is true if the child process terminated with an exit().
    510  * - WIFSIGNALED(status) : is true if the child process terminated by a signal.
     510 * - WIFSIGNALED(status) : is true if the child process killed by a signal.
    511511 * - WIFSTOPPED(status)  : is true if the child process is stopped by a signal.
    512512 * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument.
     
    558558 * [43] This debug function displays on the kernel terminal TXT0 an user defined string,
    559559 * or the current state of a kernel structure, identified by the <type> argument.
    560  * The <arg0> and <arg1> arguments depends on the structure type. It can be:
    561  * - VMM     : VSL and GPT for a process identified by <pid>.
    562  * - SCHED   : all threads allocated to a scheduler identified by <cxy> & <lid>.
    563  * - PROCESS : all processes registered in a cluster identified by <cxy>. 
    564  * - VFS     : all files registered in the VFS cache.
    565  * - CHDEV   : all registered channel devices.
    566  ******************************************************************************************
    567  * type     : [in] STRING / VMM / SCHED / PROCESS / VSEG / VFS
     560 * The <arg0> and <arg1> arguments depends on the structure type:
     561 * - DISPLAY_STRING          : an user defined string
     562 * - DISPLAY_VMM             : VSL and GPT for a process identified by <pid>.
     563 * - DISPLAY_SCHED           : all threads allocated to a scheduler <cxy> & <lid>.
     564 * - DISPLAY_CLUSTER_PROCESS : all processes registered in a cluster identified by <cxy>. 
     565 * - DISPLAY_TXT_PROCESS     : all processes registered in a cluster identified by <cxy>. 
     566 * - DISPLAY_VFS             : all files registered in the VFS cache.
     567 * - DISPLAY_CHDEV           : all registered channel devices.
     568 ******************************************************************************************
     569 * type      : [in] type of display
    568570 * arg0      : [in] type dependant argument.
    569571 * arg1      : [in] type dependant argument.
  • trunk/kernel_config.h

    r434 r435  
    3131////////////////////////////////////////////////////////////////////////////////////////////
    3232//                              KERNEL DEBUG
    33 //
    3433//  Each debug variable control one kernel function, or one small group of functions.
    3534//  - trace is generated only when cycle > debug_value.
     
    3736////////////////////////////////////////////////////////////////////////////////////////////
    3837
    39 #define CONFIG_FATFS_DEBUG            0
    40 #define CONFIG_FBF_DEBUG              0
    41 #define CONFIG_GRPC_DEBUG             0
    42 #define CONFIG_IOC_DEBUG              0
    43 #define CONFIG_IRQ_DEBUG              0
    44 #define CONFIG_KHM_DEBUG              0
    45 #define CONFIG_KMEM_DEBUG             0
    46 #define CONFIG_MMAP_DEBUG             0         
    47 #define CONFIG_MMC_DEBUG              0
    48 #define CONFIG_MAPPER_DEBUG           0
    49 #define CONFIG_NIC_DEBUG              0
    50 #define CONFIG_PIC_DEBUG              0
    51 #define CONFIG_READ_DEBUG             0
    52 
    53 
    54 #define CONFIG_DEBUG_CHDEV_REGISTER_COMMAND   3000000
    55 #define CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER  3000000
     38
     39
     40#define CONFIG_DEBUG_CHDEV_REGISTER_COMMAND   0
     41#define CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER  0
    5642
    5743#define CONFIG_DEBUG_CLUSTER_INIT             0
    5844
    59 #define CONFIG_DEBUG_DEV_TXT                  3000000
     45#define CONFIG_DEBUG_DEV_TXT                  0
     46#define CONFIG_DEBUG_DEV_IOC                  0
     47#define CONFIG_DEBUG_DEV_NIC                  0
     48#define CONFIG_DEBUG_DEV_FBF                  0
     49#define CONFIG_DEBUG_DEV_MMC                  0
    6050
    6151#define CONFIG_DEBUG_DEVFS_INIT               0
    62 #define CONFIG_DEBUG_DEVFS_MOVE               3000000
     52#define CONFIG_DEBUG_DEVFS_MOVE               0
     53
     54#define CONFIG_DEBUG_FATFS_INIT               0
     55#define CONFIG_DEBUG_FATFS_MOVE               0
     56#define CONFIG_DEBUG_FATFS_LOAD               0
    6357
    6458#define CONFIG_DEBUG_GPT_ACCESS               0
    6559
    6660#define CONFIG_DEBUG_HAL_KENTRY               0
    67 #define CONFIG_DEBUG_HAL_TXT                  3000000
     61#define CONFIG_DEBUG_HAL_TXT                  0
    6862#define CONFIG_DEBUG_HAL_EXCEPTIONS           0
    69 
    70 #define CONFIG_DEBUG_KCM_ALLOC                0
     63#define CONFIG_DEBUG_HAL_IRQS                 0       
     64
     65#define CONFIG_DEBUG_KCM                      0
     66#define CONFIG_DEBUG_KMEM                     0
    7167
    7268#define CONFIG_DEBUG_KERNEL_INIT              0
     
    7470
    7571#define CONFIG_DEBUG_LOCKS                    0
     72
     73#define CONFIG_DEBUG_MAPPER_GET_PAGE          0
     74#define CONFIG_DEBUG_MAPPER_MOVE_USER         0
     75#define CONFIG_DEBUG_MAPPER_MOVE_KERNEL       0
    7676
    7777#define CONFIG_DEBUG_PPM_ALLOC_PAGES          0
     
    8383#define CONFIG_DEBUG_PROCESS_MAKE_EXEC        0
    8484#define CONFIG_DEBUG_PROCESS_MAKE_FORK        0
    85 #define CONFIG_DEBUG_PROCESS_MAKE_KILL        0
    8685#define CONFIG_DEBUG_PROCESS_REFERENCE_INIT   0
    8786#define CONFIG_DEBUG_PROCESS_SIGACTION        0
    88 #define CONFIG_DEBUG_PROCESS_ATTACH           0
    89 #define CONFIG_DEBUG_PROCESS_DETACH           0
     87#define CONFIG_DEBUG_PROCESS_TXT_ATTACH       2
    9088#define CONFIG_DEBUG_PROCESS_ZERO_CREATE      0
    9189
     
    9492
    9593#define CONFIG_DEBUG_SCHED_HANDLE_SIGNALS     0     
    96 #define CONFIG_DEBUG_SCHED_YIELD              5000001
    97 
    98 #define CONFIG_DEBUG_SYSCALLS_ERROR           0
     94#define CONFIG_DEBUG_SCHED_YIELD              0
     95
     96#define CONFIG_DEBUG_SYSCALLS_ERROR           2
    9997
    10098#define CONFIG_DEBUG_SYS_DISPLAY              0
    101 #define CONFIG_DEBUG_SYS_EXEC                 3000000
    102 #define CONFIG_DEBUG_SYS_EXIT                 3000000
    103 #define CONFIG_DEBUG_SYS_FORK                 3000000
    104 #define CONFIG_DEBUG_SYS_KILL                 3000000
    105 #define CONFIG_DEBUG_SYS_READ                 3000000
    106 #define CONFIG_DEBUG_SYS_WAIT                 3000000
    107 #define CONFIG_DEBUG_SYS_WRITE                3000000
     99#define CONFIG_DEBUG_SYS_EXEC                 2
     100#define CONFIG_DEBUG_SYS_EXIT                 0
     101#define CONFIG_DEBUG_SYS_FORK                 2
     102#define CONFIG_DEBUG_SYS_GET_CONFIG           2
     103#define CONFIG_DEBUG_SYS_KILL                 2
     104#define CONFIG_DEBUG_SYS_MMAP                 0
     105#define CONFIG_DEBUG_SYS_READ                 0
     106#define CONFIG_DEBUG_SYS_WAIT                 2
     107#define CONFIG_DEBUG_SYS_WRITE                0
    108108
    109109#define CONFIG_DEBUG_THREAD_DESTROY           0
  • trunk/libs/stdio.c

    r426 r435  
    292292/////////////     Non standard system calls ////////////////////////////////////
    293293
     294
    294295//////////////////////////
    295296int fg( unsigned int pid )
     
    345346}
    346347
    347 ///////////////////////////////////////
    348 int display_process( unsigned int cxy )
    349 {
    350     return hal_user_syscall( SYS_DISPLAY,
    351                              DISPLAY_PROCESS,
     348/////////////////////////////////////////////////
     349int display_cluster_processes( unsigned int cxy )
     350{
     351    return hal_user_syscall( SYS_DISPLAY,
     352                             DISPLAY_CLUSTER_PROCESSES,
    352353                             (reg_t)cxy, 0, 0 );
    353354}
     
    365366    return hal_user_syscall( SYS_DISPLAY,
    366367                             DISPLAY_VFS, 0, 0, 0 );
     368}
     369
     370////////////////////////////////////////////////
     371int display_txt_processes( unsigned int txt_id )
     372{
     373    return hal_user_syscall( SYS_DISPLAY,
     374                             DISPLAY_TXT_PROCESSES,
     375                             (reg_t)txt_id, 0, 0 );
    367376}
    368377
  • trunk/libs/stdio.h

    r434 r435  
    347347int wait( int * status );
    348348
     349
    349350/****************** Non standard (ALMOS_MKH specific) system calls **********************/
    350351
     
    429430 * @ return 0 if success / return -1 if illegal argument.
    430431 **************************************************************************************/
    431 int display_process( unsigned int  cxy );
     432int display_cluster_processes( unsigned int  cxy );
    432433
    433434/***************************************************************************************
     
    448449 **************************************************************************************/
    449450int display_vfs();
     451
     452/***************************************************************************************
     453 * This debug function displays on the kernel terminal TXT0
     454 * the list of processes attached to a given TXT channel.
     455 * It can be called by any thread running in any cluster.
     456 ***************************************************************************************
     457 * @ return always 0.
     458 **************************************************************************************/
     459int display_txt_processes( unsigned int txt_id );
    450460
    451461/*****************************************************************************************
  • trunk/params.mk

    r434 r435  
    55Y_SIZE    = 1
    66NB_PROCS  = 1
    7 NB_TTYS   = 2
     7NB_TTYS   = 3
    88FBF_WIDTH = 128
    99IOC_TYPE  = IOC_BDV
  • trunk/user/init/init.c

    r434 r435  
    3838    for( i = 1 ; i <  NB_TXT_CHANNELS ; i++ )
    3939    {
    40 
    41 snprintf( string , 64 , "@@@ before fork / iter = %d\n" , i );
    42 display_string( string );
    43 
    4440        // INIT process fork process CHILD[i]
    4541        ret_fork = fork();
    46 
    47 snprintf( string , 64 , "@@@ after fork / iter = %d / ret_fork = %d\n" , i , ret_fork );
    48 display_string( string );
    4942
    5043        if( ret_fork< 0 )   // error in fork
    5144        {
    5245            // INIT display error message on TXT0 terminal
    53             snprintf( string , 64 , "init cannot fork child[%d]\n" , i );
     46            snprintf( string , 64 ,
     47            "INIT cannot fork child[%d]\n" , i );
    5448            display_string( string );
    5549
     
    6559            {
    6660                // display error message on TXT0 terminal
    67                 snprintf( string , 64 , "child[%d] cannot exec ksh[%d]\n" , i , i );
     61                snprintf( string , 64 ,
     62                "CHILD[%d] cannot exec KSH[%d] / ret_exec = %d\n" , i , i , ret_exec );
    6863                display_string( string );
    69 
    70                 // CHILD[i] exit
    71                 // exit( 0 );
    7264            }
    7365        }
     
    7567        {
    7668             // INIT display CHILD[i] process PID
    77              snprintf( string , 64 , "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork );
     69             snprintf( string , 64 ,
     70             "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork );
    7871             display_string( string );
    79 
    80              // INIT delay
    81              int     x;
    82              for( x=0 ; x<DELAY_BETWEEN_FORK ; x++) asm volatile ("nop");
    83 
    84 /*
    85              // INIT wait exec completion by CHILD[i]
    86              while( 1 )
    87              {
    88                  // get terminating process PID
    89                  received_pid = wait( &status );
    90 
    91                  if( received_pid == ret_fork ) break;
    92                  else
    93                  {
    94                      snprintf( string , 64 ,
    95                      "expected_pid %d / received_pid %d" , ret_fork , received_pid  );
    96                      display_string( string );
    97                  }
    98              }
    99 
    100 */
    101              // INIT display string on kernel TXT0
    102              snprintf( string , 64 , "INIT created KSH[%d]\n", i );
    103              display_string( string );
    104 // @@@
    105 display_process( 0 );
    106 display_sched( 0 , 0 );
    107 // @@@
    10872        }
    10973
    11074    }
    11175
    112     // This blocking loop is only for debug, because KSH[i] processes
    113     // should never be killed, and INIT should never return from the wait() function.
     76    // This loop detects the termination of the KSH[i] processes,
     77    // to recreate these process when required.
    11478    while( 1 )
    11579    {
    116         // block on child process termination
    117         received_pid = wait( &status ); 
     80        // block on child processes termination
     81        received_pid = wait( &status );
    11882
    119         // display string to report unexpected KSH process termination
    120         snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid );
    121         display_string( string );
     83        if( WIFSTOPPED( status ) )                         // stopped => unblock it
     84        {
     85            // display string to report unexpected KSH process block
     86            snprintf( string , 64 , "KSH process %x unexpectedly stopped" , received_pid );
     87            display_string( string );
     88
     89        }
     90
     91        if( WIFSIGNALED( status ) || WIFEXITED( status ) )  // killed => recreate it
     92        {
     93            // display string to report unexpected KSH process termination
     94            snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid );
     95            display_string( string );
     96        }
    12297    }
    12398
  • trunk/user/ksh/ksh.c

    r434 r435  
    484484    unsigned int  lid;
    485485    unsigned int  pid;
     486    unsigned int  txt_id;
    486487
    487488    if( strcmp( argv[1] , "vmm" ) == 0 )
     
    526527            cxy = atoi(argv[2]);
    527528
    528         if( display_process( cxy ) )
     529        if( display_cluster_processes( cxy ) )
    529530        {
    530531            printf("  error: illegal argument cxy = %x\n", cxy );
    531532        }
    532533    }
     534    else if( strcmp( argv[1] , "txt" ) == 0 )
     535    {
     536        if( argc != 3 )
     537        {
     538                    printf("  usage: display txt txt_id\n");
     539                    return;
     540            }
     541
     542            txt_id = atoi(argv[2]);
     543
     544        if( display_txt_processes( txt_id ) )
     545        {
     546            printf("  error: illegal argument txt_id = %x\n", txt_id );
     547        }
     548    }
    533549    else if( strcmp( argv[1] , "vfs" ) == 0 )
    534550    {
     
    553569    else
    554570    {
    555         printf("  usage display (vmm/sched/process/vfs/chdev) [cxy] [lid]\n");
     571        printf("  usage: display (vmm/sched/process/vfs/chdev/txt) [arg2] [arg3]\n");
    556572    }
    557573}
     
    563579ksh_cmd_t cmd[] =
    564580{
    565         { "cat",     "display file content",                cmd_cat     },
    566         { "cd",      "change current directory",            cmd_cd      },
    567         { "cp",      "replicate a file in file system",     cmd_cp      },
    568     { "fg",      "put a process in foreground",         cmd_fg      },
    569     { "display", "display vmm/sched/process/vfs/chdev", cmd_display },
    570         { "load",    "load an user application",            cmd_load    },
    571         { "help",    "list available commands",             cmd_help    },
    572         { "kill",    "kill an application (all threads)",   cmd_kill    },
    573         { "log",     "list registered commands",            cmd_log     },
    574         { "ls",      "list directory entries",              cmd_ls      },
    575         { "mkdir",   "create a new directory",              cmd_mkdir   },
    576         { "mv",      "move a file in file system",          cmd_mv      },
    577         { "pwd",     "print current working directory",     cmd_pwd     },
    578         { "rm",      "remove a file from file system",      cmd_rm      },
    579         { "rmdir",   "remove a directory from file system", cmd_rmdir   },
    580         { NULL,     NULL,                                                                  NULL         }
     581        { "cat",     "display file content",                            cmd_cat     },
     582        { "cd",      "change current directory",                        cmd_cd      },
     583        { "cp",      "replicate a file in file system",                 cmd_cp      },
     584    { "fg",      "put a process in foreground",                     cmd_fg      },
     585    { "display", "display vmm/sched/process/vfs/chdev/txt",        cmd_display },
     586        { "load",    "load an user application",                        cmd_load    },
     587        { "help",    "list available commands",                         cmd_help    },
     588        { "kill",    "kill an application (all threads)",               cmd_kill    },
     589        { "log",     "list registered commands",                        cmd_log     },
     590        { "ls",      "list directory entries",                          cmd_ls      },
     591        { "mkdir",   "create a new directory",                          cmd_mkdir   },
     592        { "mv",      "move a file in file system",                      cmd_mv      },
     593        { "pwd",     "print current working directory",                 cmd_pwd     },
     594        { "rm",      "remove a file from file system",                  cmd_rm      },
     595        { "rmdir",   "remove a directory from file system",             cmd_rmdir   },
     596        { NULL,      NULL,                                                                              NULL        }
    581597};
    582598
  • trunk/user/sort/sort.c

    r434 r435  
    265265
    266266    get_cycle( &cycle );
    267     printf("\n[SORT] completes barrier init at cycle %d\n", (unsigned int)cycle );
     267    printf("\n[SORT] completes barrier init at cycle %d continue ?\n", (unsigned int)cycle );
     268    getchar();
    268269
    269270    // Array to sort initialization
Note: See TracChangeset for help on using the changeset viewer.