J
jaeHyukLee
Guest
I learned that Fork in Unix return to parent First and later return to child, but it makes useless copy in COW(Copy On Write) because usually Child process are different from parent.
So.. to get rid of useless copy in Unix's Fork system call, Linux's Fork pushes Child process in Ready Queue with higher priority than Parent and Let OS check Ready List to give CPU to another process if it has much higher priority than current process When it return from Kernel.
Then in Linux do need wait system call in Parent process Routine? like below
//Code Start
pid = fork();
if (pid == 0) /* This is child process */
{
printf("I am Child \n");
execlp("/bin/date", "/bin/date", (char *) 0);
}
else /* This is parent process */;
wait();/*parent sleeps child run to completion parent resume*
/* If wait(2) is omitted, parent runs concurrently with child */
//Code End
Can i delete wait System call in Linux? because we don't make Parent wait until child end, because Child process is executed before Parent is restarted.
and second Question.
How Parent process know Child Process end or not in Linux?
In Unix system, Parent waits Child process to be End and wait system call makes it available. In other words, OS make parent sleep in wait list until child to be finished, but in Unix if we use Wait System call in Parent service routine, we can't execute wait call before Child process end. Then how can we make Parent know Child process End?
So.. to get rid of useless copy in Unix's Fork system call, Linux's Fork pushes Child process in Ready Queue with higher priority than Parent and Let OS check Ready List to give CPU to another process if it has much higher priority than current process When it return from Kernel.
Then in Linux do need wait system call in Parent process Routine? like below
//Code Start
pid = fork();
if (pid == 0) /* This is child process */
{
printf("I am Child \n");
execlp("/bin/date", "/bin/date", (char *) 0);
}
else /* This is parent process */;
wait();/*parent sleeps child run to completion parent resume*
/* If wait(2) is omitted, parent runs concurrently with child */
//Code End
Can i delete wait System call in Linux? because we don't make Parent wait until child end, because Child process is executed before Parent is restarted.
and second Question.
How Parent process know Child Process end or not in Linux?
In Unix system, Parent waits Child process to be End and wait system call makes it available. In other words, OS make parent sleep in wait list until child to be finished, but in Unix if we use Wait System call in Parent service routine, we can't execute wait call before Child process end. Then how can we make Parent know Child process End?