1B11 Operating Systems - 3. Memory Management and Protection



Similar documents
Backups and Backup Strategies

System Business Continuity Classification

Licensing Windows Server 2012 for use with virtualization technologies

FOCUS Service Management Software Version 8.5 for Passport Business Solutions Installation Instructions

How To Install Fcus Service Management Software On A Pc Or Macbook

1B11 Operating Systems. Input/Output and Devices

Data Protection Policy & Procedure

System Business Continuity Classification

FOCUS Service Management Software Version 8.5 for CounterPoint Installation Instructions

Software Distribution

HeartCode Information

Licensing Windows Server 2012 R2 for use with virtualization technologies

Microsoft SQL Server Administration

A Beginner s Guide to Building Virtual Web Servers

Implementing ifolder Server in the DMZ with ifolder Data inside the Firewall

Serial ATA Staggered Spin-Up

CSE 231 Fall 2015 Computer Project #4

Performance of an Infiniband cluster running MPI applications

Understand Business Continuity

Deployment Overview (Installation):

2. When logging is used, which severity level indicates that a device is unusable?

Often people have questions about new or enhanced services. This is a list of commonly asked questions and answers regarding our new WebMail format.

Research Findings from the West Virginia Virtual School Spanish Program

Hardware components. Typical connections and data flow. Student 3 page 1: Low Merit

Basic Guide line for The Sportident system

AccessData Corporation AD Lab System Specification Guide v1.1

RECOMMENDATIONS SECURITY ONLINE BANK TRANSACTIONS. interests in the use of IT services, such as online bank services of Société Générale de Banques au

STIOffice Integration Installation, FAQ and Troubleshooting

SUMMARY This is what Business Analysts do in the real world when embarking on a new project: they analyse

SBClient and Microsoft Windows Terminal Server (Including Citrix Server)

Serv-U Distributed Architecture Guide

ACTIVITY MONITOR Real Time Monitor Employee Activity Monitor

990 e-postcard FAQ. Is there a charge to file form 990-N (e-postcard)? No, the e-postcard system is completely free.

Times Table Activities: Multiplication

How To Configure A GSM Modem Using HyperTerminal

Exercise 5 Server Configuration, Web and FTP Instructions and preparatory questions Administration of Computer Systems, Fall 2008

NextGenJustice Florida attorneys have prepared the following Frequently Asked Questions to help you with your uncontested divorce.

4394 Gazzetta tal-gvern ta Malta MINISTRY OF FINANCE. Value Added Tax Department. Fiscal Cash Register Specifications

Within the program, students combine two or more areas of study into one interdisciplinary program. Current program options include:

Fermilab Time & Labor Desktop Computer Requirements

Computer Science Undergraduate Scholarship

Print to Text File at OS Level

Serv-U Distributed Architecture Guide

Service Desk Self Service Overview

David Drivers Revit One-sheets: Linked Project Positioning and shared coordinates

Software and Hardware Change Management Policy for CDes Computer Labs

Personal Data Security Breach Management Policy

Ten Steps for an Easy Install of the eg Enterprise Suite

COPIES-F.Y.I., INC. Policies and Procedures Data Security Policy

This report provides Members with an update on of the financial performance of the Corporation s managed IS service contract with Agilisys Ltd.

Retirement Planning Options Annuities

Identify Major Server Hardware Components

Microsoft Certified Database Administrator (MCDBA)

How To Migrate To A Networks Dmain Name Service On A Pc Or Macbook (For Pc) On A Linux Computer (For Macbook) On An Ipad Or Ipad (For Ipad) On Pc Or Ipa (For

Internet and Policy User s Guide

ELEC 204 Digital System Design LABORATORY MANUAL

Cell Phone & Data Access Policy Frequently Asked Questions

Learn More Cloud Extender Requirements Cheat Sheet

Kepware Technologies ClientAce: Creating a Simple Windows Form Application

Interworks Cloud Platform Citrix CPSM Integration Specification

1)What hardware is available for installing/configuring MOSS 2010?

Exercise 5 Server Configuration, Web and FTP Instructions and preparatory questions Administration of Computer Systems, Fall 2008

