Question: C Programming Questions: Q1: At this point, your solution does not contain any synchronization or mutual exclusion. Give an example of and explain a possible
C Programming Questions:
Q1: At this point, your solution does not contain any synchronization or mutual exclusion. Give an example of and explain a possible synchronization error that could occur in this code. Be specific.
Q2: Suppose we implement correct synchronization and mutual exclusion for all of the threads. If our three functions were to operate on all expression in the buffer at once (not just the first expression), would the program generate incorrect output? Why or why not?
Q3: For this step, what specific data structure(s) need(s) protection? Why?
Q4: What would happen if you had a busy-wait within one of your critical sections? What if it is a loop with sched_yield()?
Q5: Why is it sometimes necessary to use the non-blocking pthread_mutex_trylock() instead of the blocking pthread_mutex_lock()? Think for example of a program that needs to acquire multiple mutexes at the same time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
