Question: Use all the information given below to answer the Lab Question by making sure all the requirements are fulfilled: Requirements for the lab: source code
Use all the information given below to answer the Lab Question by making sure all the requirements are fulfilled:
Requirements for the lab:
- source code
- Makefile if needed
- brief report as a PDF or TXT file explaining your (a) program and its output, (b) your approach to notify selected threads, and (c) the compilation process.
- Should include:
- the correct number of threads are spawned
- threads can block with a deadline
- the thread selected can be unblocked before its deadline
- the report is clear and complete
Lab Question:
Starting from the waker/sleeper source code developed in Section 2.1.3, extend its functions so that the following features are available:
a) There are two sleeper threads.
b) The waker can randomly choose to wake one of the sleeper threads or the other. The other thread’s waiting period expires.
c) Output messages should clarify which operations are carried out by threads and by which threads. In particular, you should assign an ID to each of the sleeper threads, for example, by passing the ID as an argument to its function.
d) Explain your approach in a short PDF report: are you using different condition vari- ables? Are you using the same condition variable? Justify your choices.
Codes given to us:
1.notify.cc

2. sleeper.cc

3. threads.cc

Lab Description:




C* 2-notify No Selection 1 #include 2 #include 3 4 int main() { 5 6 7 8 9 10 11 } std::condition_variable cv; std::cout < < "Before notify "; cv.notify_one(); std::cout < < "After notify "; return 0; 12 # 13
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
