Question
In this question, you are asked to create three threads and run them simultaneously. Threads, which we will call A, B, and C, have consecutive
In this question, you are asked to create three threads and run them simultaneously. Threads, which we will call A, B, and C, have consecutive code blocks as follows: - Thread A has three code blocks: A1, A2, A3 - Thread B has four code blocks: B1, B2, B3, B4 - Thread C has three code blocks: C1, C2, C3 What we call a code block actually consists of this piece of code: #include
b. Using semaphores, synchronize the threads of the program you wrote above in such a way that every time you run your program: - Let C1 code block be run AFTER A1 code block. - Let code block A2 be run AFTER code block B1. - Let C2 code block be run AFTER B2 code block. - Let B3 code block be run AFTER A2 code block. - Let A3 code block be run AFTER C2 code block. - Let B4 be the LAST executed code block. It doesn't matter when or in what order code blocks not mentioned above run. You can write your program using the Linux semaphore library (#include
In option B, we need to use the semaphore.h library.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started