I am not 100% sure that I need to use shared memory, it just seemed like everyone I talked to about this thought it was what should be used. |
If you ask people "how do I give two processes access to the same array?" they'll tell you to use shared memory. But if you ask them "how do I send messages back and forth between a parent and child process", then they're more likely to propose a different solution.
I could be wrong, but it sounds to me like what you really need is a client-server design, where communication might look somewhat like:
Client: I want to reserve a room for one from the 26th to the 28th.
Server: Okay, I have available rooms 203 and 714.
Client: Okay, I'll take 203.
Server: Okay, I've reserved it for you. Bye.
Client: Bye.
A design based around shared memory would be a bit weird, don't you think? When you reserve a room on a hotel you don't grab the reservation book yourself, write whatever you want, then hand it back.
you say "synchronization primitives" do you mean the semaphores? |
Semaphores are one kind of synchronization primitive, yes.
Because I am sure that I need to use them for this. |
Do you mean that it's a requirement of the solution, or that you believe you need them? In the latter case, no. If you use pipes or sockets you don't need to use semaphores or any other synchronization primitive. The system will take care to synchronize the two processes without you having to do anything special.