Use following code in C programming languages to create parent and child process and find the values?
- Use following code in C
programming languages to create parent and child process and find the values?
The output of the program will be:
CHILD process value = 20
PARENT process value = 5
The child process will print "CHILD process value = 20" and the parent process will print "PARENT process value = 5".
Explanation:
The value of "value" will be passed down from the parent process to the child process in the form of the inherited value. After that, the value will be brought up to 20 by the child process by adding 15 to the value that it inherited. Before publishing the value of "value," the parent process will wait for the child process to finish and then return to its own state. In the parent process, the value of the variable "value" will not change; it will continue to be 5. a process that enables one item to take on the characteristics and act in the same way as another object. When discussing fork() and exec(), the term "inheritance" refers to the phenomenon in which the characteristics of the parent process are passed down to the child process.
This includes the values of any variables that are defined in the process that is being referred to as the parent. Using the fork() system function will result in the beginning of a new process. The new procedure is essentially an identical replica of the previous procedure. The newer process is considered to be the kid process, while the older process is considered to be the parent process. The characteristics of the parent process are passed down to the child process during the process of inheritance. This includes the values of any variables that are defined in the process that is being referred to as the parent.
Step by step
Solved in 2 steps