Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is a C program, please note the question says You * have * to implement condition variable to obtain this output. Not using Semaphores.
this is a C program, please note the question says "You have to implement condition variable to obtain this output". Not using Semaphores.
Assume you have two threads; ThreadA and ThreadB. ThreadA prints "HELLO"
ten times and ThreadB prints "WORLD" ten times.
Write a code to create these two threads such that the output of your code must be
as follows:
You have to implement condition variable to obtain this output. It's your choice to
select an appropriate predicate variable. You can follow this hint.
Hint:
Declare a variable named turn of type character. Initially this variable has the value A
Then, ThreadA prints "HELLO" only if the content of the variable turn is A Similarly,
ThreadB prints "WORLD" only if the content of the variable turn is B
Use only one condition varaible.
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