C program on unix that creates four new processes

Assignment Help Management Theories
Reference no: EM13759557

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

 

Reference no: EM13759557

Questions Cloud

Sql statement that displays the isbn-title and profit : Provide a SQL statement that displays the ISBN, TITLE and PROFIT for all books where the COST is greater than or equal to $10.00 and less than or equal to $40.00. (The PROFIT is the difference between RETAIL and COST.) Include only those books tha..
Make the companys vision come to fruition : What are the two or three biggest strengths the organization has that allow it to make the company's vision come to fruition?
Difference a database administrator and a database architect : Describe the differences between a database administrator and a database architect. How is your organization structured to handle the functions of these roles
What logical topologies are supported on an ethernet network : What logical topologies are supported on an Ethernet network and What is the purpose of the backoff on Ethernet networks
C program on unix that creates four new processes : 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.
The professional nursing literature : To prepare for this Discussion, reflect on the readings and on Dr. Mancuso's comments in this week's media presentation; specifically on the role of the BSN nurse in public and global health
How would you approach the physician : How would you approach the physician - What are the reasons for the unavailability of certain pharmaceutical items because of third-party payer reimbursement schemes?
Evaluate the role of religion and superstition on art : Create and explain a five-point checklist of what you should notice when seeing a work of art for the first time. Evaluate the role of religion and superstition on art and art history.
Explain the complexities of auditing a cloud computing : Explain the complexities of auditing a cloud computing deployment that uses the public model

Reviews

Write a Review

Management Theories Questions & Answers

  Describe the primary responses to negative events

Identify the key individual outcomes in the studies of organizational behavior and describe the factors that affect these key outcomes and discuss briefly on the four types of job performance management techniques.

  Describe the new product

Describe the new product.

  Covers all three experiments

Write a complete laboratory report that covers all three experiments

  Diagram a documentary sales transaction

Diagram a documentary sales transaction and locate examples of letters of credit and bills of lading and analyze their content

  Benchmarking

What is the need for benchmarking?

  Choose a large publicly held company to investigate

Choose a large publicly held company to investigate. Download, or otherwise immediately obtain, the complete annual report for this company. The best place to locate the annual report is the company's home website. The annual report will includ..

  Find its volume at 21 degrees celsius and 420kpa

A certain mass of hydrogen gas occupies 370ml at 16 degrees Celsius and 150 kpa. find its volume at 21 degrees Celsius and 420kpa.

  Job analysis and design relevant in the corporate industry

Is job analysis and design relevant in the corporate industries in the 21st century?

  Addresses organizational behaviors

Addresses organizational Behaviors

  Identify and explain the strong points of the managers

Identify and explain the strong points of the managers.

  The union of soviet socialist republics

Miga, a French company, sold hundreds of millions of dollars worth of goods, much of it on credit, to various agencies of the Russian government. The first deals were made with the Union of Soviet Socialist Republics (USSR

  Characteristics of effective business messages

Describe five characteristics of effective business messages and describe at least three common types of teams companies often create.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd