[MUD-Dev] Multi-threaded programming under Linux

Orion Henry ohenry at sdcc10.ucsd.edu
Wed Jul 23 11:49:44 CEST 1997


Hrmmm,
	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 2.7.2.1




heres the code

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

#define NUM_THREADS	500


void * slave(void * s)
{
	sleep(1);
	return NULL;
}

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

	for(i = 0; i < NUM_THREADS;i++)
		pthread_create(&slave_t[i],NULL,slave,NULL);

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

	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.


	Thanks,
	Orion




More information about the mud-dev-archive mailing list