Program 3.22 using message passing

  

Program 3.22 using message passing

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

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

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.

useful example msg-passing-outline

 
"If this is not the paper you were searching for, you can order your 100% plagiarism free, professional written paper now!"

"Do you have an upcoming essay or assignment due?


Get any topic done in as little as 6 hours

If yes Order Similar Paper

All of our assignments are originally produced, unique, and free of plagiarism.