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

Fix a bad bug in scheduler...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.