How to put together a Workforce Development Fund (WDF) claim 2015/16

Virtual Memory and Address Translation

Frequently Asked Questions About I-9 Compliance

iphone Mobile Application Guide Version 2.2.2

The Ohio Board of Regents Credit When It s Due process identifies students who

Perl for OpenVMS Alpha

DISASTER RECOVERY PLAN TEMPLATE

How to Convert/Burn Photo to DVD/CD Disc and Play on. TV with DVD Player (DVD Photo Slideshow Maker)

Hearing Loss Regulations Vendor information pack

ASUS PC Diagnostics Guide

Trends and Considerations in Currency Recycle Devices. What is a Currency Recycle Device? November 2003

Introduction to Mindjet MindManager Server

ZoomText Network License Installation Guide

Using Identity Finder. ITS Training Document

Customers FAQs for Webroot SecureAnywhere Identity Shield

CenterPoint Accounting for Agriculture Network (Domain) Installation Instructions

Disk Redundancy (RAID)

Volume 2, Issue 11, November 2014 International Journal of Advance Research in Computer Science and Management Studies

ENERGY CALIBRATION IN DPPMCA AND XRS-FP REV A0 ENERGY CALIBRATION IN DPPMCA AND XRS-FP

Remote Desktop Tutorial. By: Virginia Ginny Morris

In addition to assisting with the disaster planning process, it is hoped this document will also::

BLUE RIDGE COMMUNITY AND TECHNICAL COLLEGE BOARD OF GOVERNORS

xdb Configuration Guide

Transcription:

Department f Cmputer Science University Cege Lndn 1B11 Operating Systems - 3 Memry Management and Prtectin Prf. Steve R Wibur s.wibur@cs.uc.ac.uk 1B11-3 1999 Side 1 Lecture Objectives What des the OS have t d t manage memry? Hw des it prvide required sharing when needed and yet inhibit inapprpriate access? 1B11-3 1999 Side 2 12/06/99 1

Department f Cmputer Science University Cege Lndn Prcess Life Cyce Recap T start a prgram, the OS must: Find the binary/executabe n disk Acate strage fr the cde and data Acate swap space n disk Map the pages in memry and swap space Cpy the cde int the physica pages Start executin by saving current cntext (see ater) and jumping (ading the PC) t the start address f the cde! 1B11-3 1999 Side 3 Memry Management Prbems Memry Memry Memry (2) (3) P2 (4) P2 P3 P2 P3 (1) P1 P1 P1 1B11-3 1999 Side 4 12/06/99 2

Department f Cmputer Science University Cege Lndn Memry Management Prbems - 2 (1) Prgrams may be paced in different catins each time they are aded - references t absute addresses wi be invaid (2) When memry fu and need t ad prgram need repacement picy t decide which (part f) prcess t swap ut (3) Need t prtect against prcesses damaging thers - cntainment r prtectin (4) May be enugh rm t ad prgram, but n he is big enugh - fragmentatin 1B11-3 1999 Side 5 Memry Management Sutins Reative addressing deas with (1), e.g.: Jump +50 instead f Jump 456 Lad -90 instead f Lad 20 where = address f current instructin Base and Limit registers dea with (1, 3): B and L registers set t address and size f prcess memry when it becmes current prcess Prgram cmpied as thugh starts at address 0 Prcessr adds B t addresses and checks resut nt ess than zer r >L fr every memry fetch 1B11-3 1999 Side 6 12/06/99 3

Department f Cmputer Science University Cege Lndn Memry Management Sutins - 2 Paged memry deas with (4): Expensive t shuffe up prcesses Page Tabe (mutipe base registers with fixed imit) makes a hes same size Page tabe aws fragments t be physicay separate but have gicay cntiguus addresses 1B11-3 1999 Side 7 Memry Management Sutins - 3 Repacement Picy with sme hep frm hardware deas with (2) dirty bit in page tabe indicates which pages have been written t and are thus mre expensive t swap ut use bit in page tabe set when page accessed and ceared every few miisecnds indicates thse pages which were recenty used - Principe f Lcaity suggests they are a bad chice t swap ut 1B11-3 1999 Side 8 12/06/99 4

