CMSC 412 Lecture 12: Sharing Memory and Page Faults - Prof. Jeffrey K. Hollingsworth, Study notes of Operating Systems

The concepts of sharing memory in computer science, including how pages can be shared among processes and the safety of sharing read-only data. It also discusses what happens when a virtual address has no physical address, known as a page fault, and how the operating system handles it. Information on protection attributes in win32 and the steps to handle a page fault.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-e1t-1
koofers-user-e1t-1 🇺🇸

5

(1)

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CMSC 412 – S02 (lect 12)
Announcements
zProject #2 is available on the web
Atoi.c has been posted
Reference solution to project #1, delete loop in Print_String
function inside libuser.c
zMidterm #1 was returned
Solution on web
Must submit requests for re-grades in writing by 3/19/02
Grade breakdown (stddev 13.2)
84152015201020Max
30404003Min
56.299135812Avg
Total654321
pf3
pf4
pf5

Partial preview of the text

Download CMSC 412 Lecture 12: Sharing Memory and Page Faults - Prof. Jeffrey K. Hollingsworth and more Study notes Operating Systems in PDF only on Docsity!

Announcements

z^ Project #2 is available on the web

  • Atoi.c has been posted– Reference solution to project #1, delete loop in Print_Stringfunction inside libuser.c

z^ Midterm #1 was returned

  • Solution on web– Must submit requests for re-grades

in writing

by 3/19/

  • Grade breakdown (stddev 13.2)

Max

Min

Avg

Total 6 5 4 3 2 1

Sharing Memory

z^ Pages can be shared

  • several processes may share the same code or data – several pages can be associated with the same page frame – given read-only data, sharing is always safe

z^ when writes occur, decide if processes share data

  • operating systems often implement “copy on write” - pagesare shared until a process carries out a write
    • when a shared page is written, a new page frame isallocated • writing process owns the modified page • all other sharing processes own the original page
      • page could be shared
        • processes use semaphores or other means to coordinateaccess

-^ NOACCESS: attempts to read, write or execute will cause an accessviolation–^ READONLY: attempts to write or execute memory in this region causean access violation–^ READWRITE: attempts to execute memory in this region cause anaccess violation–^ EXECUTE: Attempts to read or write memory in this region cause anaccess violation–^ EXECUTE_READ: Attempts to write to memory in this region cause anaccess violation–^ EXECUTE_READ_WRITE: Do anything to this page–^ WRITE_COPY: Attempts to write will cause the system to give aprocess its own copy of the page. Attempts to execute cause accessviolation–^ EXECUTE_WRITE_COPY: Attempts to write will cause the system togive a process its own copy of a page. Can’t cause an access violation

OS Protection attributes (Win32)

Handling a page fault

1) Check if the reference is valid

  • if not, terminate the process

2) Find a page frame to allocate for the new process

  • for now we assume there is a free page frame.

3) Schedule a read operation to load the page from disk

  • we can run other processes while waiting for this to complete

4) Modify the page table entry to the page 5) Restart the faulting instruction

  • hardware normally will abort the instruction so we just returnfrom the trap to the correct location.