Class Note for CMPSCI 377 at UMass(17)
Class Note for CMPSCI 377 at UMass(17)
Popular in Course
Popular in Department
This 2 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Massachusetts taught by a professor in Fall. Since its upload, it has received 16 views.
Reviews for Class Note for CMPSCI 377 at UMass(17)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CMPSCI 377 Operating Systems Spring 2009 Lecture 17 April 7 Lecturer Mark Carrier Scribes Bruno Silva Jim Partau 171 Sharing Memory As we have discussed in previous lectures page tables map virtual page addresses to physical page addresses One of the advantages of using virtual addresses is that we can achieve complete separation between processes in terms of address spaces One drawback to this is that it is convenient to be able to share some things for example library code which would otherwise be replicated wastefully by many different programs We donlt want to have to load exactly the same library code into every process7 address space weld prefer to map the library code to its own pages and let all processes share those pages This will usually reduce the memory requirements for the systemi ln order to do this we need to do some common tricks with page tables The rst important memorysharing concept is known as CopyOrb Write or COWi COW shares pages by default whenever sharing is still possible Whenever a new process is created for example by forkO we clone an old process by making a copy of its page tables and marking all referenced pages as readonlyi Then whenever either of the processes the original one or the clone tries to write to one of the pages the two processes will differ and sharing is no longer possible The OS allocates a new page and changes the mapping in one of the page tables If neither of the processes ever tries to modify a memory location however the processes will share the same readonly pages foreverl COW tries to maximize the amount of sharing at all times There are a number of status bits in page tables in addition to valid resident and dirty including readable writable and executable Shared libraries are readable and executable because they include code but are not writablei ln this way processes can share libraries without worrying that another process can corrupt their address space because the pages used for shared libraries are not writablei As a different type of example interprocess communication lPC can use shared memory which is readable and writable as a wide and highspeed communication path between processesi COW follows the principle of delaying work until it needs to be done because often it turns out that due to an error or similar condition the work won t have to be done after all 172 Allocating new pages Processes have valid and invalid entries on their page tables The valid entries all point to somewhere real eg a physical page or some portion of disk in case of nonresident pages etc The entries that donlt point anywhere are the entries that we will use when allocating a new page The allocation of new pages can be done in two ways either via SbrkO or via mmapOi lf you want to increase the size of the heap ice the number of valid pages you can use sbrkOi Using mmapO on the other hand maps a le into a process7 virtual address space ln the allocator you implemented for example you 17 1 172 Lecture 17 April 7 used map to map memory addresses to the le devzeroi This makes it seem like you were allocating space from devzero each time you called mmapi Remember that whenever you read something from devzero7 you get only zeroes for as long as you want to keep reading But7 since devzero is a readonly le and we usually call mmap using the MAPJ RIVATE ag7 we follow the COW rules When you actually try to write to the memory mmap7d from devzero7 the OS intervenes and clones the corresponding pager So7 instead of actually writing to devzero7 you end up writing to a new memory pager
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'