Re: how fork returns value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi...

On Mon, Oct 6, 2008 at 7:51 PM, Lal <learner.kernel@xxxxxxxxx> wrote:
> On Mon, Oct 6, 2008 at 12:03 PM, Mitul Modi <mituld.modi@xxxxxxxxx> wrote:
>> hi Lal,
>>
>> thanks for the analysis and clearing the doubt. so, parent process returns
>> while child is added in to runqueue. right?
>>
>
> Depends. For example if CLONE_VM is not set, then kernel runs child
> process first in anticipation of an exec to avoid COW overhead.
> If CLONE_VM is set then kernel puts the child process at the end of
> runqueue. The parent process continues through ret_from_intr where
> kernel may again decide to schedule it out and run another process
> (may be child process or some other).

Even though it's not using CLONE_VM, the tendency is to prefer running
child first. IMO it has  relationship with the way most programmer
expect. Parent forks, child does something, parent waits 'til child
exits. By letting child runs first, you save one context switch....
since if you do the otherwise, parent runs first just to find itself
go into waiting state.

regards,

Mulyadi.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux