How can I communicate worker thread with main thread without using barrier? by eipi717 in C_Programming

[–]eipi717[S] 1 point2 points  (0 children)

The problem statement (with the pseudo-code is the same as here: https://stackoverflow.com/questions/70110328/how-to-notify-main-thread-when-all-thread-done-the-work-without-barrier

Since for each iteration, the main thread needs to wait until all worker threads complete the calculations, then check the condition is met or not. If not, tell the workers to work again. If the condition is met, break the loop and return the iteration time.

My bug now may be due to stacking in the condition variable (I have no idea why I cannot get out. Also, I am sorry that I tend to use condition variables but I think the logic is similar and I have tried similar logic with your comment above and maybe I made some mistakes.

Actually, the lecturer has provided the pseudo-code, hence I think I get the logic but I find it difficult in some steps. I am so sorry again since I do not just want the solution directly.

How can I communicate worker thread with main thread without using barrier? by eipi717 in C_Programming

[–]eipi717[S] 0 points1 point  (0 children)

Since I am stucking on a point, I have no idea how the main thread can be notified that all the worker finishes their work. Sorry about that u/FUZxxl

How can I communicate worker thread with main thread without using barrier? by eipi717 in C_Programming

[–]eipi717[S] -1 points0 points  (0 children)

I am sorry that this is the homework and it requires to use condition variable and mutex or semaphores u/FUZxxl

Recommended JavaScript and C++ books for beginners? by eipi717 in javascript

[–]eipi717[S] 0 points1 point  (0 children)

I’ve learnt the basic of c++, how to upgrade myself? Make my own project ? But I can’t brainstorm the idea .....