aboutsummaryrefslogtreecommitdiff
path: root/src/libthread
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread')
-rw-r--r--src/libthread/asm-FreeBSD-386.s34
-rw-r--r--src/libthread/exec-unix.c1
-rw-r--r--src/libthread/ref.c11
3 files changed, 27 insertions, 19 deletions
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;
}