[KLUG Programming] Pthreads problem

Alan Mink programming@kalamazoolinux.org
Tue, 30 Dec 2003 11:01:09 -0500


I'm having some shared memory/size (??) problems using threads. Is POSIX 
threads under Linux stable?
Can anyone shed some light on such problems.
Most of my variables are global, thus shared memory. I originally had 
very large
data arrays over 136 MBytes. I had reduced it to around 70 MBytes.
Just yesterday, for debugging, I reduced it to ~100 KBytes and it seemed 
to work!?!?
Could there be some memory limitations involved? Both these mach have 
500 MBytes
of main memory.

Problem examples (under Linux 2.4 on an x86 platform):

 One process w/ 5 threads seems to work, but It looks like 2 different 
threads show 2 different values for the same global variable. Luckily 
the "owner' thread has the correct value & the "user interface" thread 
(read only) has the wrong value, not an out-of-date value

 Another process w/ 4 threads Seg Faults on rcving data via a socket 
"recv()" fct. I've built a non-thread version for testing other 
co-operating code & it works fine. But the thread version still crashes 
immediately when socket data is rcvd -- with no useful info from "gdb".

Thanks,
Alan