summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
authorTom Bachmann <e_mc_h2@web.de>2008-12-15 22:10:12 +0100
committerTom Bachmann <e_mc_h2@web.de>2008-12-15 22:10:12 +0100
commit561aeff59eac9010fbea31dcdb0c3c56f6d7c8f2 (patch)
treec7d97c80b28fe30a5d9dcb43f80c7a961f56a3d8 /libpthread
parent26bcde4109a940375706a4cf6cd6d4700707378f (diff)
parent75d938974b595144f0435711c3f41e51127b32f9 (diff)
Merge commit 'origin/master' into viengoos-x86-64
Conflicts: ChangeLog README configure.ac doc/ChangeLog doc/reference-guide.tex doc/viengoos.tex gcc/ChangeLog gcc/Makefrag.am hurd/stddef.h libc-parts/assert.h libhurd-slab/ChangeLog libl4/ChangeLog libpthread/ChangeLog libpthread/sysdeps/generic/bits/spin-lock-inline.h viengoos/server.c viengoos/thread.c viengoos/thread.h viengoos/viengoos.c
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/ChangeLog62
-rw-r--r--libpthread/Makefile.am1
-rw-r--r--libpthread/pthread/pt-alloc.c2
-rw-r--r--libpthread/sysdeps/generic/bits/spin-lock-inline.h9
-rw-r--r--libpthread/sysdeps/viengoos/bits/pthread-np.h4
-rw-r--r--libpthread/sysdeps/viengoos/ia32/pt-setup.c26
-rw-r--r--libpthread/sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c11
-rw-r--r--libpthread/sysdeps/viengoos/pt-block.c14
-rw-r--r--libpthread/sysdeps/viengoos/pt-hurd-utcb-np.c28
-rw-r--r--libpthread/sysdeps/viengoos/pt-setactivity-np.c5
-rw-r--r--libpthread/sysdeps/viengoos/pt-sysdep.h24
-rw-r--r--libpthread/sysdeps/viengoos/pt-thread-alloc.c67
-rw-r--r--libpthread/sysdeps/viengoos/pt-thread-dealloc.c22
-rw-r--r--libpthread/sysdeps/viengoos/pt-thread-halt.c21
-rw-r--r--libpthread/sysdeps/viengoos/pt-thread-start.c16
-rw-r--r--libpthread/sysdeps/viengoos/pt-wakeup.c7
16 files changed, 213 insertions, 106 deletions
diff --git a/libpthread/ChangeLog b/libpthread/ChangeLog
index 7a3f156..6c6c0d5 100644
--- a/libpthread/ChangeLog
+++ b/libpthread/ChangeLog
@@ -1,3 +1,65 @@
+2008-12-11 Neal H. Walfield <neal@gnu.org>
+
+ Update to new RPC interfaces, IPC semantics.
+
+ * sysdeps/viengoos/bits/pthread-np.h: Include <hurd/exceptions.h>.
+ (pthread_hurd_utcb_np): New declaration.
+ * sysdeps/viengoos/pt-hurd-utcb-np.c: New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-hurd-utcb.c.
+
+ * sysdeps/viengoos/pt-sysdep.h (EXCEPTION_AREA_SIZE): Don't
+ define.
+ (EXCEPTION_AREA_SIZE_LOG2): Likewise.
+ (EXCEPTION_PAGE): Likewise.
+ (PTHREAD_SYSDEP_MEMBERS): Remove fields exception_area, and
+ exception_area_va. Add fields utcb and lock_message_buffer.
+ * sysdeps/viengoos/pt-thread-alloc.c: Include
+ <hurd/message-buffer.h>.
+ (__pthread_thread_alloc): Initialize thread->lock_message_buffer.
+ When executed the first time, set the thread's L4 user-defined
+ handler. Initialize THREAD->UTCB with the thread's current utcb.
+ Set HURD_UTCB to PTHREAD_HURD_UTCB_NP. For subsequent threads,
+ don't manually set up the activation area. Instead, call
+ hurd_activation_state_alloc.
+ * sysdeps/viengoos/pt-thread-dealloc.c: Include
+ <hurd/message-buffer.h>.
+ (__pthread_thread_dealloc): Call __pthread_thread_halt. Don't
+ manually clean up the activation area. Instead, call
+ hurd_activation_state_free. Free THREAD->LOCK_MESSAGE_BUFFER.
+ * sysdeps/viengoos/ia32/pt-setup.c (stack_setup): Pre-fault the
+ first four pages of the new stack.
+ (__pthread_setup): Don't set up the activation area.
+
+ * sysdeps/viengoos/pt-wakeup.c (__pthread_wakeup): Use
+ futex_wake_using with the calling thread's lock messenger.
+ * sysdeps/viengoos/pt-block.c (__pthread_block): Use
+ futex_wait_using and provide THREAD->LOCK_MESSAGE_BUFFER as the
+ message buffer.
+
+ * sysdeps/viengoos/pt-thread-start.c (__pthread_thread_start):
+ Don't set the first thread's L4 user-defined handler here.
+ (__pthread_thread_start): Update use of rm_thread_exregs according
+ to be consistent with new interface.
+ * sysdeps/viengoos/pt-thread-halt.c (__pthread_thread_halt): If
+ THREAD is the current thread, call vg_suspend.
+
+ * sysdeps/viengoos/pt-setactivity-np.c (pthread_setactivity_np):
+ Update use of rm_thread_exregs according to be consistent with new
+ interface.
+ * sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c
+ (signal_dispatch_lowlevel): Use __builtin_frame_address to get the
+ current stack frame's start. Update use of rm_thread_exregs
+ according to be consistent with new interface.
+
+2008-12-11 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/generic/bits/spin-lock-inline.h: New file.
+
+2008-12-11 Neal H. Walfield <neal@gnu.org>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Use calloc, not malloc, to
+ allocate a new struct __pthread.
+
2008-11-19 Neal H. Walfield <neal@gnu.org>
* sysdeps/generic/bits/memory.h: New file.
diff --git a/libpthread/Makefile.am b/libpthread/Makefile.am
index a4d226d..4e820de 100644
--- a/libpthread/Makefile.am
+++ b/libpthread/Makefile.am
@@ -135,6 +135,7 @@ libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
sem-post.c sem-unlink.c \
\
pt-setactivity-np.c \
+ pt-hurd-utcb-np.c \
\
kill.c \
killpg.c \
diff --git a/libpthread/pthread/pt-alloc.c b/libpthread/pthread/pt-alloc.c
index 6af2da9..c63801f 100644
--- a/libpthread/pthread/pt-alloc.c
+++ b/libpthread/pthread/pt-alloc.c
@@ -123,7 +123,7 @@ __pthread_alloc (struct __pthread **pthread)
}
/* Allocate a new thread structure. */
- new = malloc (sizeof (struct __pthread));
+ new = calloc (sizeof (struct __pthread), 1);
if (new == NULL)
return ENOMEM;
diff --git a/libpthread/sysdeps/generic/bits/spin-lock-inline.h b/libpthread/sysdeps/generic/bits/spin-lock-inline.h
index 119063a..6c3e06e 100644
--- a/libpthread/sysdeps/generic/bits/spin-lock-inline.h
+++ b/libpthread/sysdeps/generic/bits/spin-lock-inline.h
@@ -31,9 +31,14 @@ __BEGIN_DECLS
#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
-# ifndef __EBUSY
+# if !defined (__EBUSY) || !defined (__EINVAL)
# include <errno.h>
-# define __EBUSY EBUSY
+# ifndef __EBUSY
+# define __EBUSY EBUSY
+# endif
+# ifndef __EINVAL
+# define __EINVAL EINVAL
+# endif
# endif
# ifndef __PT_SPIN_INLINE
diff --git a/libpthread/sysdeps/viengoos/bits/pthread-np.h b/libpthread/sysdeps/viengoos/bits/pthread-np.h
index a90793d..aea3bab 100644
--- a/libpthread/sysdeps/viengoos/bits/pthread-np.h
+++ b/libpthread/sysdeps/viengoos/bits/pthread-np.h
@@ -25,7 +25,11 @@
#define _BITS_PTHREAD_NP_H 1
#include <hurd/addr.h>
+#include <hurd/exceptions.h>
int pthread_setactivity_np (addr_t activity);
+/* Returns the caller's activation state block. */
+struct vg_utcb *pthread_hurd_utcb_np (void) __attribute__ ((pure));
+
#endif /* bits/pthread-np.h */
diff --git a/libpthread/sysdeps/viengoos/ia32/pt-setup.c b/libpthread/sysdeps/viengoos/ia32/pt-setup.c
index 579905c..88a60e8 100644
--- a/libpthread/sysdeps/viengoos/ia32/pt-setup.c
+++ b/libpthread/sysdeps/viengoos/ia32/pt-setup.c
@@ -73,7 +73,7 @@ stack_setup (struct __pthread *thread,
top = (uintptr_t *) ((uintptr_t) thread->stackaddr + thread->stacksize);
/* Align on 0x10 for MMX operations. */
- top = (uintptr_t) top & ~0xf;
+ top = (uintptr_t *) ((uintptr_t) top & ~0xf);
if (start_routine)
{
@@ -84,6 +84,12 @@ stack_setup (struct __pthread *thread,
*--top = (uintptr_t) entry_point;
}
+ /* We need 4 pages of stack to avoid faulting before we have set up
+ the activation area. Make it so. */
+ int i;
+ for (i = 1; i < 4; i ++)
+ top[-i * PAGESIZE] = 0;
+
return top;
}
@@ -95,23 +101,5 @@ __pthread_setup (struct __pthread *thread,
thread->mcontext.pc = (void *) &_pthread_entry_point;
thread->mcontext.sp = (void *) stack_setup (thread, start_routine, arg,
entry_point);
-
- if (__pthread_num_threads == 1)
- return 0;
-
- assert (! ADDR_IS_VOID (thread->exception_area[0]));
-
- struct exception_page *exception_page = thread->exception_area_va;
-
- /* SP is set to the end of the exception area minus one word, which
- is the location of the exception page. */
- exception_page->exception_handler_sp
- = (uintptr_t) thread->exception_area_va + EXCEPTION_AREA_SIZE;
- exception_page->exception_handler_sp -= sizeof (void *);
- * (void **) exception_page->exception_handler_sp = thread->exception_area_va;
-
- exception_page->exception_handler_ip = (uintptr_t) &exception_handler_entry;
- exception_page->exception_handler_end = (uintptr_t) &exception_handler_end;
-
return 0;
}
diff --git a/libpthread/sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c b/libpthread/sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c
index 37ef821..8dd9be7 100644
--- a/libpthread/sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c
+++ b/libpthread/sysdeps/viengoos/ia32/signal-dispatch-lowlevel.c
@@ -113,8 +113,9 @@ signal_dispatch_lowlevel (struct signal_state *ss, pthread_t tid,
if (self)
{
- /* The return address is just before the first argument. */
- intr_sp = (uintptr_t) &ss - 4;
+ /* The return address is 4 bytes offset from the start of the
+ stack frame. */
+ intr_sp = (uintptr_t) __builtin_frame_address (0) + 4;
assert (* (void **) intr_sp == __builtin_return_address (0));
}
else
@@ -127,7 +128,8 @@ signal_dispatch_lowlevel (struct signal_state *ss, pthread_t tid,
err = rm_thread_exregs (ADDR_VOID, thread->object,
HURD_EXREGS_STOP | HURD_EXREGS_ABORT_IPC
| HURD_EXREGS_GET_REGS,
- in, &out);
+ in, ADDR_VOID, ADDR_VOID, ADDR_VOID, ADDR_VOID,
+ &out, NULL, NULL, NULL, NULL);
if (err)
panic ("Failed to modify thread " ADDR_FMT,
ADDR_PRINTF (thread->object));
@@ -208,6 +210,7 @@ signal_dispatch_lowlevel (struct signal_state *ss, pthread_t tid,
rm_thread_exregs (ADDR_VOID, thread->object,
HURD_EXREGS_SET_SP_IP
| HURD_EXREGS_START | HURD_EXREGS_ABORT_IPC,
- in, &out);
+ in, ADDR_VOID, ADDR_VOID, ADDR_VOID, ADDR_VOID,
+ &out, NULL, NULL, NULL, NULL);
}
}
diff --git a/libpthread/sysdeps/viengoos/pt-block.c b/libpthread/sysdeps/viengoos/pt-block.c
index 2315b1c..548cc3f 100644
--- a/libpthread/sysdeps/viengoos/pt-block.c
+++ b/libpthread/sysdeps/viengoos/pt-block.c
@@ -26,5 +26,17 @@
void
__pthread_block (struct __pthread *thread)
{
- futex_wait (&thread->threadid, thread->threadid);
+ assert (thread->lock_message_buffer);
+
+ struct hurd_message_buffer *mb = thread->lock_message_buffer;
+#ifndef NDEBUG
+ /* Try to detect recursive locks, which we don't handle. */
+ thread->lock_message_buffer = NULL;
+#endif
+
+ futex_wait_using (mb, &thread->threadid, thread->threadid);
+
+#ifndef NDEBUG
+ thread->lock_message_buffer = mb;
+#endif
}
diff --git a/libpthread/sysdeps/viengoos/pt-hurd-utcb-np.c b/libpthread/sysdeps/viengoos/pt-hurd-utcb-np.c
new file mode 100644
index 0000000..b3a76f4
--- /dev/null
+++ b/libpthread/sysdeps/viengoos/pt-hurd-utcb-np.c
@@ -0,0 +1,28 @@
+/* pt-hurd-utcb-np.c: Return the calling thread's utcb.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <pt-internal.h>
+
+struct vg_utcb *
+pthread_hurd_utcb_np (void)
+{
+ struct __pthread *thread = _pthread_self ();
+ return thread->utcb;
+}
+
diff --git a/libpthread/sysdeps/viengoos/pt-setactivity-np.c b/libpthread/sysdeps/viengoos/pt-setactivity-np.c
index f2f0723..efcc9b7 100644
--- a/libpthread/sysdeps/viengoos/pt-setactivity-np.c
+++ b/libpthread/sysdeps/viengoos/pt-setactivity-np.c
@@ -28,12 +28,11 @@ pthread_setactivity_np (addr_t activity)
struct __pthread *self = _pthread_self ();
struct hurd_thread_exregs_in in;
- in.activity = activity;
-
struct hurd_thread_exregs_out out;
int err = rm_thread_exregs (ADDR_VOID, self->object,
HURD_EXREGS_SET_ACTIVITY,
- in, &out);
+ in, ADDR_VOID, activity, ADDR_VOID, ADDR_VOID,
+ &out, NULL, NULL, NULL, NULL);
return err;
}
diff --git a/libpthread/sysdeps/viengoos/pt-sysdep.h b/libpthread/sysdeps/viengoos/pt-sysdep.h
index 5e9fabd..0733640 100644
--- a/libpthread/sysdeps/viengoos/pt-sysdep.h
+++ b/libpthread/sysdeps/viengoos/pt-sysdep.h
@@ -31,20 +31,16 @@
#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024)
#include <hurd/exceptions.h>
-
-#define EXCEPTION_AREA_SIZE EXCEPTION_STACK_SIZE
-#define EXCEPTION_AREA_SIZE_LOG2 EXCEPTION_STACK_SIZE_LOG2
-/* The exception page is the first object. */
-#define EXCEPTION_PAGE 0
-
-#define PTHREAD_SYSDEP_MEMBERS \
- addr_t object; \
- l4_thread_id_t threadid; \
- addr_t exception_area[EXCEPTION_AREA_SIZE / PAGESIZE]; \
- void *exception_area_va; \
- /* If the above four fields are valid. */ \
- bool have_kernel_resources; \
- l4_word_t my_errno;
+#include <hurd/message-buffer.h>
+
+#define PTHREAD_SYSDEP_MEMBERS \
+ addr_t object; \
+ vg_thread_id_t threadid; \
+ struct vg_utcb *utcb; \
+ struct hurd_message_buffer *lock_message_buffer; \
+ /* If the above fields are valid. */ \
+ bool have_kernel_resources; \
+ uintptr_t my_errno;
extern inline struct __pthread *
__attribute__((__always_inline__))
diff --git a/libpthread/sysdeps/viengoos/pt-thread-alloc.c b/libpthread/sysdeps/viengoos/pt-thread-alloc.c
index 11af1d0..3cc02be 100644
--- a/libpthread/sysdeps/viengoos/pt-thread-alloc.c
+++ b/libpthread/sysdeps/viengoos/pt-thread-alloc.c
@@ -25,6 +25,7 @@
#include <hurd/storage.h>
#include <hurd/as.h>
#include <hurd/addr.h>
+#include <hurd/message-buffer.h>
#include <pt-internal.h>
@@ -38,45 +39,24 @@ __pthread_thread_alloc (struct __pthread *thread)
if (thread->have_kernel_resources)
return 0;
+ thread->lock_message_buffer = hurd_message_buffer_alloc_long ();
/* The main thread is already running of course. */
if (__pthread_num_threads == 1)
{
thread->object = __hurd_startup_data->thread;
thread->threadid = l4_myself ();
+
+ l4_set_user_defined_handle ((l4_word_t) thread);
+
+ /* Get the thread's UTCB and stash it. */
+ thread->utcb = hurd_utcb ();
+ /* Override the utcb fetch function. */
+ hurd_utcb = pthread_hurd_utcb_np;
+ assert (thread->utcb == hurd_utcb ());
}
else
{
- addr_t exception_area = as_alloc (EXCEPTION_AREA_SIZE_LOG2, 1, true);
-
- thread->exception_area_va
- = ADDR_TO_PTR (addr_extend (exception_area,
- 0, EXCEPTION_AREA_SIZE_LOG2));
-
- int i;
- for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++)
- {
- addr_t slot = addr_chop (PTR_TO_ADDR (thread->exception_area_va
- + i * PAGESIZE),
- PAGESIZE_LOG2);
- as_ensure (slot);
-
- struct storage storage = storage_alloc (ADDR_VOID, cap_page,
- STORAGE_LONG_LIVED,
- OBJECT_POLICY_DEFAULT,
- slot);
- if (ADDR_IS_VOID (storage.addr))
- {
- int j;
- for (j = 0; j < i; j ++)
- storage_free (thread->exception_area[j], false);
- as_free (exception_area, false);
- return EAGAIN;
- }
-
- thread->exception_area[i] = storage.addr;
- }
-
struct storage storage;
storage = storage_alloc (meta_data_activity, cap_thread,
/* Threads are rarely shortly lived. */
@@ -84,14 +64,33 @@ __pthread_thread_alloc (struct __pthread *thread)
ADDR_VOID);
if (ADDR_IS_VOID (storage.addr))
{
- int j;
- for (j = 0; j < EXCEPTION_AREA_SIZE / PAGESIZE; j ++)
- storage_free (thread->exception_area[j], false);
- as_free (exception_area, false);
+ debug (0, DEBUG_BOLD ("Out of memory"));
return EAGAIN;
}
thread->object = storage.addr;
+
+ error_t err;
+ err = hurd_activation_state_alloc (thread->object, &thread->utcb);
+ if (unlikely (err))
+ panic ("Failed to initialize thread's activation state: %d", err);
+
+ err = rm_cap_copy (ADDR_VOID,
+ thread->lock_message_buffer->receiver,
+ ADDR (VG_MESSENGER_THREAD_SLOT,
+ VG_MESSENGER_SLOTS_LOG2),
+ ADDR_VOID, thread->object,
+ 0, CAP_PROPERTIES_DEFAULT);
+ if (err)
+ panic ("Failed to set lock messenger's thread");
+
+ /* Unblock the lock messenger. */
+ err = vg_ipc (VG_IPC_RECEIVE | VG_IPC_RECEIVE_ACTIVATE
+ | VG_IPC_RETURN,
+ ADDR_VOID, thread->lock_message_buffer->receiver, ADDR_VOID,
+ ADDR_VOID, ADDR_VOID, ADDR_VOID, ADDR_VOID);
+ if (err)
+ panic ("Failed to unblock messenger's thread");
}
thread->have_kernel_resources = true;
diff --git a/libpthread/sysdeps/viengoos/pt-thread-dealloc.c b/libpthread/sysdeps/viengoos/pt-thread-dealloc.c
index 71b3d96..9e174a9 100644
--- a/libpthread/sysdeps/viengoos/pt-thread-dealloc.c
+++ b/libpthread/sysdeps/viengoos/pt-thread-dealloc.c
@@ -26,30 +26,20 @@
#include <hurd/mutex.h>
#include <hurd/as.h>
#include <hurd/addr.h>
+#include <hurd/message-buffer.h>
void
__pthread_thread_dealloc (struct __pthread *thread)
{
assert (thread != _pthread_self ());
- /* Clean up the exception page. */
- exception_page_cleanup
- (ADDR_TO_PTR (addr_extend (thread->exception_area[EXCEPTION_PAGE],
- 0, PAGESIZE_LOG2)));
+ __pthread_thread_halt (thread);
- /* Free the storage. */
- int i;
- for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++)
- {
- assert (! ADDR_IS_VOID (thread->exception_area[i]));
- storage_free (thread->exception_area[i], false);
- }
+ /* Clean up the activation state. */
+ hurd_activation_state_free (thread->utcb);
- /* And the address space. */
- as_free (addr_chop (PTR_TO_ADDR (thread->exception_area_va),
- EXCEPTION_AREA_SIZE_LOG2), false);
-
- storage_free (thread->object, false);
+ assert (thread->lock_message_buffer);
+ hurd_message_buffer_free (thread->lock_message_buffer);
thread->have_kernel_resources = 0;
}
diff --git a/libpthread/sysdeps/viengoos/pt-thread-halt.c b/libpthread/sysdeps/viengoos/pt-thread-halt.c
index aef1395..cfa861b 100644
--- a/libpthread/sysdeps/viengoos/pt-thread-halt.c
+++ b/libpthread/sysdeps/viengoos/pt-thread-halt.c
@@ -27,6 +27,25 @@
void
__pthread_thread_halt (struct __pthread *thread)
{
+ /* We need to be careful. This function is called in three
+ situations: by the thread itself when it is about to exit, by a
+ thread joining it, and when reusing an existing thread. Hence,
+ it must be kosher to interrupt this functions execution at any
+ point: syncronization is difficult as in the first case, there is
+ no way to indicate completion. */
if (thread->have_kernel_resources)
- thread_stop (thread->object);
+ {
+ if (thread == _pthread_self ())
+ {
+ while (1)
+ vg_suspend ();
+ }
+ else
+ {
+ error_t err = thread_stop (thread->object);
+ if (err)
+ panic ("Failed to halt " ADDR_FMT ": %d",
+ ADDR_PRINTF (thread->object), err);
+ }
+ }
}
diff --git a/libpthread/sysdeps/viengoos/pt-thread-start.c b/libpthread/sysdeps/viengoos/pt-thread-start.c
index 9db399c..f03f4c2 100644
--- a/libpthread/sysdeps/viengoos/pt-thread-start.c
+++ b/libpthread/sysdeps/viengoos/pt-thread-start.c
@@ -1,5 +1,5 @@
-/* Start thread. L4 version.
- Copyright (C) 2007 Free Software Foundation, Inc.
+/* Start thread. Viengoos version.
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -35,21 +35,17 @@ __pthread_thread_start (struct __pthread *thread)
{
assert (__pthread_total == 1);
assert (l4_is_thread_equal (l4_myself (), thread->threadid));
- l4_set_user_defined_handle ((l4_word_t) thread);
}
else
{
struct hurd_thread_exregs_in in;
struct hurd_thread_exregs_out out;
- in.aspace = ADDR (0, 0);
+ addr_t aspace = ADDR (0, 0);
in.aspace_cap_properties = CAP_PROPERTIES_VOID;
in.aspace_cap_properties_flags = CAP_COPY_COPY_SOURCE_GUARD;
- in.activity = ADDR_VOID;
-
- in.exception_page = addr_chop (PTR_TO_ADDR (thread->exception_area_va),
- PAGESIZE_LOG2);
+ addr_t activity = ADDR_VOID;
in.sp = (l4_word_t) thread->mcontext.sp;
in.ip = (l4_word_t) thread->mcontext.pc;
@@ -58,12 +54,12 @@ __pthread_thread_start (struct __pthread *thread)
err = rm_thread_exregs (ADDR_VOID, thread->object,
HURD_EXREGS_SET_ASPACE
| HURD_EXREGS_SET_ACTIVITY
- | HURD_EXREGS_SET_EXCEPTION_PAGE
| HURD_EXREGS_SET_SP_IP
| HURD_EXREGS_SET_USER_HANDLE
| HURD_EXREGS_START
| HURD_EXREGS_ABORT_IPC,
- in, &out);
+ in, aspace, activity, ADDR_VOID, ADDR_VOID,
+ &out, NULL, NULL, NULL, NULL);
assert (err == 0);
}
return 0;
diff --git a/libpthread/sysdeps/viengoos/pt-wakeup.c b/libpthread/sysdeps/viengoos/pt-wakeup.c
index e568a6f..60804ea 100644
--- a/libpthread/sysdeps/viengoos/pt-wakeup.c
+++ b/libpthread/sysdeps/viengoos/pt-wakeup.c
@@ -27,6 +27,10 @@
void
__pthread_wakeup (struct __pthread *thread)
{
+ struct __pthread *self = _pthread_self ();
+ assert (self != thread);
+ assert (self->lock_message_buffer);
+
/* We need to loop here as the blocked thread may not yet be
blocked! Here's what happens when a thread blocks: it registers
itself as blocked, drops the relevant lock and then actually
@@ -36,7 +40,8 @@ __pthread_wakeup (struct __pthread *thread)
long ret;
do
{
- ret = futex_wake (&thread->threadid, INT_MAX);
+ ret = futex_wake_using (self->lock_message_buffer,
+ &thread->threadid, INT_MAX);
assertx (ret <= 1, "tid: %x, ret: %d", thread->threadid, ret);
if (ret == 0)