00001 00007 #ifndef RWLOCK_H_ 00008 #define RWLOCK_H_ 00009 00010 #include "thread.h" 00011 #include "tqueue.h" 00012 #include "io.h" 00013 00014 00015 struct rwlock { 00017 unsigned int w_count; 00019 unsigned int r_count; 00021 thread_t writing_thread; 00023 thread_queue_t w_queue; 00025 thread_queue_t r_queue; 00026 }; 00027 00028 typedef struct rwlock rwlock_t; 00029 00030 void rwlock_init (rwlock_t * rwl); 00031 void rwlock_destroy(rwlock_t * rwl); 00032 void rwlock_read_lock (rwlock_t * rwl); 00033 void rwlock_write_lock (rwlock_t * rwl); 00034 int rwlock_read_timeout (rwlock_t * rwl, const unsigned int usec); 00035 int rwlock_write_timeout (rwlock_t * rwl, const unsigned int usec); 00036 void rwlock_write_unlock (rwlock_t * rwl); 00037 void rwlock_read_unlock (rwlock_t * rwl); 00038 00039 #endif /*RWLOCK_H_*/