I am trying to develop a parallel program using pthreads on the Tilera platform. The program compiles without problems but when I run it I get the error:
pthread_create.c:389: start_thread: Assertion `freesize < pd->stackblock_size' failed.
What does it mean and how I can fix it?
The stepwise execution of a program has shown that this error appears when a thread tries to call 'pthread_exit(NULL);'
. Any suggestion?
Source code of the thread is the following:
void *Consumer(void *threadargs){
// Initialize structure
rtP_Consumer_Controll rtp_lfe;
Init_Consumer(&rtp_lfe);
// Receiving the set of CPUs and thread id
thread_data *th_data = (thread_data *) threadargs;
int th_id = th_data->thread_id;
// Binding this thread to a CPU
if (tmc_cpus_set_my_cpu(th_id) < 0)
tmc_task_die("THREAD Consumer: 'tmc_cpus_set_my_cpu' has failed");
// Activating network communication
if (tmc_udn_activate() < 0)
tmc_task_die("THREAD Consumer: Failure in ’tmc_udn_activate()’.");
// Declaring necessary vars
FOP_data r_data;
real_T result;
// Loop over receiving, processing and sending
while (!terminate)
{
if (tmc_udn0_available_count() == 0) continue;
// Receiving data to process
tmc_udn0_receive_buffer((FOP_data*)&r_data,sizeof(r_data));
// Computing a function
Consumer_Func(r_data.pA,r_data.pB,&rtp_lfe,&result);
printf("THREAD Consumer: result %lf ... \n",result);
}
printf("THREAD Consumer: Finalizing the thread ... \n");
// Exiting the thread
pthread_exit(NULL);
}
Terminate is a global variable modified by the main thread.
The execution of ulimit -a provided the following output:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 8022
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 8022
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Well, I did not find the exact answer but playing a little bit with debuggers and contacting tech support shed light on the problem. It seems that UDN communication is organized using stack. Furthermore, this stack is the same for all the demux queues of UDN. Therefore, it seems the problem comes from the fact that when using pthread_exit stack still exists but it is unwound. By adding one more packet to such a stack makes it crash.
The solution to this problem is to use TMC_QUEUE instead of UDN. TMC_QUEUE creates a FIFO type for a particular packet type in the shared memory. Then, everything works pretty well.