Question
This is an Operating systems problem. Please modify the following C-code to do the following things: Things to modify the code with:: 1.the child process
This is an Operating systems problem. Please modify the following C-code to do the following things:
Things to modify the code with::
1.the child process generates this sequence of numbers{ 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1} instead of simply printing out a message
2.The child process should take the user input n from the command line and print out the sequence of numbers.
Here is more background info to help with number 2 of the modification:
3. The parent invoke the wait() call to wait for the child process to complete before exiting the program
4.The parent process to take the user input n and send it to the child process using the named pipe. Once receiving the user input from the parent process, the child process should print out the sequence of numbers.
C Code to modify:
#include
int main() { int n = fork(); if (n > 0) //when n is not 0, then it is parent process { wait(NULL); std::cout
return 0; }
The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: 11 = { n/2, if n is even 3 x n +1, if n is odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: 11 = { n/2, if n is even 3 x n +1, if n is odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started