1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching, 80286.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Memory Management Unit
Chapter 3 Memory Management
1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 2: The hardware view dr.ir. A.C. Verschueren.
Part IV: Memory Management
1/1/ / faculty of Electrical Engineering eindhoven university of technology Processor support devices Part 3:Memory management, floating point dr.ir. A.C.
Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
16.317: Microprocessor System Design I
Virtual Memory Background Demand Paging Performance of Demand Paging
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 3: Multitasking and Memory.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Memory Management Design & Implementation Segmentation Chapter 4.
Memory Management (II)
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
1 Computer System Overview OS-1 Course AA
Memory Management 2010.
OS Spring’03 Introduction Operating Systems Spring 2003.
Memory Management Chapter 5.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
Virtual Memory Deung young, Moon ELEC 5200/6200 Computer Architecture and Design Lectured by Dr. V. Agrawal Lectured by Dr. V.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.
OS Spring’04 Introduction Operating Systems Spring 2004.
UNIT 2 Memory Management Unit and Segment Description and Paging
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Review of Memory Management, Virtual Memory CS448.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
CS333 Intro to Operating Systems Jonathan Walpole.
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
MICROPROCESSOR INPUT/OUTPUT
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
Chapter 4 Memory Management Virtual Memory.
80386DX.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Segment Descriptor Segments are areas of memory defined by a programmer and can be a code, data or stack segment. In segments need not be all the.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management Chapter 3
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Chapter 2 Memory and process management
16.317: Microprocessor System Design I
CS 6560: Operating Systems Design
COMBINED PAGING AND SEGMENTATION
Microprocessor Systems Design I
Anton Burtsev February, 2017
Day 08 Processes.
Day 09 Processes.
143A: Principles of Operating Systems Lecture 5: Address translation
Chapter 8: Main Memory.
Chapter 9: Virtual-Memory Management
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Lecture 3: Main Memory.
Operating System Chapter 7. Memory Management
Lecture 37 Syed Mansoor Sarwar
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching, example dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital Information Systems

1/1/ / faculty of Electrical Engineering eindhoven university of technology Virtual memory (1) The logically addressable memory size can exceed the physical memory size –Common situation with multiple linear memory spaces No problem if the actually used amount of memory fits in physical memory –Rely on address translation to 'pack' the memory

1/1/ / faculty of Electrical Engineering eindhoven university of technology Virtual memory (2) Memory in use > physical memory: problem –Hold part of used memory in physical memory –Store remainder somewhere else, f.i. on a hard disk Keep this invisible to processor: 'virtual memory' –Hardware stops invalid memory access –Starts routine to move data into physical memory –Then re-tries the failed memory access which may be in the middle of an instruction!

1/1/ / faculty of Electrical Engineering eindhoven university of technology The 'program locality principle' Consecutive accesses are generally not far apart –The 'working set' contains the active memory areas –Run at full speed if these are kept in real memory! last instruction address (x) p (x+1) last stack access (y) p (y+1: POP)(y-1: PUSH) last data access (z) p (z+1: Arrays, Strings) mean stack frame size

1/1/ / faculty of Electrical Engineering eindhoven university of technology Virtual memory hardware support bits These work for pages as well as segments Present bit: in memory if set, otherwise on disk –Processor aborts access if this bit is reset Accessed bit: set on each read or write access –Detect activity for determining the working set Written bit: set on each write access –No need to write back to disk if unchanged

1/1/ / faculty of Electrical Engineering eindhoven university of technology A A A A A The working set - clock algorithm (1) 'swap in' A acces s A A P=1 P=0 'swap out' I need you !

1/1/ / faculty of Electrical Engineering eindhoven university of technology The working set - clock algorithm (2) Swap out writes only if Written bit set Swap in sets Accessed and Present, resets W This algorithm is often used (works very well) –Working set pages/segments set A bit a lot they are not swapped out! –Fair swap out decisions, even under high system load –Will always find something to swap out (robust)

