Welcome! Log In Create A New Profile

about page directories and page tables

Posted by shailesh 
about page directories and page tables
September 13, 2009 01:56AM
I read that if only one linear address is assigned to a
process, all the remaining 1,023 entries of the Page Directory
are filled with zeros. So what I thought can't we make the Page Directory
and Page Table entries as zeros before hand when the CPU is free just like
how a screen saver works. Use the CPU cycles to make Page Directory and
Table entries as zeros instead of doing it later while executing a process. This
will increase the CPU efficiency and will execute processes a bit faster.
Sorry if you think this is a stupid question. I don't know much about this as
I am a newbie.
Re: about page directories and page tables
September 16, 2009 04:27AM
I'd like to guess

Let me guess:
1. Things will get worse if
-- Do zeroing when free but just zeroed some bytes of the data structure, then as sched CPU executes the process, it needs to zero (the whole data structure) again.

2. Things will get worse too if
-- Do spin-lock while zeroing, so case 1 gets avoided; but this downgrades response-speed of the kernel because that the process execution was blocked by zeroing-when-free().

3. If zeroing was not necessary, things would be different but (keep guessing)

-The Effo Staff
Effo Project, [effo.sourceforge.net]
Re: about page directories and page tables
September 16, 2009 12:31PM
we can set some kind of flag indicating that the page is zeroed and no need to scrap the current system in which the page is zeroed only when it is used, we can execute our code only when the CPU is free, just like how a screen saver works or when the CPU utilization is say below 5%..if only some bytes of the data structure are zeroed the flag wont be set and anyways it'll be zeroed while executing a process if the flag is not set.. will this work?
Re: about page directories and page tables
September 16, 2009 10:44PM
This time I'll not just guess

Per multi-processor or multi-core (actually multi-kthreading on a non-mp should be the good example too),
A on CPU#0:
A0 void polling_new_tasks()
A1 {
A2    struct my_task *task;
A3    for_each_new_task(task) {
A4        if (!task->flag) {
A5            zero(task->pgdir);
A6            task->flag = zeroed;
A7        }
A8    }
A9 }

B on CPU#1:
B0 int exec_task(struct my_task *task)
B1 {
B2     if (!task->flag) {
B3        zero(task->pgdir);
B4        task->flag = zeroed;
B5    }
B6    alloc_pages(task->pgdir);
B7    return do_exec(task);
B8 }

When A5 (zeroing not complete yet) if CPU0 needs to execute other tasks while at the same time CPU1 is executing B2:B7; then CPU0 comes back to execute A5:A6 while the process is running on CPU1 (i.e. since B7), what will happen there? Check another flag? Use lock? Or the kernel ensures them mutually exclusive already? Get it into so much trouble. I have no ideas.

I believe that you'll get a sounds solution if keep thinking
But now if the CPU(s) is free, just let it be free to save power.

I'm thinking too:
Any polling is alway ugly and just wastes power. Furthermore, if want to do something, the penalties (memory space or CPU cycles such as flags or locks, and so on) will come along, I'd balance them carefully.

Hope other guys may give us better advices.

-The Effo Staff
Effo Project, [effo.sourceforge.net]
Author:

Your Email:


Subject:


Message: