LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Relation b/w Scheduler & No. of C.P.U's (https://www.linuxquestions.org/questions/linux-newbie-8/relation-b-w-scheduler-and-no-of-c-p-us-726998/)

harrynath 05-19-2009 05:45 AM

Relation b/w Scheduler & No. of C.P.U's
 
wenever i call fork always the child process gets scheduled first...
i dont set priority or call schedule_yeild()...it just happen every time
i wonder why?
i am running openSUSE on interl core2 duo laptop

I never recompiled my kernel, so by default i think 2 cpus are enabled...

could anybody tell me what is the relation between no. of c.p.u's n scheduler?

syg00 05-19-2009 07:57 PM

Quote:

Originally Posted by harrynath (Post 3545606)
wenever i call fork always the child process gets scheduled first...
i dont set priority or call schedule_yeild()...it just happen every time
i wonder why?

Probably just lucky ... :p
I don't see anything that is biased in favour of the child - although as a new task, presumably it would be more "left-most" in the red-black tree the scheduler uses than the creating task and thus more likely to be scheduled (presuming CFS).
In other words, the parent has consumed CPU time, and so has drifted to the right in the tree - anything to the left of it in the tree will dispatch first.
Quote:

could anybody tell me what is the relation between no. of c.p.u's n scheduler?
Probably only Ingo - he wrote (most of) the scheduler.
There is a run queue per CPU, but it is likely parent and child will queue on the same CPU because of the amount of common data that will benefit from being in (hardware) cache.

harrynath 05-19-2009 08:06 PM

thanx sir...

but still that wud contrary to the very well acclaimed fact-"in linux fork creates child process, and its unpredictable to tell which process schedules first"

this is wat buks have told to me!

could u plz discuss this more!

chrism01 05-19-2009 08:54 PM

It unpredictable as to which process has priority when its running ie parent or child. Depends on what its doing. OTOH, Linux will create new processes as a priority.

syg00 05-19-2009 09:05 PM

The scheduler was recently completely rewritten. I doubt many books are cognisant of the fact.


All times are GMT -5. The time now is 05:29 AM.