Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Sharing Memory - Lecture Slides - Operating Systems | CMSC 412, Study notes of Operating Systems

Material Type: Notes; Professor: Hollingsworth; Class: Operating Systems; Subject: Computer Science; University: University of Maryland; Term: Spring 2004;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-02o-2
koofers-user-02o-2 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 13

Related documents


Partial preview of the text

Download Sharing Memory - Lecture Slides - Operating Systems | CMSC 412 and more Study notes Operating Systems in PDF only on Docsity! 1CMSC 412 โ€“ S04 (lect 11) Announcements Reading: โ€“ Today: Chapter 9.4-9.6 Midterm: โ€“ Tuesday 2CMSC 412 โ€“ S04 (lect 11) Sharing Memory 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 when writes occur, decide if processes share data โ€“ operating systems often implement โ€œcopy on writeโ€ - pages are shared until a process carries out a write โ€ข when a shared page is written, a new page frame is allocated โ€ข 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 coordinate access 5CMSC 412 โ€“ S04 (lect 11) โ€“ NOACCESS: attempts to read, write or execute will cause an access violation โ€“ READONLY: attempts to write or execute memory in this region cause an access violation โ€“ READWRITE: attempts to execute memory in this region cause an access violation โ€“ EXECUTE: Attempts to read or write memory in this region cause an access violation โ€“ EXECUTE_READ: Attempts to write to memory in this region cause an access violation โ€“ EXECUTE_READ_WRITE: Do anything to this page โ€“ WRITE_COPY: Attempts to write will cause the system to give a process its own copy of the page. Attempts to execute cause access violation โ€“ EXECUTE_WRITE_COPY: Attempts to write will cause the system to give a process its own copy of a page. Canโ€™t cause an access violation OS Protection attributes (Win32) 6CMSC 412 โ€“ S04 (lect 11) 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 return from the trap to the correct location. 7CMSC 412 โ€“ S04 (lect 11) Page Fault โ€“ Page is Paged out Page Directory Page Table Page Frames P1 Reference To this page 1) Fault 2) Read from Disk 3) Make Entry 4) Continue 10CMSC 412 โ€“ S04 (lect 11) Page Replacement Algorithms FIFO โ€“ Replace the page that was brought in longest ago โ€“ However โ€ข old pages may be great pages (frequently used) โ€ข number of page faults may increase when one increases number of page frames (discouraging!) โ€“ called beladyโ€™s anomaly โ€“ 1,2,3,4,1,2,5,1,2,3,4,5 (consider 3 vs. 4 frames) Optimal โ€“ Replace the page that will be used furthest in the future โ€“ Good algorithm(!) but requires knowledge of the future โ€“ With good compiler assistance, knowledge of the future is sometimes possible 11CMSC 412 โ€“ S04 (lect 11) Page Replacement Algorithms FIFO โ€“ Replace the page that was brought in longest ago โ€“ However โ€ข old pages may be great pages (frequently used) โ€ข number of page faults may increase when one increases number of page frames (discouraging!) โ€“ called beladyโ€™s anomaly โ€“ 1,2,3,4,1,2,5,1,2,3,4,5 (consider 3 vs. 4 frames) Optimal โ€“ Replace the page that will be used furthest in the future โ€“ Good algorithm(!) but requires knowledge of the future โ€“ With good compiler assistance, knowledge of the future is sometimes possible 12CMSC 412 โ€“ S04 (lect 11) Page Replacement Algorithms LRU โ€“ Replace the page that was actually used longest ago โ€“ Implementation of LRU can be a bit expensive โ€ข e.g. maintain a stack of nodes representing pages and put page on top of stack when the page is accessed โ€ข maintain a time stamp associated with each page Approximate LRU algorithms โ€“ maintain reference bit(s) which are set whenever a page is used โ€“ at the end of a given time period, reference bits are cleared
Docsity logo



Copyright ยฉ 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved