3
$\begingroup$

Does a process's page table too gets swapped out to secondary storage from main memory when the process gets swapped out to secondary storage from main memory? And gets swapped back in when the process is swapped in?

I tried to find the answer in text books and online, but none is clear.

Also, it would be helpful if you can tell me if the PCB (process control block) of a process also gets swapped out when the process is swapped out.

$\endgroup$
3
  • 1
    $\begingroup$ Are you asking about a particular OS? If so, you should edit your question to specify it. Some of this sounds to me like design decisions that could vary from OS to OS. The definitions of some terms may well vary per OS too. $\endgroup$
    – PJTraill
    Feb 24, 2017 at 19:04
  • 2
    $\begingroup$ Swapping out any data owned by the kernel is extra difficult, and many operating systems don't even try. Page tables in particular usually can't be swapped out, because they record what has been swapped out, which the page-fault handler may need to know at any moment. "Process control block" sounds very OS-specific to my ear, but I think I know what you mean, and those usually can't be swapped out either because basic information about all processes needs to be available at all times. $\endgroup$
    – zwol
    Jun 5, 2017 at 21:14
  • $\begingroup$ A process' pages need not be all swapped out to disk, so the process' page table needs to be resident. $\endgroup$
    – user16034
    Feb 6 at 15:37

2 Answers 2

0
$\begingroup$

There are two different methods: Method 1 is that the page table maps a logical address to a physical address. Since two processes use the same logical addresses (for totally different things), process B using the page table set up for process A would be fatal, so that page table needs to be swapped out. That's time consuming and painful.

Method 2 is that the page table maps a combination of logical address + an identifier for the process to a physical address. So having entries for other processes in your page table is not a problem, they will not be used, they may be swapped out at some point if the new process needs more page table address, but the transition is smooth, and there is only one method for changing page table entries.

With Method 2, in the not uncommon case that two processes don't actually need the whole page table, it's quite possible that the CPU can switch forth and back between these two processes without touching the page table at all.

No idea why this question has come back, but since it's here, a little addition. There are two things that you never, ever, ever swap out. One is your hard disk driver, because it's no good to you if it is somewhere on your hard disk and you can't read it because you need a hard disk driver in real accessible RAM. The other is the part of the page table that tells you were your page table is stored. If that is swapped out, then you can't read your page table.

$\endgroup$
-1
$\begingroup$

The below article include the answer of your questions, apparently this is possible using multi level page table.

https://www.8bitavenue.com/page-table-vs-inverted-page-table/

$\endgroup$
1
  • 4
    $\begingroup$ Can you include the main aspects of the article here so that the answer is self-contained? $\endgroup$ Apr 22, 2020 at 15:00

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.