Skip to content

How does this work?? #132

@neo2043

Description

@neo2043

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions