Discussion:
Project 4, Part 1: Clarifications
(too old to reply)
Daniel Ramsbrock
2005-10-25 14:05:55 UTC
Permalink
Here is my usual list of clarification items:

1. Do we need to have interrupts disabled while initializing paging
(i.e. during the call to Init_VM)? I assume yes.

2. For part 1, we should use our existing userseg.c, and we'll only
switch over to the new uservm.c in part 2, correct?

3. There are quite a few fields in both pte and pde which it doesn't
seem like we need. It is safe to assume that the only fields we will
need to set are present, flags, and the base address? Can we leave all
other fields set to zero?

4. As mentioned in the slides, we are supposed to set the following
flags in both pde and pte: VM_WRITE, VM_READ, VM_USER. In part 2, we
will be removing VM_USER from both pde and pte (well, at init time
anyhow--VM_USER may be set later when a page is allocated to a user
process). Is that correct?

5. The slide titled "Mapping kernel memory: steps" mentions the
PAGE_DIRECTORY_INDEX and PAGE_TABLE_INDEX functions as being handy.
While I understand what they do, I'm not quite sure how they are useful
during this step--perhaps I'm misunderstanding what needs to be done
during this step. The only place I could imagine using these is when
storing the base addresses--but I'm converting those by simply
right-shifting my addresses by 12 bits (for both pde's and pte's).

6. The same slide also mentions using Get_Page to obtain the Page struct
for a given page address. Once we have this, I assume we do two things:
set vaddr to the current logical address and set entry to the current
pte pointer. We leave flags and clock alone, right?

Thanks,

Daniel
Iulian Neamtiu
2005-10-25 14:59:18 UTC
Permalink
Post by Daniel Ramsbrock
1. Do we need to have interrupts disabled while initializing paging
(i.e. during the call to Init_VM)? I assume yes.
I don't think you need to disable them. Since Init_VM() comes
before Init_Scheduler(), there's only one thread running
hence there's no race condition.
Post by Daniel Ramsbrock
2. For part 1, we should use our existing userseg.c, and we'll only
switch over to the new uservm.c in part 2, correct?
Yes.
Post by Daniel Ramsbrock
3. There are quite a few fields in both pte and pde which it doesn't
seem like we need. It is safe to assume that the only fields we will
need to set are present, flags, and the base address? Can we leave all
other fields set to zero?
Right. You can memset() the whole PD/PT entry to 0 and then set the fields
you're interested in to non-zero values. For Part 2, though, and only for
PTs you'll also modify the 'accessed' and 'kernelInfo' fields.
Post by Daniel Ramsbrock
4. As mentioned in the slides, we are supposed to set the following
flags in both pde and pte: VM_WRITE, VM_READ, VM_USER. In part 2, we
will be removing VM_USER from both pde and pte (well, at init time
anyhow--VM_USER may be set later when a page is allocated to a user
process). Is that correct?
Yes.
Post by Daniel Ramsbrock
5. The slide titled "Mapping kernel memory: steps" mentions the
PAGE_DIRECTORY_INDEX and PAGE_TABLE_INDEX functions as being handy.
While I understand what they do, I'm not quite sure how they are useful
during this step--perhaps I'm misunderstanding what needs to be done
during this step. The only place I could imagine using these is when
storing the base addresses--but I'm converting those by simply
right-shifting my addresses by 12 bits (for both pde's and pte's).
Make sure you use unsigned values and mask off the most
significant bits when right-shifting.
Post by Daniel Ramsbrock
6. The same slide also mentions using Get_Page to obtain the Page struct
set vaddr to the current logical address and set entry to the current
pte pointer. We leave flags and clock alone, right?
I don't think you need to change the struct Page at this point.
Scratch that bullet in the slides. That comes in Part 2 and it's
already implemented for you in Alloc_Pageable_Page().


Iulian

Loading...