Changeset 415 for trunk/kernel


Ignore:
Timestamp:
Dec 22, 2017, 1:16:59 PM (4 years ago)
Author:
alain
Message:

Few bugs.

Location:
trunk/kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/printk.h

    r409 r415  
    331331#endif
    332332
    333 #if CONFIG_SIGNAL_DEBUG
    334 #define signal_dmsg(...)   if(hal_time_stamp() > CONFIG_SIGNAL_DEBUG) printk(__VA_ARGS__)
    335 #else
    336 #define signal_dmsg(...)
     333#if CONFIG_SIGACTION_DEBUG
     334#define sigaction_dmsg(...)   if(hal_time_stamp() > CONFIG_SIGACTION_DEBUG) printk(__VA_ARGS__)
     335#else
     336#define sigaction_dmsg(...)
    337337#endif
    338338
  • trunk/kernel/kern/process.c

    r409 r415  
    125125    uint32_t    stdout_id;
    126126    uint32_t    stderr_id;
     127    error_t     error;
    127128
    128129process_dmsg("\n[DBG] %s : core[%x,%d] enters for process %x / ppid = %x\n",
     
    139140
    140141    // initialize vmm as empty
    141     vmm_init( process );
     142    error = vmm_init( process );
     143    assert( (error == 0) , __FUNCTION__ , "cannot initialize VMM\n" );
     144 
    142145
    143146process_dmsg("\n[DBG] %s : core[%x,%d] / vmm empty for process %x\n",
     
    259262                           xptr_t      reference_process_xp )
    260263{
     264    error_t error;
     265
    261266    // get reference process cluster and local pointer
    262267    cxy_t       ref_cxy = GET_CXY( reference_process_xp );
     
    272277
    273278    // reset local process vmm
    274     vmm_init( local_process );
     279    error = vmm_init( local_process );
     280    assert( (error == 0) , __FUNCTION__ , "cannot initialize VMM\n");
    275281
    276282    // reset process file descriptors array
     
    309315    // register new process descriptor in owner cluster manager copies_list
    310316    cluster_process_copies_link( local_process );
    311 
    312     // initialize signal manager TODO [AG]
    313317
    314318        hal_fence();
     
    397401    process_t        * process_ptr;       // local pointer on process copy
    398402
    399 signal_dmsg("\n[DBG] %s : enter for signal %s to process %x in cluster %x\n",
     403sigaction_dmsg("\n[DBG] %s : enter for signal %s to process %x in cluster %x\n",
    400404__FUNCTION__ , process_action_str( action_type ) , process , local_cxy );
    401405
     
    432436        process_ptr = (process_t *)GET_PTR( process_xp );
    433437
    434 printk("\n    @@@ %s : process = %x / pid = %x / ppid = %x\n",
     438sigaction_dmsg("\n[DBG] %s : process = %x / pid = %x / ppid = %x\n",
    435439__FUNCTION__ , process_ptr , process_ptr->pid , process_ptr->ppid );
    436440
     
    449453    sched_yield("BLOCKED on RPC");
    450454
    451 signal_dmsg("\n[DBG] %s : exit for signal %s to process %x in cluster %x\n",
     455sigaction_dmsg("\n[DBG] %s : exit for signal %s to process %x in cluster %x\n",
    452456__FUNCTION__ , process_action_str( action_type ) , process , local_cxy );
    453457
     
    471475    killer = CURRENT_THREAD;
    472476
    473 signal_dmsg("\n[DBG] %s : enter for process %x in cluster %x\n",
     477sigaction_dmsg("\n[DBG] %s : enter for process %x in cluster %x\n",
    474478__FUNCTION__ , process->pid , local_cxy );
    475479
     
    532536    }
    533537
    534 signal_dmsg("\n[DBG] %s : exit for process %x in cluster %x / %d threads blocked\n",
     538sigaction_dmsg("\n[DBG] %s : exit for process %x in cluster %x / %d threads blocked\n",
    535539__FUNCTION__ , process->pid , local_cxy , count );
    536540
     
    553557    killer = CURRENT_THREAD;
    554558
    555 signal_dmsg("\n[DBG] %s : enter for process %x in cluster %x\n",
     559sigaction_dmsg("\n[DBG] %s : enter for process %x in cluster %x\n",
    556560__FUNCTION__ , process->pid , local_cxy );
    557561
     
    586590    }
    587591
    588 signal_dmsg("\n[DBG] %s : exit for process %x in cluster %x / %d threads blocked\n",
     592sigaction_dmsg("\n[DBG] %s : exit for process %x in cluster %x / %d threads blocked\n",
    589593__FUNCTION__ , process->pid , local_cxy , req_count );
    590594
     
    607611    pid = process->pid;
    608612
    609 signal_dmsg("\n[DBG] %s : enter for process %x in cluster %x at cycle %d\n",
     613sigaction_dmsg("\n[DBG] %s : enter for process %x in cluster %x at cycle %d\n",
    610614__FUNCTION__ , pid , local_cxy , (uint32_t)hal_get_cycles() );
    611615
     
    648652    }
    649653
    650 signal_dmsg("\n[DBG] %s : exit for process %x in cluster %x at cycle %d\n",
     654sigaction_dmsg("\n[DBG] %s : exit for process %x in cluster %x at cycle %d\n",
    651655__FUNCTION__ , pid , local_cxy , (uint32_t)hal_get_cycles() );
    652656
     
    11811185__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid );
    11821186
    1183     // re-initialize VMM
    1184     vmm_init( process );
     1187    // initialize VMM
     1188    error = vmm_init( process );
     1189        {
     1190                printk("\n[ERROR] in %s : cannot initialize VMM for process %x / path = %s\n",
     1191                __FUNCTION__, pid , path );
     1192        process_destroy( process );
     1193        return -1;
     1194        }
     1195
     1196    if( error )
    11851197
    11861198    // register "code" and "data" vsegs as well as entry-point and vfs_bin_xp
    11871199    // in VMM, using information contained in the elf file.
    1188         if( elf_load_process( path , process ) )
     1200        error = elf_load_process( path , process );
     1201
     1202    if( error )
    11891203        {
    11901204                printk("\n[ERROR] in %s : failed to access .elf file for process %x / path = %s\n",
  • trunk/kernel/kern/process.h

    r409 r415  
    5959enum process_sigactions
    6060{
    61     BLOCK_ALL_THREADS,
    62     UNBLOCK_ALL_THREADS,
    63     DELETE_ALL_THREADS,
     61    BLOCK_ALL_THREADS    = 11,
     62    UNBLOCK_ALL_THREADS  = 22,
     63    DELETE_ALL_THREADS   = 33,
    6464};
    6565
  • trunk/kernel/kern/rpc.c

    r409 r415  
    106106    rpc->lid       = core->lid;
    107107
     108printk("\n   @@@ enter %s : rpc_desc_cxy = %x / rpc_desc_ptr = %x / index = %d / &index = %x\n",
     109__FUNCTION__ , local_cxy , rpc , rpc->index , &rpc->index);
     110 
    108111    // build an extended pointer on the RPC descriptor
    109112        xptr_t   desc_xp = XPTR( local_cxy , rpc );
     
    176179    }
    177180   
     181printk("\n   @@@ exit %s : rpc_desc_cxy = %x / rpc_desc_ptr = %x / index = %d / &index = %x\n",
     182__FUNCTION__ , local_cxy , rpc , rpc->index , &rpc->index);
     183 
    178184}  // end rpc_send()
    179185
     
    245251    }
    246252
     253//@@@
     254sched_display( 0 );
     255//@@@
     256
    247257grpc_dmsg("\n[DBG] %s : core[%x,%d] / interrupted thread %s deschedules / cycle %d\n",
    248258__FUNCTION__, local_cxy, core->lid, thread_type_str(this->type), hal_time_stamp() );
     
    300310                while( 1 )  // internal loop
    301311            {
     312
    302313                    empty = local_fifo_get_item( rpc_fifo , (uint64_t *)&desc_xp );
    303314
     
    311322                        index = hal_remote_lw( XPTR( desc_cxy , &desc_ptr->index ) );
    312323
     324printk("\n   @@@ in %s : rpc_desc_cxy = %x / rpc_desc_ptr = %x / index = %d / &index = %x\n",
     325__FUNCTION__ , desc_cxy , desc_ptr , index , &desc_ptr->index );
     326 
    313327grpc_dmsg("\n[DBG] %s : core[%x,%d] / RPC thread %x / starts rpc %d / cycle %d\n",
    314 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , index , hal_time_stamp() );
     328__FUNCTION__ , local_cxy , this->core->lid , this->trdid , index , (uint32_t)hal_get_cycles() );
    315329
    316330                    // call the relevant server function
     
    980994
    981995/////////////////////////////////////////////////////////////////////////////////////////
    982 // [9]     Marshaling functions attached to RPC_PROCESS_KILL (multicast / non blocking)
     996// [9] Marshaling functions attached to RPC_PROCESS_SIGACTION (multicast / non blocking)
    983997/////////////////////////////////////////////////////////////////////////////////////////
    984998
     
    9901004                                   xptr_t      client_xp )     // in
    9911005{
    992 signal_dmsg("\n[DBG] %s : enter for %s / thread %x on core[%x,%d] / cycle %d\n",
    993 __FUNCTION__ , process_action_str( sigaction ) , CURRENT_THREAD ,
     1006sigaction_dmsg("\n[DBG] %s : enter for %s (%d) / thread %x on core[%x,%d] / cycle %d\n",
     1007__FUNCTION__ , process_action_str( sigaction ) , sigaction , CURRENT_THREAD ,
    9941008local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    9951009
     
    10071021    rpc_send( cxy , &rpc , false );
    10081022
    1009 signal_dmsg("\n[DBG] %s : exit for %s / thread %x on core[%x,%d] / cycle %d\n",
    1010 __FUNCTION__ , process_action_str( sigaction ) , CURRENT_THREAD ,
     1023sigaction_dmsg("\n[DBG] %s : exit for %s (%d) / thread %x on core[%x,%d] / cycle %d\n",
     1024__FUNCTION__ , process_action_str( sigaction ) , sigaction , CURRENT_THREAD ,
    10111025local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    10121026
     
    10301044    client_xp = (xptr_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
    10311045   
    1032 signal_dmsg("\n[DBG] %s : enter for %s / thread %x on core[%x,%d] / cycle %d\n",
    1033 __FUNCTION__ , process_action_str( action ) , CURRENT_THREAD ,
     1046sigaction_dmsg("\n[DBG] %s : enter for %s (%d) / thread %x on core[%x,%d] / cycle %d\n",
     1047__FUNCTION__ , process_action_str( action ) , action , CURRENT_THREAD ,
    10341048local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    10351049
     
    10391053    else if (action == UNBLOCK_ALL_THREADS ) process_unblock( process , rsp_xp , client_xp );
    10401054
    1041 signal_dmsg("\n[DBG] %s : exit for %s / thread %x on core[%x,%d] / cycle %d\n",
    1042 __FUNCTION__ , process_action_str( action ) , CURRENT_THREAD ,
     1055sigaction_dmsg("\n[DBG] %s : exit for %s (%d) / thread %x on core[%x,%d] / cycle %d\n",
     1056__FUNCTION__ , process_action_str( action ) , action , CURRENT_THREAD ,
    10431057local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
    10441058}
  • trunk/kernel/mm/vmm.c

    r409 r415  
    5353
    5454
    55 ////////////////////////////////////
    56 void vmm_init( process_t * process )
     55///////////////////////////////////////
     56error_t vmm_init( process_t * process )
    5757{
    5858    error_t   error;
     
    9797                                   local_cxy );
    9898
    99     assert( (vseg_kentry != NULL) , __FUNCTION__ , "cannot register kentry vseg\n" );
     99    if( vseg_kentry == NULL )
     100    {
     101        printk("\n[ERROR] in %s : cannot register kentry vseg\n", __FUNCTION__ );
     102        return -1;
     103    }
    100104
    101105    vmm->kent_vpn_base = base;
     
    115119                                 local_cxy );
    116120
    117     assert( (vseg_args != NULL) , __FUNCTION__ , "cannot create args vseg\n" );
     121    if( vseg_args == NULL )
     122    {
     123        printk("\n[ERROR] in %s : cannot register args vseg\n", __FUNCTION__ );
     124        return -1;
     125    }
    118126
    119127    vmm->args_vpn_base = base;
     
    134142                                 local_cxy );
    135143
    136     assert( (vseg_envs != NULL) , __FUNCTION__ , "cannot create envs vseg\n" );
     144    if( vseg_envs == NULL )
     145    {
     146        printk("\n[ERROR] in %s : cannot register envs vseg\n", __FUNCTION__ );
     147        return -1;
     148    }
    137149
    138150    vmm->envs_vpn_base = base;
     
    141153    error = hal_gpt_create( &vmm->gpt );
    142154
    143     assert( (error == 0) , __FUNCTION__ , "cannot create GPT\n");
    144 
    145     // architecture specific GPT initialization
     155    if( error )
     156    printk("\n[ERROR] in %s : cannot create GPT\n", __FUNCTION__ );
     157
     158    // initialize GPT (architecture specic)
    146159    // (For TSAR, identity map the kentry_vseg)
    147160    error = hal_vmm_init( vmm );
    148161
    149     assert( (error == 0) , __FUNCTION__ , "cannot initialize GPT\n");
     162    if( error )
     163    printk("\n[ERROR] in %s : cannot initialize GPT\n", __FUNCTION__ );
    150164
    151165    // initialize STACK allocator
     
    168182__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ,
    169183process->pid , process->vmm.entry_point );
     184
     185    return 0;
    170186
    171187}  // end vmm_init()
     
    399415    parent_lock_xp = XPTR( parent_cxy , &parent_vmm->vsegs_lock );
    400416
    401     // take the lock protecting the parent VSL
    402     remote_rwlock_rd_lock( parent_lock_xp );
    403 
    404417    // initialize the lock protecting the child VSL
    405418    remote_rwlock_init( XPTR( local_cxy , &child_vmm->vsegs_lock ) );
     
    409422    child_vmm->vsegs_nr = 0;
    410423
    411     // create & initialize the child GPT as empty
     424    // create child GPT
    412425    error = hal_gpt_create( &child_vmm->gpt );
     426
    413427    if( error )
    414428    {
     
    419433    // build extended pointer on parent VSL
    420434    parent_root_xp = XPTR( parent_cxy , &parent_vmm->vsegs_root );
     435
     436    // take the lock protecting the parent VSL
     437    remote_rwlock_rd_lock( parent_lock_xp );
    421438
    422439    // loop on parent VSL xlist
     
    501518    // release the parent vsegs lock
    502519    remote_rwlock_rd_unlock( parent_lock_xp );
     520
     521    // initialize child GPT (architecture specic)
     522    // => For TSAR, identity map the kentry_vseg
     523    error = hal_vmm_init( child_vmm );
     524
     525    if( error )
     526    {
     527        printk("\n[ERROR] in %s : cannot create GPT\n", __FUNCTION__ );
     528        return -1;
     529    }
    503530
    504531    // initialize the child VMM STACK allocator
  • trunk/kernel/mm/vmm.h

    r409 r415  
    137137 * - The "stack" vsegs are dynamically created by the thread_user_create() function.
    138138 * - The "file", "anon", "remote" vsegs are dynamically created by the mmap() syscall.
    139  * TODO : Any error in this function gives a kernel panic => improve error handling.
    140139 *********************************************************************************************
    141140 * @ process   : pointer on process descriptor
    142  ********************************************************************************************/
    143 void vmm_init( struct process_s * process );
     141 * @ return 0 if success / return -1 if failure.
     142 ********************************************************************************************/
     143error_t vmm_init( struct process_s * process );
    144144
    145145/*********************************************************************************************
     
    169169 * @ child_process     : local pointer on local child process descriptor.
    170170 * @ parent_process_xp : extended pointer on remote parent process descriptor.
    171  * @ return 0 if success / return ENOMEM if failure.
     171 * @ return 0 if success / return -1 if failure.
    172172 ********************************************************************************************/
    173173error_t vmm_fork_copy( struct process_s * child_process,
Note: See TracChangeset for help on using the changeset viewer.