One Child Process, Communicating with the Parent

One Child Process, Communicating with the Parent
Assignment Task

1 Circular queues again

Examine int_64_test_01.c and compile it and run it. The purpose of this code is to show that it is possible to define very large integers, with 64 bits that fit into 8 bytes. It is possibly easier to store all the data in one data type. The sample code, circular_queue_example_07.c uses int_64_t.

You may well have your own solution from Computer Exercise 01, but a sample solution has been provided as circular_queue_example_07.c read through the source-code and compile and run it.

2 Separate processes, communicating through pipes

We plan to examine the metaphor of communication between a process that produces data and a process that consumes data. In the Computer Science literature this is known as the producer – consumer problem. It is a classic example of a multi-process synchronization problem. We begin with the simplest case, of one producer and one consumer. The producing process will be a loop, like the one in fork_demo_05.c. The consuming process will be like the main loop in circular_queue_example_07.c. The differences in timing will be handled by temporary storage in the pipe.

2.1 One child process, communicating with the parent

Use fork() to create a child process that generates the data for events, a source (PID), and an elapsedtime, and writes these into a pipe. The parent process will read the pipe, assemble the data into the correct format and insert it into a circular queue. There should be no dispatch during this accumulation process.

The child-process and parent process need to agree on a stopping condition. A suitable way to do this is to make each process stop after a given period has elapsed, say 1 minute. Note that both the parentprocess and the child-process are handling variables containing elapsed times. It should be easy to test for a condition where the elapsed-time has exceeded a limit.

The parent needs to perform a waitpid() for the child.

All the events in the queue need to be dispatched at the end, to show that the events have been captured and placed in the queue.

2.2 Two child processes, communicating with the parent

Use two forks to create two independent free-running processes that generate the data for events and write these into two separate pipes. The parent process will need to fork() the two child processes.

There needs to be a counter, or flag, that changes between each fork(), so that each child process can test that value to see if it is the first or second child and choose the correct pipe to use. The parent processneeds to read from the two pipes, in sequence, in a “super loop”, and stop when the total time has expired.

The parent needs to perform two instanced of waitpid(), one for the child.

All the events in the queue need to be dispatched at the end, to show that the events have been captured and placed in the queue. The queue should contain events from both child processes. These can be distinguished using the different PID values associated with the different events.

This IT Assignment has been solved by our IT experts at Schooling Best. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.