Question: skelShm.c: Write a multiple concurrent process program that uses shared memory and semaphores to display ascii modern art composed of a series of randomly generated
skelShm.c: Write a multiple concurrent process program that uses shared memory and semaphores to display "ascii modern art" composed of a series of randomly generated blocks of or more repeating characters, using no file pointers.
Write a multiple concurrent process program that does the following
Displays "ascii modern art" composed of a series of
randomly generated blocks of or more repeating characters
The program should perform this task in the following way:
Create a semaphore set of size use IPCPRIVATE as your key
a Initialize the semaphore representing the child to available
b Initialize the semaphore representing the parent to in use
Create a segment of shared memory use IPCPRIVATE as your key
Create a child process that:
a Attaches the segment of shared memory
b Seeds the random number generator
c Reserves the child semaphore
d Generates and stores the total number of blocks to generate.
This should be between and
c For each block, generate and store the following values:
The length of the block ie the number of characters to display
This should be between and
The character that comprises the block.
This should be between a and z
d Release the parent semaphore
e Reserve the child semaphore
f Detach the shared memory segment
g Release the parent semaphore
Create a parent process that:
a Attaches the segment of shared memory
b Seeds the random number generator
c Reserve the parent semaphore
d Generate a random width for the ASCII art.
This should be between and
e Using the data stored in the shared memory segment, output an image
Use the following tips:
One value stored in the segment should represent the number
of length character pairings. For each length character
pairing, you should output length instances of the given
character. This means if the pairing was b you would
output bbb
The random image has basically been encoded use runlength
encoding RLE; RLE doesn't including the location of new lines.
The location of new lines is determined by the random width
generated in step d Each time you output width total characters,
output a new line.
f Release the child semaphore
g Reserve the parent semaphore
h Detach the shared memory segment
Delete the semaphore
Delete the shared memory
You can useshould use the binary semaphore protocol introduced in class
Problem List the inlcude files you need for this program.
#include stdio.h
#include stdlib.h
#include "semun.h
#include "binarysem.h
Problem remember to declare a structure that represents the data
stored in the shared memory
Problem create a function to handle the code for the child.
Be certain to pass this function the id values for both the semaphore
and the shared memory segment
Problem create a function to handle the code for the parent.
Be certain to pass this function the id values for both the semaphore
and the shared memory segment
Problem implement function main
int mainint argc, char argv
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
