Question: Problem 2 - Programming Problems. (60pts) - Zip your answer sheet for Problem 1 and problem 2 source codes (e.g.,.c files) together and upload it
Problem 2 - Programming Problems. (60pts) - Zip your answer sheet for Problem 1 and problem 2 source codes (e.g.,.c files) together and upload it to the Blackboard. 2.1 Demonstrate fork() system calls. Description: In Unix/Linux, when we create a process, we first fork from the parent process, then execute a new program in the child process. Your goal is to write a program to: 1. fork() a new child process. (The fork system call creates a new process by duplicating the calling process) 2. After the call to fork, the child process and the parent process run concurrently. 3. Need to use 'child_pid' to hold the process 10 of the child process. If 'child_pid' equal to 0 , the current process is the child process, thus your code need to print out "I am process \#" followd by its process 10 . 4. If 'child_pid" is not equal to 0 , return to the parent process, and print out "l am the parent of process \#" followed by the process 10 of the child process on the screen. 5. In the end of your code, should return to 0 to have a termination of your program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
