diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2004-03-19 04:18:42 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-04-06 22:32:34 +0200 |
commit | 4a6de6dc5632fd08588983a4f5bf6ac79d991deb (patch) | |
tree | 2fa6e969d42964208858b11df8a38ee5a0e94b56 /sysdeps/l4/pt-pool-np.c | |
parent | 7e9f8f474cc8d44818a476818f19571e2f54a3d0 (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/pt-pool-np.c')
-rw-r--r-- | sysdeps/l4/pt-pool-np.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c new file mode 100644 index 0000000..c59e15a --- /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; +} |