Write two small pieces of code that run as different processes, yet they share part of their memory. The memory is shared by mapping it to the same file. Create a file 100 bytes in size which is big enough for this purpose. You can use dd if=/dev/zero of=sharedfile count=10 bs=10 to create the file. The one process, we call sender opens the file and memory maps it (use mmap(2)) to an array. Then modifies it by reading user input and copying the user input to the mapped array. After every modification it sends (with kill(2)) a SIGUSR signal to the other process. Repeats the cycle of reading, copying and sending a signal until the mapped array is full and then exits after sending a kill signal SIGTERM to terminate the other processes. The program takes one argument, the pid of the other process. The other process which we call receiver, prints out its pid to be used in the command line of the other process, maps the same file and then sets up a signal handler (use sigaction(2)) after which it blocks with sigsuspend until it receives the signal SIGUSR. All the new characters that were added to the mapped array are printed to the standard output. Make sure that SIGUSR is blocked going into sigsuspend and unblocks in sigsuspend. The process catches the SIGTERM signal and exits gracefully. Submit one tar file that includes as first target all that compiles both programs and creates the shared file, appropriate targets to compile the components of the assignment, a target clean to clean up, and a target tar to create the tar file. To start, have a look into the manual pages of mmap(2), stat(2), open(2) and signal(7)
memorymapping's Introduction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.