Question
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started