Hi,

A sample program using POSIX threads (with basic pthread functions) runs well perfectly for 1 thread/2 threads. But for more than 2 threads it fails with Segmentation fault.
The function which is threaded, makes use of a variable 'flag' & contains an if statement. If the "if" condition is true, flag will be set to 0 and the loop will be break in the next iteration. To test the next case, again the flag is set to 1.
The server has 2 cores.
The memory allocation statement is:

// params is a structure
params *thread_params = (params*) malloc( nthreads * sizeof(params*));

What could be the reason for "seg fault" here?

Let me know if the complete program is required.

Thanks