0
$\begingroup$

I am reading the book: Digital Design and Computer Architecture: ARM Edition

I am on the chapter about virtual memory. I am wondering, when a page fault occurs, is it the processor or the OS that "fixes it". In the text below they first say that the processor fixes it, then they say it is the OS that fixes it.

Do you understand why it is written this way?

enter image description here

$\endgroup$
1
  • $\begingroup$ The page replacement mechanism is implemented in software, so it is executed by the processor, running a layer of the OS. The author probably tried to avoid repetitions, don't take this too literally. $\endgroup$
    – user16034
    Sep 19 at 21:04

3 Answers 3

1
$\begingroup$

Both. The OS is software that executes on the processor.

$\endgroup$
0
$\begingroup$

Let’s say you want to access data at a certain logical address. Your program might use a “load” instruction. That instruction is implemented in the CPU; it will determine if the data is in a cache and return it quickly, or if it is in RAM and at what physical address and return it slowly, or the hardware determines that the data is not in RAM at all. In that case the hardware interrupts your code and switches to code in the OS that handles the situation.

At that point code in the OS takes over. So it’s the OS running instructions using the processor. The OS is just given the logical address. It will then decide whether your program had the right to access that logical address - if not the OS might even kill your program. Or you have the right, then the OS will arrange things so that your logical address is in RAM and then tell the processor to run the instruction again; this time it should work.

$\endgroup$
0
$\begingroup$

It's done by the software, usually OS. Paging out is the process of writing data to the external memory, a CPU can't do that on its own.

So, the user program is interrupted, OS reads this page from the disk, maybe writes another page to the disk, updates virtual memory tables and returns control back to the user program.

The first citation is incorrect, although from a user program perspective, it doesn't make much difference - the page magically appears in the memory and execution continues.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.