Question: 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

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!