Changeset 581 for trunk/kernel/libk/remote_mutex.h
- Timestamp:
- Oct 10, 2018, 3:11:53 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_mutex.h
r563 r581 29 29 #include <xlist.h> 30 30 31 /*************************************************************************************** 32 * This file definesan user level POSIX compliant mutex.31 /***************************************************************************************** 32 * This file defines the ALMOS-MKH implementation of an user level POSIX compliant mutex. 33 33 * 34 34 * It can be used by muti-threaded user applications to synchronise user threads … … 49 49 * The "remote_mutex_unlock()" function unblocks the first waiting thread in the queue 50 50 * without releasing the mutex if queue is not empty. 51 ************************************************************************************** /51 ****************************************************************************************/ 52 52 53 53 /***************************************************************************************** … … 57 57 typedef struct remote_mutex_s 58 58 { 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 */ 65 65 } 66 66 remote_mutex_t; 67 67 68 /*************************************************************************************** 68 /***************************************************************************************** 69 69 * This function returns an extended pointer on the remote mutex, identified 70 70 * by its virtual address in a given user process. It makes an associative search, 71 71 * scanning the list of mutex rooted in the reference process descriptor. 72 *************************************************************************************** 72 ***************************************************************************************** 73 73 * @ ident : mutex virtual address, used as identifier. 74 74 * @ returns extended pointer on mutex if success / returns XPTR_NULL if not found. 75 ************************************************************************************** /75 ****************************************************************************************/ 76 76 xptr_t remote_mutex_from_ident( intptr_t ident ); 77 77 78 /*************************************************************************************** 78 /***************************************************************************************** 79 79 * This function implements the pthread_mutex_init() syscall. 80 80 * It allocates memory for the mutex descriptor in the reference cluster for 81 81 * the calling process, it initializes the mutex state, and register it in the 82 82 * list of mutex owned by the reference process. 83 *************************************************************************************** 83 ***************************************************************************************** 84 84 * @ ident : mutex identifier (virtual address in user space). 85 85 * @ return 0 if success / ENOMEM if no memory / EINVAL if invalid argument. 86 ************************************************************************************** /86 ****************************************************************************************/ 87 87 error_t remote_mutex_create( intptr_t ident ); 88 88 89 /*************************************************************************************** 89 /***************************************************************************************** 90 90 * This function implements the pthread_mutex_destroy() syscall. 91 91 * It releases thr memory allocated for the mutex descriptor, and remove the mutex 92 92 * from the list of mutex owned by the reference process. 93 *************************************************************************************** 93 ***************************************************************************************** 94 94 * @ mutex_xp : extended pointer on mutex descriptor. 95 ************************************************************************************** /95 ****************************************************************************************/ 96 96 void remote_mutex_destroy( xptr_t mutex_xp ); 97 97 98 /*************************************************************************************** 98 /***************************************************************************************** 99 99 * This blocking function implements the pthread_mutex_lock() syscall. 100 100 * It returns only when the ownership of the mutex identified by the <mutex_xp> 101 101 * argument has been obtained by the calling thread. It register in the mutex waiting 102 102 * queue when the mutex is already taken by another thread. 103 *************************************************************************************** 103 ***************************************************************************************** 104 104 * @ mutex_xp : extended pointer on mutex descriptor. 105 ************************************************************************************** /105 ****************************************************************************************/ 106 106 void remote_mutex_lock( xptr_t mutex_xp ); 107 107 108 /*************************************************************************************** 108 /***************************************************************************************** 109 109 * This function implements the pthread_mutex_unlock() syscall. 110 110 * It cheks that the calling thread is actually the mutex owner. … … 112 112 * It unblocks the first thread registered in the mutex waiting queue, when the 113 113 * queue is not empty. 114 *************************************************************************************** 114 ***************************************************************************************** 115 115 * @ mutex_xp : extended pointer on mutex descriptor. 116 116 * @ return 0 if success / return non zero if calling thread is not mutex owner. 117 ************************************************************************************** /117 ****************************************************************************************/ 118 118 error_t remote_mutex_unlock( xptr_t mutex_xp ); 119 119 120 /*************************************************************************************** 120 /***************************************************************************************** 121 121 * This non blocking function function attempts to lock a mutex without blocking. 122 *************************************************************************************** 122 ***************************************************************************************** 123 123 * @ mutex_xp : extended pointer on mutex descriptor. 124 124 * @ return 0 if success / return non zero if already taken. 125 ************************************************************************************** /125 ****************************************************************************************/ 126 126 error_t remote_mutex_trylock( xptr_t mutex_xp ); 127 127
Note: See TracChangeset
for help on using the changeset viewer.