posted Dec 8, 2016, 7:02 AM by JonAlf Dyrland-Weaver
updated Dec 15, 2016, 6:59 AM
With your table buddy, write a telephone style game simulator! It will use a semaphore to control access to a file and shared memory. This will be due on Monday.
You will need 2 programs:
- Control for the resources
- Should take a command line argument to determine if it is creating or removing the resources or viewing the story.
- If creating (command line argument:
- Should make the shared memory, semaphore and file (open the file with the truncate flag).
- Set any values that are needed.
- If removing (command line argument:
- Remove the shared memory and the semaphore
- Display the full contents of the story.
The writing program
- If viewing (command line argument:
- Output the contents of the story file.
- This mode does not need to interact with the semaphore
You do not need a run target in your makefile
- Will attempt to access the resources using the semaphore
- Once in, it should display the last line added to the file (the shared memory should contain the size of the last line).
- Then prompt the use for the next line.
- Once a new line is added, it should write that to the file, update the shared memory and then release the semaphore