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$
  • 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 '17 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 '17 at 21:14
0
$\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/

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Can you include the main aspects of the article here so that the answer is self-contained? $\endgroup$ – 6005 Apr 22 at 15:00
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.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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