[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hang in threads.test
From: |
Neil Jerram |
Subject: |
Re: Hang in threads.test |
Date: |
Mon, 27 Sep 2010 21:58:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Could you run the program that I posted and report back?
That program runs fine for me - except only 100% because I have a single
core.
I also modified it to add continual thread creation and destruction
(attached), and it was still fine.
Any further ideas? I'll also continue playing with this...
Neil
#define GC_THREADS 1
#define GC_REDIRECT_TO_LOCAL 1
#include <gc/gc.h>
#include <pthread.h>
#include <stdlib.h>
void *a;
static void *
alloc_thread (void *data)
{
while (1)
a = GC_MALLOC_ATOMIC (123);
return NULL;
}
static void *
gc_thread (void *data)
{
while (1)
GC_gcollect ();
return NULL;
}
static void *
creator_thread (void *data)
{
pthread_t child;
pthread_create (&child, NULL, creator_thread, NULL);
usleep (random() % 10000);
return NULL;
}
int
main (int argc, char *argv[])
{
pthread_t alloc, gc;
GC_INIT ();
pthread_create (&alloc, NULL, alloc_thread, NULL);
pthread_create (&gc, NULL, gc_thread, NULL);
(void) creator_thread (NULL);
while (1);
return EXIT_SUCCESS;
}