0

So as we know when page fault occurs: (1)the hardware traps to the kernel (2) saves program counter on the stack
(3)assembly-code routine saves all registers on corresponding process table entry (4)page fault handler discovers which virtual page is needed
(5)if everything is valid and no page frames are free, the page replacement algorithm is run to select a victim
(6) If the page frame selected is dirty, the page is scheduled for transfer to the disk, and a context switch takes place, suspending the faulting process and letting another one run until the disk transfer has completed (7)and after step 6 is another 4 steps to bring in the corresponding page from backing store in RAM and so on ......

what i dont understand is that when at step 6 context switch occurs this means that page fault handler must suspend until disk transfer has completed , but how is it then posible to resume page fault handler at step 7>? as i know all handlers(Interrupt , trap , fault) are running in kernel and they are not processes

  • There are plenty of other places where kernel code must sleep while it is executing on behalf of a process. You see it all the time in system calls: `sleep()`, `read()`, etc, etc. This is no different - the only difference is that the process entered kernel mode by means of a page fault rather than an explicit syscall trap. The process will resume at the same place where it went to sleep: in kernel mode, in the page fault handler. – Nate Eldredge Aug 10 '21 at 17:46
  • so you mean that page-fault service routine is part of process that caused page fault? – Evariste Galois Aug 10 '21 at 17:54
  • I mean, it's physically in the kernel, but when it's running, part of its context is the process which triggered the fault and all of its userspace state (registers, memory map, etc). So when that context is restored, we are back in the kernel's page fault handler, with the knowledge of which process originally caused the fault and everything else about it. Whether that makes the handler "part of the process" is I guess a philosophical question. – Nate Eldredge Aug 10 '21 at 17:57
  • :D :D ..... so this means that page fault handler is resumed when the process(that cause fault) is scheduled again ?? i finally got it , thanks bro :)))) – Evariste Galois Aug 10 '21 at 18:04

0 Answers0