Tweaks to various bits.
Until I hear otherwise, Refs aren't used enough to merit their own assembly. They are now implemented with locks.
This commit is contained in:
parent
7f11104a57
commit
49588d5d90
11 changed files with 166 additions and 90 deletions
|
|
@ -30,20 +30,20 @@ _gotolabel:
|
|||
ret
|
||||
|
||||
|
||||
.globl _xinc
|
||||
_xinc:
|
||||
movl 4(%esp), %eax
|
||||
lock incl 0(%eax)
|
||||
ret
|
||||
|
||||
.globl _xdec
|
||||
_xdec:
|
||||
movl 4(%esp), %eax
|
||||
lock decl 0(%eax)
|
||||
jz iszero
|
||||
movl $1, %eax
|
||||
ret
|
||||
iszero:
|
||||
movl $0, %eax
|
||||
ret
|
||||
|
||||
# .globl _xinc
|
||||
# _xinc:
|
||||
# movl 4(%esp), %eax
|
||||
# lock incl 0(%eax)
|
||||
# ret
|
||||
#
|
||||
# .globl _xdec
|
||||
# _xdec:
|
||||
# movl 4(%esp), %eax
|
||||
# lock decl 0(%eax)
|
||||
# jz iszero
|
||||
# movl $1, %eax
|
||||
# ret
|
||||
# iszero:
|
||||
# movl $0, %eax
|
||||
# ret
|
||||
#
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ efork(void *ve)
|
|||
for(i=3; i<40; i++)
|
||||
if(i != e->fd[1])
|
||||
close(i);
|
||||
rfork(RFNOTEG);
|
||||
execvp(e->prog, e->args);
|
||||
_threaddebug(DBGEXEC, "_schedexec failed: %r");
|
||||
rerrstr(buf, sizeof buf);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,18 @@
|
|||
void
|
||||
incref(Ref *r)
|
||||
{
|
||||
_xinc(&r->ref);
|
||||
lock(&r->lk);
|
||||
r->ref++;
|
||||
unlock(&r->lk);
|
||||
}
|
||||
|
||||
long
|
||||
decref(Ref *r)
|
||||
{
|
||||
return _xdec(&r->ref);
|
||||
long n;
|
||||
|
||||
lock(&r->lk);
|
||||
n = --r->ref;
|
||||
unlock(&r->lk);
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue