summaryrefslogtreecommitdiff
path: root/ruth
diff options
context:
space:
mode:
authorneal <neal>2007-11-23 13:39:36 +0000
committerneal <neal>2007-11-23 13:39:36 +0000
commit063d8339dfe16b6035375a00f3a6313f2dff083c (patch)
tree6e37ef358183bf00e277da95f46f2586f597bd64 /ruth
parent2b62e6480aaa4c3dcb73f45fa4977d6b2e7de080 (diff)
/
2007-11-23 Neal H. Walfield <neal@gnu.org> * README: Add note that Pistachio must be compiled with the Pager ExchangeRegisters configure option enabled. hurd/ 2007-11-23 Neal H. Walfield <neal@gnu.org> * thread.h: Include <hurd/addr-trans.h>. (HURD_EXREGS_EXCEPTION_THREAD): New definition. (trans_exregs): Take two additional arguments for determining how to copy the aspace address translation bits. Update callers. (thread_stop): New function. * rpc.h (RPC12_4): New macro. (RPC13_4): Likewise. * exceptions.h (exception_handler_init): New declaration. (exception_handler_loop): Likewise. libhurd-mm/ 2007-11-23 Neal H. Walfield <neal@gnu.org> * exceptions.c (exception_thread): Rename from this... (exception_handler_loop): ... to this. Update caller. * Makefile.am (libhurd_mm_a_SOURCES): Remove exceptions.h. * exceptions.h: Remove file. viengoos/ 2007-11-23 Neal H. Walfield <neal@gnu.org> * thread.h (thread_exregs): Take two additional arguments, a cap_addr_trans structure and a corresponding flags. Update users. * thread.c (thread_commission): Don't start thread THREAD. (control_to_string): New function. (thread_exregs): Take two additional arguments, a cap_addr_trans structure and a corresponding flags. Use them when copying a supplied capability into the address space slot of the thread. Support the HURD_EXREGS_EXCEPTION_THREAD flag. Improve error detection and debugging out. * server.c (server_loop): Let a void address for the activity slot imply the caller's current activity. Take two additional arguments, a cap_addr_trans structure and a corresponding flags argument. Pass them to thread_exregs. * viengoos.c (system_task_load): Set THREAD_ACTIVITY. Don't call thread_commission. Instead, call thread_exregs. ruth/ 2007-11-23 Neal H. Walfield <neal@gnu.org> * ruth.c (main): Don't call rm_object_slot_copy_in to update the address space slot. Just use rm_thread_exregs. Add test for pthread library. * ia32-cmain.c (cmain): If _pthread_init_routine is not NULL, call it. Otherwise, just call finish directly.
Diffstat (limited to 'ruth')
-rw-r--r--ruth/ChangeLog9
-rw-r--r--ruth/ia32-cmain.c13
-rw-r--r--ruth/ruth.c148
3 files changed, 71 insertions, 99 deletions
diff --git a/ruth/ChangeLog b/ruth/ChangeLog
index b67779d..4ae5e14 100644
--- a/ruth/ChangeLog
+++ b/ruth/ChangeLog
@@ -1,3 +1,12 @@
+2007-11-23 Neal H. Walfield <neal@gnu.org>
+
+ * ruth.c (main): Don't call rm_object_slot_copy_in to update the
+ address space slot. Just use rm_thread_exregs. Add test for
+ pthread library.
+
+ * ia32-cmain.c (cmain): If _pthread_init_routine is not NULL, call
+ it. Otherwise, just call finish directly.
+
2007-11-22 Neal H. Walfield <neal@gnu.org>
* ruth.c: Include <hurd/thread.h>.
diff --git a/ruth/ia32-cmain.c b/ruth/ia32-cmain.c
index 0b87c38..55c8553 100644
--- a/ruth/ia32-cmain.c
+++ b/ruth/ia32-cmain.c
@@ -110,15 +110,20 @@ cmain (void)
l4_init ();
l4_init_stubs ();
- printf ("In cmain");
+ printf ("In cmain\n");
mm_init (__hurd_startup_data->activity);
extern void *(*_pthread_init_routine)(void);
- void *sp = _pthread_init_routine ();
+ if (_pthread_init_routine)
+ {
+ void *sp = _pthread_init_routine ();
- /* Switch stacks. */
- l4_start_sp_ip (l4_myself (), sp, &finish);
+ /* Switch stacks. */
+ l4_start_sp_ip (l4_myself (), (l4_word_t) sp, (l4_word_t) &finish);
+ }
+ else
+ finish ();
/* Never reached. */
}
diff --git a/ruth/ruth.c b/ruth/ruth.c
index 44cfb2e..be05d8d 100644
--- a/ruth/ruth.c
+++ b/ruth/ruth.c
@@ -37,6 +37,7 @@
#include <string.h>
#include <sys/mman.h>
+#include <pthread.h>
#include "ruth.h"
@@ -279,7 +280,7 @@ main (int argc, char *argv[])
do_debug (4)
as_dump ("thread");
- debug (2, "I'm running (%x.%x)!\n",
+ debug (4, "I'm running (%x.%x)!",
l4_thread_no (l4_myself ()),
l4_version (l4_myself ()));
@@ -292,29 +293,27 @@ main (int argc, char *argv[])
printf ("Checking thread creation... ");
addr_t thread = capalloc ();
- debug (1, "thread: " ADDR_FMT, ADDR_PRINTF (thread));
+ debug (5, "thread: " ADDR_FMT, ADDR_PRINTF (thread));
addr_t storage = storage_alloc (activity, cap_thread, STORAGE_LONG_LIVED,
thread).addr;
struct cap_addr_trans addr_trans = CAP_ADDR_TRANS_VOID;
- rm_object_slot_copy_in (activity, thread, THREAD_ASPACE_SLOT,
- ADDR (0, 0), CAP_COPY_COPY_SOURCE_GUARD,
- addr_trans);
-
l4_word_t dummy;
rm_thread_exregs (activity, thread,
- HURD_EXREGS_SET_ACTIVITY
- | HURD_EXREGS_SET_SP_IP | HURD_EXREGS_START,
- ADDR (0, 0), activity,
+ HURD_EXREGS_SET_ASPACE | HURD_EXREGS_SET_ACTIVITY
+ | HURD_EXREGS_SET_SP_IP | HURD_EXREGS_START
+ | HURD_EXREGS_ABORT_IPC,
+ ADDR (0, 0), CAP_COPY_COPY_SOURCE_GUARD, addr_trans,
+ activity,
(l4_word_t) ((void *) stack + sizeof (stack)),
(l4_word_t) &start, 0, 0,
ADDR_VOID, ADDR_VOID,
&dummy, &dummy, &dummy, &dummy);
- debug (2, "Waiting for thread");
+ debug (5, "Waiting for thread");
while (done == 0)
l4_yield ();
- debug (2, "Thread done!");
+ debug (5, "Thread done!");
storage_free (storage, true);
capfree (thread);
@@ -323,105 +322,64 @@ main (int argc, char *argv[])
}
{
- static volatile int done;
- char stack[0x1000];
+ printf ("Checking pthread library... ");
- void start (void)
- {
- do_debug (4)
- as_dump ("thread");
-
- debug (2, "I'm running (%x.%x)!\n",
- l4_thread_no (l4_myself ()),
- l4_version (l4_myself ()));
+#define N 4
+ pthread_t threads[N];
- done = 1;
- do
- l4_yield ();
- while (1);
- }
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+#define FACTOR 10
+ static volatile int shared_resource;
- printf ("Checking thread creation... ");
+ void *start (void *arg)
+ {
+ uintptr_t i = (uintptr_t) arg;
- addr_t thread = capalloc ();
- debug (1, "thread: " ADDR_FMT, ADDR_PRINTF (thread));
- addr_t storage = storage_alloc (activity, cap_thread, STORAGE_LONG_LIVED,
- thread).addr;
+ debug (5, "%d (%x.%x) started", (int) i,
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()));
- struct cap_addr_trans addr_trans = CAP_ADDR_TRANS_VOID;
- rm_object_slot_copy_in (activity, thread, THREAD_ASPACE_SLOT,
- ADDR (0, 0), CAP_COPY_COPY_SOURCE_GUARD,
- addr_trans);
+ int c;
+ for (c = 0; c < FACTOR; c ++)
+ {
+ int w;
+ for (w = 0; w < 10; w ++)
+ l4_yield ();
- l4_word_t dummy;
- rm_thread_exregs (activity, thread,
- HURD_EXREGS_SET_ACTIVITY
- | HURD_EXREGS_SET_SP_IP | HURD_EXREGS_START,
- ADDR (0, 0), activity,
- (l4_word_t) ((void *) stack + sizeof (stack)),
- (l4_word_t) &start, 0, 0,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
+ pthread_mutex_lock (&mutex);
- debug (2, "Waiting for thread");
- while (done == 0)
- l4_yield ();
- debug (2, "Thread done!");
+ debug (5, "%d calling, count=%d", (int) i, shared_resource);
- storage_free (storage, true);
- capfree (thread);
+ for (w = 0; w < 10; w ++)
+ l4_yield ();
- printf ("ok.\n");
- }
+ shared_resource ++;
- {
- static volatile int done;
- char stack[0x1000];
+ pthread_mutex_unlock (&mutex);
+ }
- void start (void)
- {
- do_debug (4)
- as_dump ("thread");
-
- debug (2, "I'm running (%x.%x)!\n",
- l4_thread_no (l4_myself ()),
- l4_version (l4_myself ()));
-
- done = 1;
- do
- l4_yield ();
- while (1);
+ return arg;
}
- printf ("Checking thread creation... ");
-
- addr_t thread = capalloc ();
- debug (1, "thread: " ADDR_FMT, ADDR_PRINTF (thread));
- addr_t storage = storage_alloc (activity, cap_thread, STORAGE_LONG_LIVED,
- thread).addr;
-
- struct cap_addr_trans addr_trans = CAP_ADDR_TRANS_VOID;
- rm_object_slot_copy_in (activity, thread, THREAD_ASPACE_SLOT,
- ADDR (0, 0), CAP_COPY_COPY_SOURCE_GUARD,
- addr_trans);
-
- l4_word_t dummy;
- rm_thread_exregs (activity, thread,
- HURD_EXREGS_SET_ACTIVITY
- | HURD_EXREGS_SET_SP_IP | HURD_EXREGS_START,
- ADDR (0, 0), activity,
- (l4_word_t) ((void *) stack + sizeof (stack)),
- (l4_word_t) &start, 0, 0,
- ADDR_VOID, ADDR_VOID,
- &dummy, &dummy, &dummy, &dummy);
+ int i;
+ for (i = 0; i < N; i ++)
+ {
+ debug (5, "Creating thread %d", i);
+ error_t err = pthread_create (&threads[i], NULL, start,
+ (uintptr_t) i);
+ assert (err == 0);
+ }
- debug (2, "Waiting for thread");
- while (done == 0)
- l4_yield ();
- debug (2, "Thread done!");
+ for (i = 0; i < N; i ++)
+ {
+ void *status = (void *) 1;
+ debug (5, "Waiting on thread %d", i);
+ error_t err = pthread_join (threads[i], &status);
+ assert (err == 0);
+ assert (status == (uintptr_t) i);
+ debug (5, "Joined %d", i);
+ }
- storage_free (storage, true);
- capfree (thread);
+ assert (shared_resource == N * FACTOR);
printf ("ok.\n");
}