Write the C code for the below two systems programming questions:
Question 1. A factory is producing socks. Use lock(s) and condition variable(s) to write a procedure ASockIsProduced(), which is called whenever a sock (thread) is produced. As soon as two socks are available, one thread should call PackAPair() (you don’t need to implement PackAPair()), and two threads should return from ASockIsProduced.
Question 2. A factory is producing pepper and salt shakers. Use lock(s) and condition variable(s) to write a procedure PepperShakerArrvies() that is called whenever a pepper shaker (thread) is produced. Use lock(s) and condition variable(s) to write another procedure SaltShakerArrives() that is called whenever a salt shaker (thread) is produced. As soon as one pepper shaker and one salt shaker are available, one of the threads should call PackShakers() (you don’t need to implement PackShakers()); one thread is returned from PepperShakerArrives() and one thread is returned from SaltShakerArrives().
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here