From 49588d5d9089589ccda28c41aae90c29d6f72787 Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 17 Dec 2003 04:34:52 +0000 Subject: Tweaks to various bits. Until I hear otherwise, Refs aren't used enough to merit their own assembly. They are now implemented with locks. --- src/libthread/asm-FreeBSD-386.s | 34 +++++++++++++++++----------------- src/libthread/exec-unix.c | 1 + src/libthread/ref.c | 11 +++++++++-- 3 files changed, 27 insertions(+), 19 deletions(-) (limited to 'src/libthread') diff --git a/src/libthread/asm-FreeBSD-386.s b/src/libthread/asm-FreeBSD-386.s index 074556f9..35e2ab6f 100644 --- a/src/libthread/asm-FreeBSD-386.s +++ b/src/libthread/asm-FreeBSD-386.s @@ -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 +# diff --git a/src/libthread/exec-unix.c b/src/libthread/exec-unix.c index 97c75607..c04d414c 100644 --- a/src/libthread/exec-unix.c +++ b/src/libthread/exec-unix.c @@ -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); diff --git a/src/libthread/ref.c b/src/libthread/ref.c index 9b78e63e..8f50fd5f 100644 --- a/src/libthread/ref.c +++ b/src/libthread/ref.c @@ -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; } -- cgit v1.2.3