Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (6 years ago)
Author:
alain
Message:

1/ Fix a bug in the Multithreaded "sort" applicationr:
The pthread_create() arguments must be declared as global variables.
2/ The exit syscall can be called by any thread of a process..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_kill.c

    r438 r440  
    22 * sys_kill.c - Kernel function implementing the "kill" system call.
    33 *
    4  * Author    Alain Greiner (2016,2017)
     4 * Author    Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c)  UPMC Sorbonne Universites
     
    3838{
    3939    xptr_t      owner_xp;      // extended pointer on target process in owner cluster
    40     cxy_t       owner_cxy;     // target process owner cluster
     40    cxy_t       owner_cxy;     // target process in owner cluster
    4141    process_t * owner_ptr;     // local pointer on target process in owner cluster
    42     xptr_t      parent_xp;     // extended pointer on parent process
    43     cxy_t       parent_cxy;    // parent process cluster
    44     process_t * parent_ptr;    // local pointer on parent process
    45     pid_t       ppid;          // parent process PID
    4642    uint32_t    retval;        // return value for the switch
    4743
    4844    thread_t  * this    = CURRENT_THREAD;
    4945    process_t * process = this->process;
    50     trdid_t     trdid   = this->trdid;
    5146
    5247#if DEBUG_SYS_KILL
     
    7570    }
    7671
    77     // process can kill itself only when calling thread is the main thread
    78     if( (pid == process->pid) && ((owner_cxy != local_cxy) || (LTID_FROM_TRDID( trdid ))) )
     72    // process cannot kill itself
     73    if( (pid == process->pid) )
    7974    {
    8075
    8176#if DEBUG_SYSCALLS_ERROR
    82 printk("\n[ERROR] in %s : only main thread can kill itself\n", __FUNCTION__ );
     77printk("\n[ERROR] in %s : process %x cannot kill itself\n", __FUNCTION__, pid );
    8378#endif
    8479        this->errno = EINVAL;
     
    8681    }
    8782
    88     // get parent process PID
    89     parent_xp  = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
    90     parent_cxy = GET_CXY( parent_xp );
    91     parent_ptr = GET_PTR( parent_xp );
    92     ppid       = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
    93 
    94     // check processe INIT
     83    // processe INIT cannot be killed
    9584    if( pid == 1 )
    9685    {
Note: See TracChangeset for help on using the changeset viewer.