summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2009-03-17 20:35:46 +0100
committerNeal H. Walfield <neal@gnu.org>2009-03-17 20:35:46 +0100
commit85532309547c936947da9e27e328f0e4f29df323 (patch)
tree891786adce339419cc200d0112b79d802203dce2
parentd6cdbfd09d2ce8ed04298acbb91206c7f10bb053 (diff)
Change Hieronymus to destroy activities when the corresponding thread exits.
-rw-r--r--hieronymus/hieronymus.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/hieronymus/hieronymus.c b/hieronymus/hieronymus.c
index 24cc86e..ce05b79 100644
--- a/hieronymus/hieronymus.c
+++ b/hieronymus/hieronymus.c
@@ -343,24 +343,49 @@ main (int argc, char *argv[])
/* Wait for all activities to die. */
- for (i = 0; i < module_count; i ++)
+ void *waiter (void *arg)
+ {
+ int i = (uintptr_t) arg;
+
+ uintptr_t rt = -1;
+ vg_object_reply_on_destruction (root_activity,
+ thread[i], &rt);
+
+ vg_addr_t folio = vg_addr_chop (activities[i], VG_FOLIO_OBJECTS_LOG2);
+ int index = vg_addr_extract (activities[i], VG_FOLIO_OBJECTS_LOG2);
+
+ error_t err;
+ err = vg_folio_object_alloc (VG_ADDR_VOID, folio, index,
+ vg_cap_void, VG_OBJECT_POLICY_VOID,
+ (uintptr_t) rt,
+ NULL, NULL);
+ if (err)
+ debug (0, "deallocating object: %d", err);
+
+ debug (0, "%s exited with %d", modules[i].name, (int) rt);
+
+ return 0;
+ }
+
+ if (module_count == 1)
+ waiter ((void *) 0);
+ else
{
- uintptr_t rt = -1;
- vg_object_reply_on_destruction (root_activity,
- thread[i], &rt);
-
- vg_addr_t folio = vg_addr_chop (activities[i], VG_FOLIO_OBJECTS_LOG2);
- int index = vg_addr_extract (activities[i], VG_FOLIO_OBJECTS_LOG2);
-
- error_t err;
- err = vg_folio_object_alloc (VG_ADDR_VOID, folio, index,
- vg_cap_void, VG_OBJECT_POLICY_VOID,
- (uintptr_t) rt,
- NULL, NULL);
- if (err)
- debug (0, "deallocating object: %d", err);
-
- debug (0, "%s exited with %d", modules[i].name, (int) rt);
+ pthread_t tids[module_count];
+ int i;
+ for (i = 0; i < module_count; i ++)
+ {
+ error_t err;
+ err = pthread_create (&tids[i], NULL, waiter, (void *) (uintptr_t) i);
+ if (err)
+ panic ("Creating thread: %d", err);
+ }
+
+ for (i = 0; i < module_count; i ++)
+ {
+ void *ret;
+ pthread_join (tids[i], &ret);
+ }
}
if (gather_stats)