|
|
1.1 root 1: #include <u.h>
2: #include <libc.h>
3: #include <lock.h>
4:
5: int tas(int*);
6:
7: void
8: lockinit(void)
9: {
10: }
11:
12: void
13: lock(Lock *lk)
14: {
15: while(tas(&lk->val))
16: sleep(0);
17: }
18:
19: int
20: canlock(Lock *lk)
21: {
22: if(tas(&lk->val))
23: return 0;
24: return 1;
25: }
26:
27: void
28: unlock(Lock *lk)
29: {
30: lk->val = 0;
31: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.