adding rwlock and event support to mthread

This commit is contained in:
Raja Appuswamy
2011-11-29 14:03:49 +01:00
committed by Ben Gras
parent e2758c6759
commit 03a8d06668
5 changed files with 431 additions and 0 deletions

View File

@@ -56,6 +56,18 @@ struct __mthread_attr {
};
typedef struct __mthread_attr *mthread_attr_t;
typedef struct {
mthread_mutex_t mutex;
mthread_cond_t cond;
} mthread_event_t;
typedef struct {
unsigned int readers;
mthread_thread_t writer;
mthread_mutex_t queue;
mthread_event_t drain;
} mthread_rwlock_t;
#define MTHREAD_CREATE_JOINABLE 001
#define MTHREAD_CREATE_DETACHED 002
#define MTHREAD_ONCE_INIT 0
@@ -122,6 +134,19 @@ _PROTOTYPE( int mthread_mutex_lock, (mthread_mutex_t *mutex) );
_PROTOTYPE( int mthread_mutex_trylock, (mthread_mutex_t *mutex) );
_PROTOTYPE( int mthread_mutex_unlock, (mthread_mutex_t *mutex) );
/* event.c */
_PROTOTYPE( int mthread_event_destroy, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_init, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_wait, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_fire, (mthread_event_t *event) );
/* rwlock.c */
_PROTOTYPE( int mthread_rwlock_destroy, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_init, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_rdlock, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_wrlock, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_unlock, (mthread_rwlock_t *rwlock) );
/* schedule.c */
_PROTOTYPE( void mthread_init, (void) );
_PROTOTYPE( int mthread_yield, (void) );