Department f Cmputer Science University Cege Lndn Memry Management Prbems - 3 (5) Prgram t arge t fit in rea memry Memry Sutin: Use paging scheme where address space greater than memry space Sme part f prcess wi aways be n disk P3 (5) wi be swapped in when needed (after deay) 1B11-3 1999 Side 9 Virtua Memry Resut is Virtua Memry Prgrams written by human prgrammers are transated (cmpied r interpreted) int machine cde + data Machine cde is executed in a virtua address space which may prvide user with a virtua memry much arger than rea machine, abeit smewhat swer than main memry Curtesy f the OS and hardware cmbined 1B11-3 1999 Side 10 12/06/99 5

Department f Cmputer Science University Cege Lndn Mapping Prcess Fr a 4 GB virtua address space and a 1 GB physica address space 31 30 29 28.... 15 14 13 12 11 10 9.... 3 2 1 0 Virtua page number Page ffset Transatin 29 28.... 15 14 13 12 11 10 9.... 3 2 1 0 Physica page number Page ffset 1B11-3 1999 Side 11 Virtua Memry - 2 The CPU accesses memry via a memry management unit - this uses a page tabe t transate addresses the CPU it gives (virtua addresses) int physica addresses. The perating system ( kerne ) has its wn page tabe that ets it get at everything User prcesses have page tabes managed by the perating system These page tabes map virtua addresses t physica 1B11-3 1999 Side 12 12/06/99 6

Department f Cmputer Science University Cege Lndn Virtua Memry - 3 S each prgram is run apparenty in the address space 0-max address This is mapped in chunks f a page - usuay the same size as a disk bck Mapped t rea memry - r fagged if swapped ut t disk Cntext switches change the page tabes. 1B11-3 1999 Side 13 Virtua Memry - 4 Q. If yu run mre prgrams than wi fit in rea memry (easy t d) what happens? A. Paging. The mst recenty run prgrams are in memry - the dest ne has the bcks (pages) f physica memry written ut t disk, and the page tabe (in memry) changed t say that the pages are n disk - in the swap area This f curse takes time! The page tabe (kept by the OS) keeps a map f the swap area t 1B11-3 1999 Side 14 12/06/99 7

Department f Cmputer Science University Cege Lndn Virtua Address Mapping Prg A Virtua Addresses Physica Memry Addresses Prg B Virtua Addresses 0x0000 Unused Unused 0x1000 0x2000 0x3000 0x4000 0x5000 Unused Memry address space 0x6000 0x7000 N memry Virtua Address Space ::: Disk Addresses ::: 0xD000 0xE000 0xF000 1B11-3 1999 Side 15 Thrashing If there are a t f prcesses, and they d a t f I/O, and they are cnstanty being de-schedued and re-schedued, then there may be a t f paging (cpying f bcks t and frm disk/memry) This makes the system run ike a dg (purey technicay speaking, yu understand) Its caed thrashing - very itte prgress is made under such circumstances. 1B11-3 1999 Side 16 12/06/99 8

Department f Cmputer Science University Cege Lndn Prtectin Operating System prvides varius degrees f prtectin fr the user and prgrams... Safety - Ps shud nt be abe t damage thers accidentay r deiberatey Fairness - Ps shud get fair treatment based n picies in frce Integrity - basic assumptins shud nt be viated Authenticity - ensure bjects are what they purprt t be OS enhances hardware supprt, t give a smarter virtua service 1B11-3 1999 Side 17 MMU Prtectin Memry maps (page tabes) prvide basic prtectin against damage, because P can ny see rea memry that has been mapped t it Each page can be marked as: read write execute r a cmbinatin 1B11-3 1999 Side 18 12/06/99 9

