Due: Oct 20th
The goal is to make two programs.
1) Server:
Example: ./server /region1 Love 2 /region2 Hate 3 /region3 "Sugar is sweet" 1
Set up N shared memory regions
Copies the data to the region
Sets the count to the number
When all regions are used ... exit
2) Client
Example: /client /region1
Maps the named region
Wait for data to become available no more than 1 second
Decrements the count
Print the data
Quit
Question: Why does this code not work for the client?
int ans = sem_getvalue(...)
if ans >= 0
sem_wait(....)
Question: How does the server know when all the regions are used?
Bonus extra credit:
If you can cause the server to exit without busy waiting .. +10%.
But only the first turn-in with each method gets the bonus!
Bonus extra credit:
If you can make it impossible for the client to access data
before the server has copied it, and even before the server has
set up the semaphores, +10%.
But only the first turn-in with each method gets the bonus!
Resources:
Object oriented semaphores
Shared Memory
super simple non-object Semaphore example code
Slides about semaphores with sample code
Easy sample semaphore code
Timed semphores
Sample code