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/kern/thread.h

    r438 r440  
    171171    cxy_t               fork_cxy;        /*! target cluster  for next fork()          */
    172172
    173         xlist_entry_t       children_root;   /*! root of list of attached children        */
    174     uint32_t            children_nr;     /*! number of attached children threads      */
    175     remote_spinlock_t * children_lock;   /*! lock protecting the children list        */
    176 
    177     xlist_entry_t       brothers_list;   /*! list of attached threads to same parent  */
    178 
    179173        list_entry_t        sched_list;      /*! member of threads attached to same core  */
    180174
     
    222216 * in an existing process. It allocates memory for an user thread descriptor in the
    223217 * local cluster, and initializes it from information contained in the arguments.
    224  * The CPU context is initialized from scratch. If required by the <attr> argument,
    225  * the new thread is attached to the core specified in <attr>.
     218 * The CPU context is initialized from scratch.
    226219 * It is registered in the local process descriptor specified by the <pid> argument.
    227  * The thread descriptor pointer is returned to allow the parent thread to register it
    228  * in its children list.
    229220 * The THREAD_BLOCKED_GLOBAL bit is set => the thread must be activated to start.
    230221 ***************************************************************************************
     
    325316
    326317/***************************************************************************************
    327  * This function registers a child thread in the global list of attached
    328  * children threads of a parent thread.
    329  * It does NOT take a lock, as this function is always called by the parent thread.
    330  ***************************************************************************************
    331  * @ parent_xp : extended pointer on the parent thread descriptor.
    332  * @ child_xp  : extended pointer on the child thread descriptor.
    333  **************************************************************************************/
    334 void thread_child_parent_link( xptr_t  parent_xp,
    335                                xptr_t  child_xp );
    336 
    337 /***************************************************************************************
    338  * This function removes an user thread from the parent thread global list
    339  * of attached children threads.
    340  ***************************************************************************************
    341  * @ parent_xp : extended pointer on the parent thread descriptor.
    342  * @ child_xp  : extended pointer on the child thread descriptor.
    343  **************************************************************************************/
    344 void thread_child_parent_unlink( xptr_t parent_xp,
    345                                  xptr_t child_xp );
    346 
    347 /***************************************************************************************
    348318 * This function is used by a "blocker" thread running in the same cluster as a "target"
    349319 * thread to request the scheduler of the target thread to acknowledge that the target
     
    386356
    387357/***************************************************************************************
    388  * This function is called to handle the four pthread_cancel(), pthread_exit(),
    389  * kill() and exit() system calls. It kills a "target" thread identified by the
    390  * <thread_xp> argument. The "killer" thread can be the "target" thread, when the
    391  * <is_exit> argument is true. The "killer" thread can run in any cluster,
    392  * as it uses remote accesses.
    393  * If the "target" thread is running in "attached" mode, and the <is_forced> argument
     358 * This function is used by the four sys_thread_cancel(), sys_thread_exit(),
     359 * sys_kill() and sys_exit() system calls to delete a given thread.
     360 * It set the THREAD_BLOCKED_GLOBAL bit and set the the THREAD_FLAG_REQ_DELETE bit
     361 * in the thread descriptor identified by the <thread_xp> argument, to ask the scheduler
     362 * to asynchronously delete the target thread, at the next scheduling point.
     363 * The calling thread can run in any cluster, as it uses remote accesses, but
     364 * the target thread cannot be the main thread of the process identified by the <pid>,
     365 * because the main thread must be deleted by the parent process argument.
     366 * If the target thread is running in "attached" mode, and the <is_forced> argument
    394367 * is false, this function implements the required sychronisation with the joining
    395  * thread, blocking the "killer" thread until the pthread_join() syscall is executed.
    396  * To delete the target thread, this function sets the THREAD_FLAG_REQ_DELETE bit
    397  * and the THREAD BLOCKED_GLOBAL bit in the target thread, and the actual destruction
    398  * is asynchronously done by the scheduler at the next scheduling point.
     368 * thread, blocking the calling thread until the pthread_join() syscall is executed.
    399369 ***************************************************************************************
    400370 * @ thread_xp   : extended pointer on the target thread.
    401  * @ is_exit     : the killer thread is the target thread itself.
    402  * @ is_forced   : the killing does not depends on the attached mode.
    403  **************************************************************************************/
    404 void thread_kill( xptr_t  thread_xp,
    405                   bool_t  is_exit,
    406                   bool_t  is_forced );
     371 * @ pid         : process identifier (to get the owner cluster identifier).
     372 * @ is_forced   : the deletion does not depends on the attached mode.
     373 **************************************************************************************/
     374void thread_delete( xptr_t  thread_xp,
     375                    pid_t   pid,
     376                    bool_t  is_forced );
    407377
    408378/***************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.