Colleagues, welcome.

I have a program that synchronizes 3 threads with semaphores. But there is a problem that is presented in the picture.

Console

It feels as if, after the completion of the program, the threads have not yet been fully implemented and continue to be executed.

Code listing on gist: https://gist.github.com/ArtemTellur/d7af7dfc4c4dcf08bb396b98345a248a

Please explain whether this is normal behavior. If not, what could be the error?

Thank you in advance!

  • one
    Output caching in printf ? - ߊߚߤߘ
  • @Arhad what does this mean? - Artem Tellur
  • 1. the minimum reproducible example (all the necessary information should be given directly in the text of the question) 2. text information is better to attach as text: a) it is easier to read; b) can be copied; c) the search works. You can correct the question text by clicking below to edit the question text - aleksandr barakin
  • 2
    Call fflush() after each printf to buffered output - Mike
  • @Mike put fflush (stdout) after each printf; - did not help. - Artem Tellur

0