Follow the example programs unix_pipe.c, named_pipe.c and shm-posix-combined.c to write three versions (two pipe versions and one shared memory version) of an interprocess communication program (A8p2_unixpipe.c[pp], A8p2_namedpipe.c[pp] and A8p2_shm.c[pp]) in C/C++. Each version should create two processes using fork. One of the two processes should send or share twenty random integers a1,…,a20 in the range from -19 to 19 inclusive to the other process. The sending process should print out the values of these integers. The receiving process should decide and print out whether the two vectors (a1,…,a10) and (a11,…,a20) are orthogonal. Either parent or child can act as the sending process or receiving process. Sample runs of the programs in 1 & 2 can look like the following. You do NOT need to submit screen shots. Instead submit source code files.
[kwang@computer][~/temp]$ ./A8p2_shm
child wrote into the shared memory:
-3,8,-13,17,11,-7,13,3,-6,16,
0,3,-10,15,-5,-2,0,9,-1,-10,
parent read from the shared memory:
-3,8,-13,17,11,-7,13,3,-6,16,
0,3,-10,15,-5,-2,0,9,-1,-10,
The two vectors are not orthogonal
[kwang@computer][~/temp]$ ./A8p2_unixpipe
child sent into the unnamed pipe:
-9,-7,7,12,-3,-1,16,14,-8,-10,
-6,-3,-12,17,-4,-13,5,-9,-16,-19,
parent received from the unnamed pipe:
-9,-7,7,12,-3,-1,16,14,-8,-10,
-6,-3,-12,17,-4,-13,5,-9,-16,-19,
The two vectors are not orthogonal
[kwang@computer][~/temp]$ ./A8p2_namedpipe
child sent into the named pipe:
-10,-16,-15,-19,9,-3,19,12,5,-15,
8,-19,3,10,-16,-6,18,-12,-6,14,
parent received from the named pipe:
-10,-16,-15,-19,9,-3,19,12,5,-15,
8,-19,3,10,-16,-6,18,-12,-6,14,
The two vectors are not orthogonal
We need at least 8 more requests to produce the answer.
2 / 10 have requested this problem solution
The more requests, the faster the answer.
Follow the example programs unix_pipe.c, named_pipe.c and shm-posix-combined.c to write three versions (two pipe versions and one shared memory version) of an interprocess communication program (A8p2_unixpipe.c[pp], A8p2_namedpipe.c[pp] and A8p2_shm.c[pp]
1. Write a C or C++ program A6p2.c[pp] that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 39 inclusive and store them in a 5 by 12 two dimensional integer array (e.g.,int a[5][12];). Use pthread to create n threads to convert all 60 array elements modulo 11 (i.e. take the remainder after division by 11) in place. You should divide this update task among the n threads as evenly as possible. Print the array both before and after...