diff options
Diffstat (limited to 'sysdeps/l4')
-rw-r--r-- | sysdeps/l4/hurd/pt-sysdep.c | 2 | ||||
-rw-r--r-- | sysdeps/l4/pt-block.c | 2 | ||||
-rw-r--r-- | sysdeps/l4/pt-create-np.c | 3 | ||||
-rw-r--r-- | sysdeps/l4/pt-pool-np.c | 3 | ||||
-rw-r--r-- | sysdeps/l4/pt-stack-alloc.c | 27 | ||||
-rw-r--r-- | sysdeps/l4/pt-thread-halt.c | 20 |
6 files changed, 31 insertions, 26 deletions
diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c index f23a137a..265592ca 100644 --- a/sysdeps/l4/hurd/pt-sysdep.c +++ b/sysdeps/l4/hurd/pt-sysdep.c @@ -43,7 +43,7 @@ init_routine (void) __pthread_initialize (); /* Create the pthread structure for the main thread (i.e. us). */ - err = __pthread_create_internal (&thread, 0, 0, 0, 0); + err = __pthread_create_internal (&thread, 0, 0, 0); assert_perror (err); __pthread_initialize (); diff --git a/sysdeps/l4/pt-block.c b/sysdeps/l4/pt-block.c index 5992dc14..933cc285 100644 --- a/sysdeps/l4/pt-block.c +++ b/sysdeps/l4/pt-block.c @@ -25,5 +25,5 @@ void __pthread_block (struct __pthread *thread) { - l4_receive (l4_anylocalthread); + L4_Receive (L4_anylocalthread); } diff --git a/sysdeps/l4/pt-create-np.c b/sysdeps/l4/pt-create-np.c index 57c782cc..68b8b004 100644 --- a/sysdeps/l4/pt-create-np.c +++ b/sysdeps/l4/pt-create-np.c @@ -36,7 +36,8 @@ pthread_create_from_l4_tid_np (pthread_t *thread, int err; struct __pthread *pthread; - err = __pthread_create_internal (&pthread, attr, (void *) &tid, +#warning Does not use TID. + err = __pthread_create_internal (&pthread, attr, start_routine, arg); if (! err) *thread = pthread->thread; diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c index c72f2eb2..f59a3e2b 100644 --- a/sysdeps/l4/pt-pool-np.c +++ b/sysdeps/l4/pt-pool-np.c @@ -26,13 +26,14 @@ _L4_thread_id_t pool_list = l4_nilthread; /* Add the thread TID to the pthread kernel thread pool. */ int -pthread_pool_add_np (_L4_thread_id_t tid) +pthread_pool_add_np (_L4_thread_id_t tid, bool stop) { __pthread_mutex_lock (&pool_lock); /* FIXME: Do error checking. */ l4_set_user_defined_handle_of (tid, pool_list); pool_list = tid; __pthread_mutex_unlock (&pool_lock); + return 0; } diff --git a/sysdeps/l4/pt-stack-alloc.c b/sysdeps/l4/pt-stack-alloc.c index 9a254141..2ede58fd 100644 --- a/sysdeps/l4/pt-stack-alloc.c +++ b/sysdeps/l4/pt-stack-alloc.c @@ -1,5 +1,5 @@ /* Allocate a new stack. L4 Hurd version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2007 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 @@ -19,22 +19,12 @@ #include <l4.h> #include <errno.h> -#include <sys/mman.h> #include <pt-internal.h> -#define __pthread_stacksize __pthread_default_attr.stacksize - - -static void * -allocate_page (void) -{ - return mmap - (NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); -} - +#include <sys/mman.h> -/* Allocate a new stack of size STACKSIZE. If successfull, store the +/* Allocate a new stack of size STACKSIZE. If successful, store the address of the newly allocated stack in *STACKADDR and return 0. Otherwise return an error code (EINVAL for an invalid stack size, EAGAIN if the system lacked the necessary resources to allocate a @@ -42,12 +32,11 @@ allocate_page (void) int __pthread_stack_alloc (void **stackaddr, size_t stacksize) { - if (stacksize != __pthread_stacksize) - return EINVAL; - - *stackaddr = allocate_page (); - if (! *stackaddr) + void *buffer = mmap (0, stacksize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buffer == MAP_FAILED) return EAGAIN; - + + *stackaddr = buffer; return 0; } diff --git a/sysdeps/l4/pt-thread-halt.c b/sysdeps/l4/pt-thread-halt.c index 991123c2..aa2bf43d 100644 --- a/sysdeps/l4/pt-thread-halt.c +++ b/sysdeps/l4/pt-thread-halt.c @@ -24,8 +24,22 @@ /* Deallocate the kernel thread resources associated with THREAD. */ void -__pthread_thread_halt (struct __pthread *thread) +__pthread_thread_halt (struct __pthread *thread, int need_dealloc) { - l4_stop (thread->threadid); - pthread_pool_add_np (thread->threadid); + l4_thread_id_t tid = thread->threadid; + + if (need_dealloc) + __pthread_dealloc (thread); + + /* There is potential race here: once if TID is the current thread, + then once we add TID to the pool, someone can reallocate it + before we call stop. However, to start the thread, the caller + atomically starts and sets the sp and ip, thus, if the stop has + not yet executed at that point, it won't. */ + + if (tid != l4_myself ()) + l4_stop (tid); + pthread_pool_add_np (tid); + if (tid == l4_myself ()) + l4_stop (tid); } |