| plan 9 kernel history: overview | file list | diff list |
1995/0109/port/taslock.c (diff list | history)
| port/taslock.c on 1992/0222 | ||
| 1992/0222 | #include "u.h" | |
| 1992/0321 | #include "../port/lib.h" | |
| 1992/0222 | #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" void lock(Lock *l) { | |
| 1995/0108 | int n; if(up) { n = up->inlock+2; up->inlock = n; if(tas(&l->key) == 0) return; for(;;){ while(l->key) if(conf.nproc == 1) { up->yield = 1; sched(); } up->inlock = n; if(tas(&l->key) == 0) return; } } | |
| 1993/1204 | if(tas(&l->key) == 0) return; | |
| 1993/0830 | for(;;){ | |
| 1994/0808 | while(l->key) ; | |
| 1993/0830 | if(tas(&l->key) == 0) | |
| 1992/0222 | return; } } | |
| 1995/0109 | int canlock(Lock *l) | |
| 1994/0322 | { | |
| 1995/0109 | int n; | |
| 1994/0323 | ||
| 1995/0109 | if(up) { n = up->inlock; up->inlock = n+2; if(tas(&l->key)) { up->inlock = n; return 0; | |
| 1994/0323 | } | |
| 1995/0109 | return 1; | |
| 1994/0322 | } | |
| 1992/0222 | if(tas(&l->key)) return 0; return 1; } void unlock(Lock *l) { | |
| 1995/0108 | int n; if(up) { n = up->inlock-2; if(n < 0) n = 0; up->inlock = n; } | |
| 1995/0109 | l->key = 0; | |
| 1994/0322 | } void | |
| 1995/0109 | ilock(Lock *l) { ulong sr; sr = splhi(); lock(l); l->sr = sr; } void | |
| 1994/0322 | iunlock(Lock *l) { ulong sr; sr = l->sr; | |
| 1995/0109 | unlock(l); | |
| 1994/0322 | splx(sr); | |
| 1992/0222 | } | |