Expert answer:C++, Sender & Receiver – IPC Project – (Operating


Solved by verified expert:The assignment sheet and files needed are attached.I would like to get an explanation of what we’re doing, because we’re demonstrating it in will be checked on Moss so please no plagiarism.Nice written C++ code following the instructions and nothing more, we’re not professional, so our code shouldn’t look like we are.(student level coding to do everything that is asked in the .docx file, with comments + explanations to help us demonstrate the code in class)take your time to make it look nice, student level C++ coding, follow every grading criteria.(notes on what to say/do on our in class demo/presentation would be greatly appreciated)THANK YOU.


Don't use plagiarized sources. Get Your Custom Essay on
Expert answer:C++, Sender & Receiver – IPC Project – (Operating
Just from $10/Page
Order Essay

Unformatted Attachment Preview

CPSC 351 Operating System Concepts
Programming Assignment – Sender & Receiver
Mode: Teams of 4 persons
Due Date: As shown on Titanium.
1. To solidify your understanding of IPC principles.
2. To develop greater appreciation for the different IPC mechanisms.
3. To gain hands-on experience using shared memory.
4. To gain hands-on experience using message queues.
5. To gain hands-on experience using signals.
6. To learn how to combine shared memory and message queues in order to implement a
practical application where the sender process sends information to the receiver process.
For this assignment:
You will use your knowledge of shared memory and message queues in order to implement an
application which synchronously transfers files between two processes.
You are to implement two related programs: a sender program and the receiver program as
described below:
• sender: this program shall implement the process that sends files to the receiver process.
The sender shall be invoked as ./sender where sender
is the name of the executable and is the name of the file to transfer. For
example, ./sender song.mp3. When invoked, the sender shall perform the following
sequence of steps:
1. The program shall then attach to the shared memory segment, and connect to the message
queue both previously set up by the receiver.
2. Send the name of the file specified at the command line to the receiver process using
the message queue. The message shall contain a field called fileName specifying the
name of the file to be sent.
3. Read a predefined number of bytes from the specified file, and store these bytes in the chunk
of shared memory.
Page 1 of 4
4. Send a message to the receiver (using a message queue). The message shall contain a field
called size indicating how many bytes were read from the file.
5. Wait on the message queue to receive a message from the receiver confirming successful
reception and saving of data to the file by the receiver.
6. Go back to step 3. Repeat until the whole file has been read.
7. When the end of the file is reached, send a message to the receiver with the size field set to 0.
This will signal to the receiver that the sender will send no more.
8. Close the file, detach shared memory, and exit.
• receiver: this program shall implement the process that receives les
from the sender process. The program shall be invoked as ./recv where recv is the
name of the executable. When invoked, the receiver program shall perform the following
sequence of steps:
1. The program shall setup a chunk of shared memory and a message queue.
2. The program shall wait on a message queue to receive a message from the sender program.
When the message is received, the message shall contain a field called size denoting the
number of bytes the sender has saved in the shared memory chunk.
3. If size is not 0, then the receiver reads size number of bytes from shared memory, saves them
to the file (always called recvfile), sends message to the sender acknowledging successful
reception and saving of data, and finally goes back to step 3.
4. Otherwise, if size field is 0, then the program closes the file, detaches the shared memory,
deallocates shared memory and message queues, and exits.
• When user presses Control-C in order to terminate the receiver, the receiver shall de-allocate
memory and the message queue and then exit. This can be implemented by setting up a signal
handler for the SIGINT signal. Sample file illustrating how to do this have been provided
For more details, refer to “UNIX System V IPC” example in the slides “Chp 3
Starter code:
Please note: by default the skeleton programs will give you errors when you run them. This is
because they are accessing unallocated, unattached regions of shared memory. It’s your job to
fill in the appropriate functionality in the skeleton, de-noted by the TODO comments, in order
to make the programs work.
The skeleton codes for sender and receiver can be found on Titanium. The files are as follows:
• sender.cpp: the skeleton code for the sender (see the TODO: comments in order to find out
what to fill in)
• recv.cpp: the skeleton code for the receiver (see the TODO: comments in order to find out what
to fill in).
• msg.h: the header file used by both the sender and the receiver
Page 2 of 4
It contains the structure of the message relayed through message queues). The structure contains
two fields:
– long mtype: represents the message type.
– int size: the number of bytes written to the shared memory.
In addition to the structure, msg.h defines macros representing two different message types:
– SENDER_DATA_TYPE: macro representing the message sent from sender to receiver. It’s
type is 1.
– RECV_DONE_TYPE: macro representing the message sent from receiver to the sender
acknowledging successful reception and saving of data.
• NOTE: both message types have the same structure. The difference is how the mtype field
is set. Also, the messages of type RECV_DONE_TYPE do not make use of the size field.
• Makefile: enables you to build both sender and receiver by simply typing make at the command
• signaldemo.cpp: a program illustrating how to install a signal handler for SIGSTP signal sent to
the process when user presses Control-C.
The following links provide additional documentation about shared memory and message
• Message Queues:
• Shared Memory:
Grading for this assignment:
Design of your program: 10’
(1) Write in a document called “Design of Sender and Receiver”.
(2) Resource for Design Part:
• Program compiles: 5’
• Correct use of message queues: 25’
• Correct use of shared memory: 25’
• Program deallocates shared memory and message queues after exiting: 10’
• Correct file transfer: 5’
• Correct signal handling: 5’
• All system calls are error-checked: 5’
• README file: 10’
(1) List your team members’ Names, Section Numbers, and Emails
(2) How to run your program (platform, commands in each step and a screenshot of one
(3) How did your team collaborate on your projects? Illustrate each member’s
• Late submissions shall be penalized 10%. No assignments shall be accepted after 24 hours.
Page 3 of 4
Academic Honesty:
All forms of cheating shall be treated with utmost seriousness. You may discuss the problems
with other students, however, you must write your OWN codes and solutions. Discussing
solutions to the problem is NOT acceptable (unless specified otherwise). Copying an assignment
from another student or allowing another student to copy your work may lead to an automatic
F for this course. Moss shall be used to detect plagiarism in programming assignments. If you
have any questions about whether an act of collaboration may be treated as academic dishonesty,
please consult the instructor before you collaborate. Details posted at
• This assignment MUST be completed using C or C++ on Linux.
• Please hand in your source code electronically (do not submit .o or executable code)
• You must make sure that the code compiles and runs correctly.
• Write a README file (text file, do not submit a .doc file) which contains
– Your Section#, Name and Email Address.
– The programming language you used (i.e. C or C++).
– How to execute your program.
– Anything special about your submission that we should take note of.
• Place all your files under one directory with a unique name (such as p1-[userid] for
sendandrecv, e.g. p1-whan).
• Tar the contents of this directory using the following command. tar cvf [directory name].tar
[directory name] E.g. tar -cvf p1- whan.tar p1- whan/
• Use TITANIUM to upload the tared file you created above.
• Turn in ONE copy (per group) to Titanium.
Page 4 of 4

Purchase answer to see full

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code ESSAYSHELP