diff options
author | rsc <devnull@localhost> | 2004-12-26 21:51:15 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-12-26 21:51:15 +0000 |
commit | 5f8fa94796903bf81db4f1dc76d433a80308b3d4 (patch) | |
tree | bc94c36965c4bf6cdb420c4c5fe628024647f88e /src/lib9/lock-pthread.c | |
parent | b2ff5382580e13d82ca48966c9d79d3318865cba (diff) | |
download | plan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.tar.gz plan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.tar.bz2 plan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.zip |
cleanups - lots of removed files now in thread library.
qlock.c - stubs to thread library
notify.c - clean interface slightly.
Diffstat (limited to 'src/lib9/lock-pthread.c')
-rw-r--r-- | src/lib9/lock-pthread.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/lib9/lock-pthread.c b/src/lib9/lock-pthread.c deleted file mode 100644 index eb3ea21d..00000000 --- a/src/lib9/lock-pthread.c +++ /dev/null @@ -1,55 +0,0 @@ -#include <u.h> -#include <unistd.h> -#include <sys/time.h> -#include <sched.h> -#include <errno.h> -#include <libc.h> - -static pthread_mutex_t initmutex = PTHREAD_MUTEX_INITIALIZER; - -static void -lockinit(Lock *lk) -{ - pthread_mutexattr_t attr; - - pthread_mutex_lock(&initmutex); - if(lk->init == 0){ - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); - pthread_mutex_init(&lk->mutex, &attr); - pthread_mutexattr_destroy(&attr); - lk->init = 1; - } - pthread_mutex_unlock(&initmutex); -} - -void -lock(Lock *lk) -{ - if(!lk->init) - lockinit(lk); - if(pthread_mutex_lock(&lk->mutex) != 0) - abort(); -} - -int -canlock(Lock *lk) -{ - int r; - - if(!lk->init) - lockinit(lk); - r = pthread_mutex_trylock(&lk->mutex); - if(r == 0) - return 1; - if(r == EBUSY) - return 0; - abort(); -} - -void -unlock(Lock *lk) -{ - if(pthread_mutex_unlock(&lk->mutex) != 0) - abort(); -} |