1/1/ / faculty of Electrical Engineering eindhoven university of technology 16 K paged memory, 1 K pages 0 16 The fragmentation problem 16 K segmented memory K 2 K 2.5 K 4 K 1.5 K 4.5 K 3.5 K 1.5 K 3.5 K Unusable space inside pages !! 6 K free, but does not fit !! Memory is fragmented outside segments: external fragmentation Memory is fragmented inside pages: internal fragmentation

1/1/ / faculty of Electrical Engineering eindhoven university of technology Pages versus segments Fixed-size pages ease swapping to/from disk Segments provide more complete protection Intel uses segmenting AND paging –Protection based upon the segments (done first) –Virtual memory based upon paging (done last) –Two translation steps needed The P, A and W bits are offered in hardware, managing virtual memory is done in software!

1/1/ / faculty of Electrical Engineering eindhoven university of technology Switching from user to system mode (1) Generally done with a kind of software 'interrupt' –Hardware interrupt routines run in system mode too –They need the same mode switching logic but interrupts remain enabled here Interrupt routine start addresses in protected table –Not possible to enter system mode at arbitrary address –Called routine is responsible for checking parameters

1/1/ / faculty of Electrical Engineering eindhoven university of technology Switching from user to system mode (2) The number of software interrupts is limited –Signetics and Zilog Z8000: ONE 'service call' Other methods exist for protected switching –DEC Alpha: protected library of subroutines –Intel 80286: pseudo segments called call gates

1/1/ / faculty of Electrical Engineering eindhoven university of technology User applications: PL 3 Intel protection example –Code access:only in same level or higher levels –Data access:only in same level or lower levels –Stack access:only in same level (separate stacks!) Device drivers: PL 2O.S. core: PL 1 Kernel: PL 0 PL: Privilege Level

1/1/ / faculty of Electrical Engineering eindhoven university of technology 16 bits Intel segment selector Global table with 8192 shared segments Task-local table with 8192 private segments 'Requested Privilege Level' allows lowering the protection level of a segment (towards PL 3) 'RPL 2 bits local/global 1 bit segment number 13 bits

1/1/ / faculty of Electrical Engineering eindhoven university of technology 64 bits Intel memory segment descriptor –CODEreadable, 'conforming' (for libraries) –DATAwritable, stack (reverses limit checking) –TASK STATE(registers, 4 stack pointers, active segs.) –LOCAL TABLE(only in global segment table) limit 16 bits base 24 bits Present 1 bit Accessed 1 bit 'PL 2 bits Type & access rights Location Size Virtual memory No Written bit !

1/1/ / faculty of Electrical Engineering eindhoven university of technology Intel calls and jumps Within same segment only needs offset Other segment at same PL needs offset & selector To higher protected code (lower PL) uses 'call gate –These are stored in segment tables (pseudo- segment) –CALL instruction points to this pseudo-segment but the offset in instruction is overruled by call gate –Data copied automatically between stacks 'PL 2 bits Present 1 bit offset 16 bits code segment selector stack copy block size

1/1/ / faculty of Electrical Engineering eindhoven university of technology Intel traps and interrupts Use 256 entry 'interrupt descriptor table –Which contains trap gates and interrupt gates –These are call gates without stack data copying –An interrupt gate disables interrupts automatically 'PL 2 bits Present 1 bit offset 16 bits code segment selector

1/1/ / faculty of Electrical Engineering eindhoven university of technology Intel I/O protection Global 'I/O Privilege Level' indicates the highest PL value at which ANY I/O is allowed –Higher PL level code traps on IN & OUT instructions Each task has a bitmap in the task state segment –Each bit corresponds with an I/O port –Accessing I/O port with bit at 0 generates trap –Size of bitmap variable, undefined ports always trap

1/1/ / faculty of Electrical Engineering eindhoven university of technology Intel multitasking support 'Task state' segments store task information –Special register points to active task state segment Task switch with JUMP through a 'task gate' 'PL 2 bits Present 1 bit task state segment selector 1)Save register set in active task state segment 2)Get address of new task state and declare it active 3)Load register set from this segment, including PC 4)Restart program execution for the new task PL 0 only: kernel !