> 1- In two moments the variable counter is initialized.
>
> a) When a process is created (using the function do_fork in fork.c)
> "p->counter = (current->counter >>= 1);"
>
> b) When all process have counter equal to zero and it is necessary to reinitialized the variable counter (using the function schedule in sched.c).
> "p->counter = (p->counter >> 1) + p->priority"
>
> QUESTION: Why does the division by two is necessary ??
When you create a new process, the counter variable should
be defined to something useful so we can schedule predictably.
The second calculation is done when all runnable processes
are out of credit (counter == 0). We do this because we
need to have the counter at a meaningful value in order to
decide which process to schedule.
> 2- The function "sys_sched_yield" is defined in sched.c and
> it uses the variable counter. I could not find where this
> function is called
>
> QUESTION: Do you know where it happens??
It's a system call. You call it from userland whenever you
want to yield the CPU (in order to spin on a spinlock or to
release control to one of your sibling threads).
Rik -- Open Source: you deserve to be in control of your data.
+-------------------------------------------------------------------+
| Linux Memory Management site: http://humbolt.geo.uu.nl/Linux-MM/ |
| Nederlandse Linux documentatie: http://www.nl.linux.org/ |
+-------------------------------------------------------------------+
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/