C-Thread-Pool icon indicating copy to clipboard operation
C-Thread-Pool copied to clipboard

How does this work??

Open neo2043 opened this issue 6 months ago • 0 comments

I am trying to make a cross platform threadpool library in c and I came across this library and I started to examine it but I don't get it how is it working. The thing that I don't understand is that for example if I have 4 threads in the threadpool and I give all 4 of them work to do and its going to take a long time, in this case 1 minute, if I add 20 work into the queue before the 1 minute mark, they all will signal for threads but no one will be able to get that signal (as they are not waiting for any signal) and miss the signal and then I noticed that you added an integer v in bsem because of it it will take atleast one job after the first initial intensive job but then after this how does the thread know if there are any jobs left in the queue. There is no signal to inform the threads and the integer v is 0 after taking the 2nd job. I tried this library in linux because of signals .I made the above mentioned scenario, and it still worked. I don't get it how is it working. Any help would be appreciated.

neo2043 avatar Aug 05 '24 22:08 neo2043