Ignore:
Timestamp:
Oct 10, 2018, 3:11:53 PM (6 years ago)
Author:
alain
Message:

1) Improve the busylock debug infrastructure.
2) introduce a non-distributed, but portable implementation for the pthread_barrier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/remote_mutex.h

    r563 r581  
    2929#include <xlist.h>
    3030
    31 /***************************************************************************************
    32  *    This file defines an user level POSIX compliant mutex.
     31/*****************************************************************************************
     32 * This file defines the ALMOS-MKH implementation of an user level POSIX compliant mutex.
    3333 *
    3434 * It can be used by muti-threaded user applications to synchronise user threads
     
    4949 * The "remote_mutex_unlock()" function unblocks the first waiting thread in the queue
    5050 * without releasing the mutex if queue is not empty.
    51  **************************************************************************************/
     51 ****************************************************************************************/
    5252
    5353/*****************************************************************************************
     
    5757typedef struct remote_mutex_s
    5858{
    59     remote_busylock_t  lock;            /*! lock protecting the mutex state           */
    60     intptr_t           ident;           /*! mutex identifier (vaddr in user space)    */
    61     uint32_t           taken;           /*! mutex non allocated if 0                  */
    62     xlist_entry_t      list;            /*! member of list of mutex in same process   */
    63     xlist_entry_t      root;            /*! root of list of waiting threads           */
    64     xptr_t             owner;           /*! extended pointer on owner thread          */
     59    remote_busylock_t  lock;            /*! lock protecting the mutex state             */
     60    intptr_t           ident;           /*! mutex identifier (vaddr in user space)      */
     61    uint32_t           taken;           /*! mutex non allocated if 0                    */
     62    xlist_entry_t      list;            /*! member of list of mutex in same process     */
     63    xlist_entry_t      root;            /*! root of list of waiting threads             */
     64    xptr_t             owner;           /*! extended pointer on owner thread            */
    6565}
    6666remote_mutex_t;
    6767
    68 /***************************************************************************************
     68/*****************************************************************************************
    6969 * This function returns an extended pointer on the remote mutex, identified
    7070 * by its virtual address in a given user process. It makes an associative search,
    7171 * scanning the list of mutex rooted in the reference process descriptor.
    72  ***************************************************************************************
     72 *****************************************************************************************
    7373 * @ ident    : mutex virtual address, used as identifier.
    7474 * @ returns extended pointer on mutex if success / returns XPTR_NULL if not found.
    75  **************************************************************************************/
     75 ****************************************************************************************/
    7676xptr_t remote_mutex_from_ident( intptr_t  ident );
    7777
    78 /***************************************************************************************
     78/*****************************************************************************************
    7979 * This function implements the pthread_mutex_init() syscall.
    8080 * It allocates memory for the mutex descriptor in the reference cluster for
    8181 * the calling process, it initializes the mutex state, and register it in the
    8282 * list of mutex owned by the reference process.
    83  ***************************************************************************************
     83 *****************************************************************************************
    8484 * @ ident       : mutex identifier (virtual address in user space).
    8585 * @ return 0 if success / ENOMEM if no memory / EINVAL if invalid argument.
    86  **************************************************************************************/
     86 ****************************************************************************************/
    8787error_t remote_mutex_create( intptr_t ident );
    8888
    89 /***************************************************************************************
     89/*****************************************************************************************
    9090 * This function implements the pthread_mutex_destroy() syscall.
    9191 * It releases thr memory allocated for the mutex descriptor, and remove the mutex
    9292 * from the list of mutex owned by the reference process.
    93  ***************************************************************************************
     93 *****************************************************************************************
    9494 * @ mutex_xp  : extended pointer on mutex descriptor.
    95  **************************************************************************************/
     95 ****************************************************************************************/
    9696void remote_mutex_destroy( xptr_t  mutex_xp );
    9797
    98 /***************************************************************************************
     98/*****************************************************************************************
    9999 * This blocking function implements the pthread_mutex_lock() syscall.
    100100 * It returns only when the ownership of the mutex identified by the <mutex_xp>
    101101 * argument has been obtained by the calling thread. It register in the mutex waiting
    102102 * queue when the mutex is already taken by another thread.
    103  ***************************************************************************************
     103 *****************************************************************************************
    104104 * @ mutex_xp  : extended pointer on mutex descriptor.
    105  **************************************************************************************/
     105 ****************************************************************************************/
    106106void remote_mutex_lock( xptr_t  mutex_xp );
    107107
    108 /***************************************************************************************
     108/*****************************************************************************************
    109109 * This function implements the pthread_mutex_unlock() syscall.
    110110 * It cheks that the calling thread is actually the mutex owner.
     
    112112 * It unblocks the first thread registered in the mutex waiting queue, when the
    113113 * queue is not empty.
    114  ***************************************************************************************
     114 *****************************************************************************************
    115115 * @ mutex_xp  : extended pointer on mutex descriptor.
    116116 * @ return 0 if success / return non zero if calling thread is not mutex owner.
    117  **************************************************************************************/
     117 ****************************************************************************************/
    118118error_t remote_mutex_unlock( xptr_t  mutex_xp );
    119119
    120 /***************************************************************************************
     120/*****************************************************************************************
    121121 * This non blocking function function attempts to lock a mutex without blocking.
    122  ***************************************************************************************
     122 *****************************************************************************************
    123123 * @ mutex_xp  : extended pointer on mutex descriptor.
    124124 * @ return 0 if success / return non zero if already taken.
    125  **************************************************************************************/
     125 ****************************************************************************************/
    126126error_t remote_mutex_trylock( xptr_t  mutex_xp );
    127127
Note: See TracChangeset for help on using the changeset viewer.