Can you use a lock file to coordinate these two processes


Write a short C program and turn in the source code and output printouts. 

a. Write a short C program that creates two processes (Hinit: Check the Nag.c example in Lecture 3). Each process should repeatedly write its own unique message to a test file, one character at a time. Do you see garbled messages in the file? Why or why not? 

b. Add "#include " to your program, and use the usleep(1) and fflush(FILE *stream) calls between writes to individual characters. Do you see garbled messages in the file? Why or why not? 

c. Can you use a lock file to coordinate these two processes so the test file no longer contains garbled messages? Why or why not? State your assumptions. 

2. Find a creative/funny example of synchronization that can demonstrate the difficulty of developing a solution similar to the "Too Much Milk Solution 3." Make sure that you develop your own corresponding solutions 1, 2, and 3, and vigorously discuss the correctness and pitfalls of each solution.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Can you use a lock file to coordinate these two processes
Reference No:- TGS0146345

Expected delivery within 24 Hours