2023 Write and run a C program on UNIX that creates four new processes A B C and D When the | Assignment Collections

Computer Science 2023 Write And Run A C Program On UNIX That Creates Four New Processes: A, B, C,

2023 Write and run a C program on UNIX that creates four new processes A B C and D When the | Assignment Collections

Write and run a C program on UNIX that creates four new processes: A, B, C,
and D. When the original process creates the new processes, it passes them
all the same pipe that they can use to send data to the original process,
which will serve as a logging process, displaying each line it receives along
with a time stamp. A pipeline is to exist between A and B, another between
B and C, and another between B and D. Including the shared pipe back to the
logging process and these three pipes (A-B, B-C, B-D) there are four pipes.

Process A generates 10 records consisting of the letter C or D (picked at
random for each record) along with the record number (1 byte ASCII) issued
sequentially from 0 to 9 and sends it to process B. Process A also sends a
log message something like: A sent process B ‘D1’ to the logging process.

Process B reads from the pipe connecting it to A. For each record it reads,
it will send it to the process indicated by the first character, along with
sending an appropriate log message to the logging process. For example, if
it receives a message containing ‘C2’, it sends the message to process C.
After sending the logging message, process B waits one second.

Process C reads its pipe and for each message received it sends the logging
process an appropriate message.

Process D reads its pipe and for each message received it sends the logging
process an appropriate message. Process D then waits 5 seconds after every
time it receives a message.

The logging process should terminate when it receives 30 messages, which is
10 messages from A to B, a total of 10 messages from either B to C or B to D,
and then a total of 10 more messages from either C or D indicating receipt.
Implement some way to terminate the other processes at appropriate times.

Here is pseudocode for the pipe program:

Main program
Include header files
Initialize variables
Create log pipe
Create A-B pipe
Create B-C pipe
Create B-D pipe
Fork process A
Loop 10 times
Create 10 records, starting with ‘C’ or ‘D’ chosen randomly
followed by a number from 0 to 9 issued in sequential order
Write each record to the A-B pipe
Write a message to the log pipe
End loop
Exit process A
Fork process B
Loop 10 times
Read a record from the A-B pipe
Write records starting with ‘C’ to the B-C pipe
Write records starting with ‘D’ to the B-D pipe
Write a message to the log pipe
Delay for 1 second
End loop
Exit process B
Fork process C
Loop until no more messages
Read a record from the B-C pipe
Write a message to the log pipe
End loop
Exit process C
Fork process D
Loop until no more messages
Read a record from the B-D pipe
Write a message to the log pipe
Delay 5 seconds
End loop
Exit process D
Loop 30 times (Logging process – not forked)
Read a message from the log pipe
Add the time to the message
Print the message to the screen
End loop
Kill process A if necessary
Kill process B if necessary
Kill process C if necessary
Kill process D if necessary
End

Note: You don’t need to pass any parameters to the child processes because
they already have access to all the pipes that were created in main process.

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational