summaryrefslogtreecommitdiff
path: root/sysdeps/l4
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2004-03-19 04:18:42 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-06 22:32:34 +0200
commit0d723d7f3a762f106de2f95af2fdaaa650359d80 (patch)
treed1b0d7355013332e6708a940379c9fedc5177c1b /sysdeps/l4
parent0ba014f072e0d19c16d0584672ec9f65cc451a54 (diff)
2004-03-19 Marcus Brinkmann <marcus@gnu.org>
* sysdeps/l4/bits/pthread-np.h (pthread_pool_add_np, pthread_pool_get_np): New prototypes. * sysdeps/l4/pt-pool-np.c: New file. * Makefile.am (libpthread_a_SOURCES): Add pt-pool-np.c. * sysdeps/l4/pt-thread-alloc.c (__pthread_thread_alloc): Try to allocate thread from pool. * sysdeps/l4/pt-thread-halt.c (__pthread_thread_halt): Add thread to pool after stopping it.
Diffstat (limited to 'sysdeps/l4')
-rw-r--r--sysdeps/l4/bits/pthread-np.h6
-rw-r--r--sysdeps/l4/pt-pool-np.c52
-rw-r--r--sysdeps/l4/pt-thread-alloc.c4
-rw-r--r--sysdeps/l4/pt-thread-halt.c6
4 files changed, 65 insertions, 3 deletions
diff --git a/sysdeps/l4/bits/pthread-np.h b/sysdeps/l4/bits/pthread-np.h
index b487e6dc..7e807107 100644
--- a/sysdeps/l4/bits/pthread-np.h
+++ b/sysdeps/l4/bits/pthread-np.h
@@ -35,4 +35,10 @@ extern int pthread_create_from_l4_tid_np (pthread_t *thread,
void *(*start_routine)(void *),
void *arg);
+/* Add the thread TID to the internal kernel thread pool. */
+int pthread_pool_add_np (l4_thread_id_t tid);
+
+/* Get the first thread from the pool. */
+l4_thread_id_t pthread_pool_get_np (void);
+
#endif /* bits/pthread-np.h */
diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c
new file mode 100644
index 00000000..c59e15a9
--- /dev/null
+++ b/sysdeps/l4/pt-pool-np.c
@@ -0,0 +1,52 @@
+/* Thread pool for L4 threads.
+ Copyright (C) 2004 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>
+#include <l4/thread.h>
+
+static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER;
+
+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_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;
+}
+
+
+/* Get the first thread from the pool. */
+l4_thread_id_t
+pthread_pool_get_np (void)
+{
+ l4_thread_id_t tid;
+
+ __pthread_mutex_lock (&pool_lock);
+ /* FIXME: Do error checking. */
+ tid = pool_list;
+ pool_list = l4_user_defined_handle_of (tid);
+ __pthread_mutex_unlock (&pool_lock);
+ return tid;
+}
diff --git a/sysdeps/l4/pt-thread-alloc.c b/sysdeps/l4/pt-thread-alloc.c
index 00e99ff9..07784f5f 100644
--- a/sysdeps/l4/pt-thread-alloc.c
+++ b/sysdeps/l4/pt-thread-alloc.c
@@ -36,6 +36,10 @@ __pthread_thread_alloc (struct __pthread *thread)
}
else
{
+ thread->threadid = pthread_pool_get_np ();
+ if (thread->threadid != l4_nilthread)
+ return 0;
+
#if 0
CORBA_Environment env;
diff --git a/sysdeps/l4/pt-thread-halt.c b/sysdeps/l4/pt-thread-halt.c
index ea97eea0..991123c2 100644
--- a/sysdeps/l4/pt-thread-halt.c
+++ b/sysdeps/l4/pt-thread-halt.c
@@ -1,5 +1,5 @@
-/* Deallocate the kernel thread resources. Mach version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+/* Deallocate the kernel thread resources. L4version.
+ Copyright (C) 2000, 2002, 2004 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
@@ -26,6 +26,6 @@
void
__pthread_thread_halt (struct __pthread *thread)
{
- /* FIXME reuse thread somehow */
l4_stop (thread->threadid);
+ pthread_pool_add_np (thread->threadid);
}