Write a program that creates a chain of n processes


Problem:

Question 1- Write a program that creates a chain of N processes, where N is the command line parameter. Each process creates a child process, print out its own PID and its parents PID, and then waits for its child to terminate by calling the wait() function.

Question 2- Write a program that creates a fan of N processes, where N is the command line parameter. The parent process creates N child processes, each prints out its own PID and its parent's PID. After creating N processes and printing out its PID, the parent process waits for its children to terminate by calling the waitpid() function.

Quetion 3- Use Posix Thread to do the following activity. Write a program that creates two threads, one reading a text you create that contains a series of none-zero numbers ended by a special number -1 and stores the numbers , including the ending -1, into an array, while the other thread write the numbers in the array to a newly created text file in the same directory. Note: make sure the thread that writes the numbers to file come back to read the array until -1 is encountered, if the writing is faster than the reading. You need to figure out how to tell the writing thread where is the last item that has been read into the array when the reading is still ongoing.

Please show code with comments so I can follow what you are doing.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that creates a chain of n processes
Reference No:- TGS0893991

Expected delivery within 24 Hours