Home Schedule Reading Projects People
Mac Logo Windows Logo Minix Logo Sun Solaris Logo Linux Logo

Homework 3: Inter Process Communication (IPC): Shared memory and Message Queues.

Assignment Day September 13,2016 (Tuesday)
Due Date September 20, 2016 (Tuesday before class) Note that the project is due later in the week, Thursday.
  Email (time stamp), Typed Hardcopy are required.and submit code to nike via csx730.

Question 1: Shared Memory (15 pts):

Write a simple a program (starting programming snippets are available here and here) where processes synchronize via polling such that a process A prints out the strings of two other separate writing processes (B first and then C second) from shared memory. process A needs to 'wait' by polling until B and C finish writing their strings to memory.

Here is the sequence of events that needs to be implemented:

  1. Process A writes to position 1 in memory and then waits until B and C completes
  2. Process B writes the string "shared" into memory then signals A & C that it is complete by writing into memory position 1 (note B should wait to write into position 1 until after process A writes into position 1 in memory)
  3. Process C writes the string "memory" into memory and then signals A that it is complete by writing into memory position 1 (note C should wait until process B writes into position 1 in memory).

Submit a hardcopy of your code (make sure it is readable). We will grade this on concisement and correctness by inspecting you submitted code.

Question 2: Shared Memory (4 pts)

How are shared memory segments finally destroyed? What UNIX utility can be used to to determine whether a memory segment has been destroyed or not?

Question 3: Message Queues (6 pts)

Review the programs (spock.c and kirk.c) that we discussed in class Tuesday on Beej's Message Queue section and also read Beej's discussion (link is here). Code is also available for copy (here and here).

Answer (or discuss) Beej's questions (also listed below):

a) Discuss and evaluate what happens when you're running both in separate windows and you kill one or the other.

b) Discuss what happens (and why) when you run two copies of kirk.

c) Discuss what happens (and why) when your run two copies of spock.