| plan 9 kernel history: overview | file list | diff list |
1990/0403/gnot/lock.c (diff list | history)
| 1990/0312/sys/src/9/gnot/lock.c:4,9 – 1990/0403/sys/src/9/gnot/lock.c:4,18 (short | long | prev | next) | ||
| 1990/03091 | #include "dat.h" #include "fns.h" | |
| 1990/0403 | #define PCOFF -2 /* * N.B. Ken's compiler generates a TAS instruction for the sequence: * * if(l->key >= 0){ * l->key |= 0x80; * ... */ | |
| 1990/03091 | void lock(Lock *l) { | |
| 1990/0312/sys/src/9/gnot/lock.c:12,35 – 1990/0403/sys/src/9/gnot/lock.c:21,49 | ||
| 1990/03091 | /* * Try the fast grab first */ | |
| 1990/0403 | if(l->key >= 0){ l->key |= 0x80; l->pc = ((ulong*)&i)[PCOFF]; | |
| 1990/03091 | return; } for(i=0; i<10000000; i++) | |
| 1990/0403 | if(l->key >= 0){ l->key |= 0x80; l->pc = ((ulong*)&i)[PCOFF]; | |
| 1990/03091 | return; } | |
| 1990/0403 | l->key = 0; panic("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&i)[PCOFF], l->pc); | |
| 1990/03091 | } int canlock(Lock *l) { | |
| 1990/0403 | int i; if(l->key >= 0){ l->key |= 0x80; l->pc = ((ulong*)&i)[PCOFF]; | |
| 1990/03091 | return 1; } return 0; | |
| 1990/0312/sys/src/9/gnot/lock.c:39,45 – 1990/0403/sys/src/9/gnot/lock.c:53,59 | ||
| 1990/03091 | unlock(Lock *l) { l->pc = 0; | |
| 1990/0403 | l->key = 0; | |
| 1990/03091 | } void | |