Department f Cmputer Science University Cege Lndn MMU Prtectin - 2 Fr exampe: cde wud nrmay be execute-ny t prevent cpies being taken r being verwritten accidentay cnstants, incuding strings, wud be read-ny s they cannt be changed ] Cnsider x := x+1 if cnstant 1 was changed t 4!! wrking data and the stack wud be read+write 1B11-3 1999 Side 19 MMU Prtectin - 3 Tw r mre prcesses can share memry pages (nt necessariy at the same address in each P) ne might have write access, the ther read access - prducer-cnsumer prcesses e.g.. print server bth might have read-write access - appicatindefined sharing - need t carefuy cntr use (st updates?) bth might have execute access - shared ibraries Ony OS can change the page maps s it cntrs access 1B11-3 1999 Side 20 12/06/99 10

Department f Cmputer Science University Cege Lndn Sharing Pages Prcess A Physica Memry Prcess B 0x0000 0x1000 0x2000 0x3000 0x4000 0x5000 0x6000 0x7000 - Unused X X X R RW RW - Library 2 Unused Library 1 N memry X X Unused Virtua Address Space Yew pages in rea memry are mapped t different addresses in Prcesses A and B. Even thugh pages are disjint in memry they appear cnsecutive in bth prcesses 1B11-3 1999 Side 21 Kerne and User Mde Q. Hw des the OS stp user prcesses frm getting at these data structures (e.g. Page Tabes, Prcess tabes etc)? A. The prcessr can be set t kerne mde r user mde (When the machine is bted it is set t kerne mde and memry mapping is set t Virtua = Rea) The prcessr mde is changed as a side effect when the prcessr executes a trap r interrupt 1B11-3 1999 Side 22 12/06/99 11

Department f Cmputer Science University Cege Lndn Kerne and User Mde - 2 In kerne mde any instructin can be executed (OS runs in this mde) In user mde, (nrma prcesses,) I/O, hat and sme ther instructins cause a mde change t kerne mde and fr a rutine at a fixed catin t be invked This mechanism is knwn as a trap 1B11-3 1999 Side 23 Traps There are at east 3 types f trap: System cas - Specia instructins which can be used t invke OS functins e.g. create a new prcess Exceptins - these ccur when the prcessr executes an instructin which makes n sense, e.g. ] Divide by 0 ] iega instructin - undefined r nt awed in user mde ] iega memry access Interrupts - generated by I/O devices when they are dne 1B11-3 1999 Side 24 12/06/99 12

Department f Cmputer Science University Cege Lndn Cd Start ROM Btstrap OS Kerne mde Machine starts in kerne mde Memry management ff - i.e. mapped Virtua = Rea ROM btstrap executed t ad OS Page tabe set fr perating system t see whe memry OS R, X, W as apprpriate free space R, W Page Tabes Memry management switched n 1B11-3 1999 Side 25 Cd Start - 2 User mde ROM Btstrap Kerne mde Initia user prcess aded cmmand prcessr OS gin prcess, etc. PCB created User Prcess 1 PCB1 User P s initia PC, SP, page tabe pre-aded int PCB PCB added t head f Ready t Run Q Page Tabes Dispatcher invked 1B11-3 1999 Side 26 12/06/99 13

Department f Cmputer Science University Cege Lndn Cd Start - 3 ROM Btstrap Kerne mde Set up user mde page tabe fr P1 frm faked PCB OS Return t P1 causes PC t be set causes mde change t user mde User Prcess 1 User mde P1 executes PCB1 Page Tabes 1B11-3 1999 Side 27 Cd Start - 4 ROM Btstrap User mde Kerne mde P1 needs t d I/O - e.g. get user s gin name System ca fr synchrnus read Change t kerne mde OS Vatie registers saved in PCB by OS User Prcess 1 PCB1 OS sets up I/O peratin P1 status = Bcked Ide prcess (interna in OS) run unti I/O cmpete Page Tabes Try extending this fr mutipe user prcesses 1B11-3 1999 Side 28 12/06/99 14

Department f Cmputer Science University Cege Lndn Summary Memry management needed t ensure M used efficienty Page tabes prvide safe mechanism Pages can be fagged as read, write r execute r a mixture Ony OS awed t change tabes User mde ensures nrma user cannt access I/O devices r act as OS Traps prvide means f changing mde and cmmunicatin between user P and OS 1B11-3 1999 Side 29 12/06/99 15