Posted: December 8th, 2022

Program 3.22 using message passing


Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Program 3.22 using message passing

The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm

The conjecture states that when this algorithm is continually applied all positive integers will eventually reach 1. Write a C program using fork() system call that generates this sequence in the child process. The starting number will be provided from the command line. Because the parent and the child processes have their own copies of the data, it will be necessary for the child to output the sequence in Exercise 3.21. Another approach to designing this program is to create message queues, one for the parent process and one for the child process. The parent can write a message containing the starting number of the sequence to the child’s message queue. After the child process receives the message, the child process will generate the sequence, and send the entire sequence to the parent’s message queue. The parent will receive the sequence from its message queue, then output the sequence to the screen. Before the processes terminate, they will each destroy its own message queue.

One area of concern with cooperating processes involves synchronization issues. In this exercise, the parent and child processes must be coordinated so that the parent does not output the sequence until the child finishes execution. These two processes will be synchronized using synchronous message sending and receiving.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

useful example msg-passing-outline

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
error: Content is protected !!
Open chat
Order through WhatsApp!
You Can Now Place your Order through WhatsApp


Order your essay today and save 30% with the discount code 2022DISCOUNT