<< Chapter < Page Chapter >> Page >

The most common solution is a technique that is sometimes called a shadow table. The idea of a shadow is simple (and familiar toFortran programmers!):

  • Consider the hardware defined data structure as an array.
  • For the new information that you want to add, define a new (shadow) array.
  • There is one entry in the shadow array for each entry in the hardware array.
  • For each new item you want to add to the data structure, you add a new data member to the shadow array.

For example, consider the hardware defined page table to be an array of structures:

struct Page_Entry { unsigned PageFrame_hi : 10; // 42-bit page frame numberunsigned PageFrame_mid : 16; unsigned PageFrame_low : 16;unsigned UserRead : 1; unsigned UserWrite : 1;unsigned KernelRead : 1; unsigned KernelWrite : 1;unsigned Reference : 1; unsigned Dirty : 1;unsigned Valid : 1; }struct Page_Entry pageTable[TABLESIZE];

If you wanted to added a couple of data members, you cannot simply change it to the following:

struct Page_Entry { unsigned PageFrame_hi : 10;unsigned PageFrame_mid : 16; unsigned PageFrame_low : 16;unsigned UserRead : 1; unsigned UserWrite : 1;unsigned KernelRead : 1; unsigned KernelWrite : 1;unsigned Reference : 1; unsigned Dirty : 1;unsigned Valid : 1; Time_t lastRefTime;PageList *shared; }

Instead, you would define a a second array based on this type:

struct Page_Entry { struct PE_Shadow { unsigned PageFrame_hi : 10; Time_t lastRefTime;unsigned PageFrame_mid : 16; PageList *shared; unsigned PageFrame_low : 16; }unsigned UserRead : 1; unsigned UserWrite : 1;unsigned KernelRead : 1; unsigned KernelWrite : 1;unsigned Reference : 1; unsigned Dirty : 1;unsigned Valid : 1; }struct Page_Entry pageTable[TABLESIZE];struct PE_Shadow pageShadow[TABLESIZE];

Virtual memory, page faults

Problem: how does the operating system get information from user memory? E.g. I/O buffers, parameter blocks. Note that theuser passes the OS a virtual address.

  • In some cases the OS just runs unmapped. Then all it has to do is read the tables and translate user addresses in software. However, addressesthat are contiguous in the virtual address space may not be contiguous physically. Thus I/O operations may have to be split up into multiple blocks.Draw an example.
  • Suppose the operating system also runs mapped. Then it must generate a page table entry for the user area. Some machines provide specialinstructions to get at user stuff. Note that under no circumstances should users be given access to mapping tables.
  • A few machines, most notably the VAX, make both system information and user information visible at once (but the user cannot touch system stuffunless the program is running with special kernel protection bit set). This makes life easy for the kernel, although it does not solve the I/O problem.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Operating systems. OpenStax CNX. Aug 13, 2009 Download for free at http://cnx.org/content/col10785/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Operating systems' conversation and receive update notifications?

Ask