IPC-3: Shared array implementation
Requirements
- Write a C++ class implementing a module shared_array which is an array of integers shared between processes.
- The class is supposed to be initialized as follows: shared_array array(“array-name”, size);
- The size of the array (number of elements) could be between 1 and 1 000 000 000
- Two shared arrays are the same in the system if they have equal names and sizes, otherwise, they are different.
- The class should provide operator [] for indexing an element with a given index i.
- Any process that knows the name and the size of the array should be able to use it.
- Write two infinite programs (first and second) to work with the shared array using cross-process semaphore.
Expected result
The resulting application should be able to build from the command line as follows:
make first
make secondThe execution of the program should demonstrate how the array changes from the first and second processes.
The final solution should contain a Makefile for the multi-stage build. The Makefile should also contain targets all and clean. It’s recommended to have compiler and compiler flags declared as Makefile variables. Alternatively, cmake could also be used instead of make.