CS 471

Due Midnight, Thursday Feb 9, 2012


 

Write four C or C++ program Q1-Q4 described below.

Each program creates two children processes: The first is “Male” and the 2nd is “Female”

The two children communicate using the following IPC methods:

 

          Q1: shared memory

          Q2: sockets

          Q3: pipe

          Q4: shared file

 

 

ü The male process writes the following message to the female process:

       How are you my sister?

 

ü The female process reads this message, prints it to the tty, replies to the male process with the message,  and sleeps 1 seconds  then exits.

I am fine my brother, thanks!

The male process reads this reply and sleeps 2 seconds then exits.

 

ü The parent waits until both children exits. It prints to the tty a message whenever a child exits:

Son(or Daughter) Exited.

You may execute my solutions at:

http://www.cs.odu.edu/~cs471w/spring12/assignments/a1/wahab

For example:

[procyon] ~/public_html/spring12/assignments/a1/wahab>Q2

 

Q2: Using Sockets

Parent:          pid=11276

Son:             pid=11277, Parent_pid=11276

Daughter:        pid=11278, Parent_pid=11276

Daughter Got:    How are you my sister?

Son Got:         I am fine my brother, thanks!

Parent:          Daughter Exited

Parent:          Son Exited