Pithikos/C-Thread-Pool

Segmentation fault (core dumped)

gcjyzdd opened this issue · 2 comments

Hi,

I use your code to accelerate my calculations. I created a thpool with 4 workers and added 50 threads to it. When I ran my code, it reported "Segmentation fault (core dumped)". I don't know why.

I ran your example.c correctly. Perhaps each thread uses too much memory. I use each thread to compute a complex cost function which handles arrays of millions of double numbers. My laptop has 8G memory; hence, I think I can create 4 workers to compute some cost functions of some parameters concurrently. I tested that it took 0.7s to compute the cost function. Any advice? Thank you!

I suggest you first test by creating a single thread and trying that. If it doesn't give you errors, try with two threads.

You didn't give much information as to how you perform the calculations.. are the calculations part of your own program? I would first try and see if there is any race condition in the logic of your program. Maybe one thread is trying to read something that the other thread has already freed?

Thanks for your reply. I forgot to add a pair of curly brackets to a for structure. Now it runs perfectly now!