Question: A) Write a multi-processed C/C++ program in Unix that does the following: It takes an email address as the only parameter. The program finds all

A) Write a multi-processed C/C++ program in Unix that does the following:

It takes an email address as the only parameter.

The program finds all the file names under the current running directory and put the information into an array in the memory.

The program then finds all the process information (including process names and IDs) of the current system, and appends the information to the above-mentioned array.

The program sends the contents of the array (file names and process names/IDs), to the provided email address. The subject line should be "There are N of files and M processes", where N is the actual number of files, and M is the actual number of files.

Note: you can use the Unix "mail" or "mailx" program to send email. To find out the syntax of their command line parameters, use the man page or google.

You are not allowed to use system() function in this or any other assignment programs.

B) Write client/server programs in Unix that do the following:

The server process creates a shared memory area by using System Vs shared memory segment.

The client(s) (there can be more than one client processes running), started separately on the same machine, can write some text to the shared buffer. The text will be less than 1000 bytes. You can input the text from keyboard, or you can ask the client to read the first 1000 bytes of a text file (redirect from stdin is the easiest solution).

When the server receives a new text from a client, it appends the text to a file. The server stops when it sees a STOP!!! string in the shared buffer.

You need to figure out a way for the client to notify the server that a new text is ready. Remember that the client(s) can write the same text twice. Your test cases should test this condition.

C) Implement two C programs in Unix that do the following:

All these programs map a common file to memory, using mmap().

One program, called a writer, repeatedly writes a string xxxxxxxxxx to the beginning of the memory mapped file in memory, where x is the last digit of the processs PID. The process pauses for two seconds (by calling sleep()) between writing. It terminates after writing the string 20 times. Since you always write from the first byte of the file, the processes repeatedly overwrite any previous data there.

You can start multiple writer processes concurrently.The other program, called a reader, repeatedly reads the memory-mapped file, and displays its contents. The process pauses for two seconds between readings. It terminates after looping 20 times.You can start multiple writer processes concurrently.Run a few reader processes and write processes concurrently and observe the outputs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!