In: Computer Science
This is a multiple answer question. Meaning any number of the four could be true. This is from an O/S class
We discussed in class the ability to create new processes in a Linux environment by way of the fork() function. What is true about this function?
fork() takes a parameter which is the priority of the process that is going to be created |
||
It spawns a new process that is a child of the calling process. The child process is its own, unique process and shares nothing with the parent. The two processes are seen as equal and have no interaction with each other. |
||
The function has a return value. -1 if the function failed to create a new process 0 if we are in the child process that was created a positive integer if we are the in the parent. The positive integer reflects the process ID of the newly created process. |
||
fork() allows you to create handlers for the new process during the creation |
Answer:
False statements:
fork() takes a parameter which is the priority of the process that is going to be created.
(Because it takes no parameters and returns an integer value).
It spawns a new process that is a child of the calling process. The child process is its own, unique process and shares nothing with the parent. The two processes are seen as equal and have no interaction with each other.
(Separate address space for the child will be created with exact copy of all the memory segments from the parent process. Hence, if the child process want to know the process id of parent process then the parent process can store its id in a variable before forking a process. Hence both the processes can have process-ids of each other in case they want to interact with each other thru inter process communication.)
fork() allows you to create handlers for the new process during the creation.
(Because this is the work of clone() method.The function clone() creates a new child process which shares memory, file descriptors and signal handlers with the parent. It implements threads and thus launches a function as a child. )
True statements are as follows:
The function has a return value.-1 if the function failed to create a new process 0 if we are in the child process that was created a positive integer if we are the in the parent. The positive integer reflects the process ID of the newly created process.
Please give thumbsup, if you like it. Thanks.