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-tas.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-tas.c')
-rw-r--r-- | src/lib9/lock-tas.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/lib9/lock-tas.c b/src/lib9/lock-tas.c deleted file mode 100644 index e6f54de6..00000000 --- a/src/lib9/lock-tas.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <u.h> -#include <unistd.h> -#include <sys/time.h> -#include <sched.h> -#include <libc.h> - -int _ntas; -static int -_xtas(void *v) -{ - int x; - - _ntas++; - x = _tas(v); - if(x != 0 && x != 0xcafebabe){ - print("bad tas value %d\n", x); - abort(); - } - return x; -} - -int -canlock(Lock *l) -{ - return !_xtas(&l->val); -} - -void -unlock(Lock *l) -{ - l->val = 0; -} - -void -lock(Lock *lk) -{ - int i; - - /* once fast */ - if(!_xtas(&lk->val)) - return; - /* a thousand times pretty fast */ - for(i=0; i<1000; i++){ - if(!_xtas(&lk->val)) - return; - sched_yield(); - } - /* now nice and slow */ - for(i=0; i<1000; i++){ - if(!_xtas(&lk->val)) - return; - usleep(100*1000); - } - /* take your time */ - while(_xtas(&lk->val)) - usleep(1000*1000); -} |