[MUD-Dev] Multi-threaded programming under Linux

Orion Henry ohenry at sdcc10.ucsd.edu
Wed Jul 23 11:49:44 New Zealand Standard Time 1997

	I am neck deep in trying to get LinuxThreads to work
at my Job.  They seemed to function fine until I put them to 
some serious stress testing.  If anyone else has LinuxThreads
on their box I'd appricate it if they could compile and run
this little bit.  I have no way of knowing if this is the
thread package messing up or if its something else totally
unrelated (like me having the wrong libs)

If this DOES run on someone elses machine please let me know
what spec you are running with.

I am running Redhat linux 4.2
I am runnign binutils 2.8.1
and have glibc 2.0.4 (aka libc 6.0.4 I think)
and I have gcc

heres the code

#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

#define NUM_THREADS	500

void * slave(void * s)
	return NULL;

int main(int argc, char ** argv)
	int i;
	pthread_t slave_t[NUM_THREADS];

	for(i = 0; i < NUM_THREADS;i++)

	for(i = 0; i < NUM_THREADS;i++) {
		printf("[PARENT] Slave %d is dead.\n",i);

	printf("All done...\n");

	return 0;

heres the output

[PARENT] Slave 0 is dead.
[PARENT] Slave 1 is dead.
[PARENT] Slave 2 is dead.
[PARENT] Slave 3 is dead.
[PARENT] Slave 4 is dead.
[PARENT] Slave 5 is dead.
[PARENT] Slave 246 is dead.
[PARENT] Slave 247 is dead.
[PARENT] Slave 248 is dead.
[PARENT] Slave 249 is dead.
[PARENT] Slave 250 is dead.
[PARENT] Slave 251 is dead.
Segmentation Fault

Last week it would always die after 246... 
this week it always dies after 251...

If anyone can duplicate this crash (or not)
I'd be quite happy.


More information about the MUD-Dev mailing list