Re: how fork returns value

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

 



can someone please help me puzzle this out?

1.   we know that "ps auxwf" will list out all the processes
(including kernel threads) and their parent-child relationship.   so
each of these have a "current", ie, the global task-struct ptr value
called "current", enabling them to be schedulable.

2.   lsmod will list all the modules loaded.   I printk() the
"current", and each running module have its own task struct ptr value.
  But ps cannot see any of them.   But I supposed they should be on
the schedulable list of task-struct right?   Or may be not?

(btw...the module are just simple module, not using kthread_run() or
any other APIs)

not sure....someone has to go through fs/proc/*.c to see how
/proc/[pid] are printed.   ie, how are all the PIDs enumerated?   are
the kernel modules skipped?

On Mon, Oct 6, 2008 at 10:48 PM, Mulyadi Santosa
<mulyadi.santosa@xxxxxxxxx> wrote:
> 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
>
>



-- 
Regards,
Peter Teoh

--
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