Docsity

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

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.