Presentation is loading. Please wait.

Presentation is loading. Please wait.

CE 454 Computer Architecture

Similar presentations


Presentation on theme: "CE 454 Computer Architecture"— Presentation transcript:

1 CE 454 Computer Architecture
Lecture 12 Ahmed Ezzat The Operating System Machine Level, Ch-(6.1 – 6.3)

2 Outline Introduction Virtual Memory Virtual I/O Instructions
Virtual Instructions for Parallel Processing CE 454 Ahmed Ezzat

3 Introduction OS is a program that adds variety of new instructions and features (system calls) beyond the ISA level OS Machine level includes most ISA instructions + system calls OSM level is always interpretive, i.e., reading data from a file is executed similar to a microprogram carrying out an ADD instruction – step-by-step CE 454 Ahmed Ezzat

4 Virtual Memory Since the IBM compatible PC 286, virtual memory has been used to make believe that memory space is larger than what it is Using the external memory device (as disk) to extend the addressable space Before, programmers tried to shrink programs to fit tiny memories Code and data size is still a constraint in embedded systems though CE 454 Ahmed Ezzat

5 Virtual Memory: Implementations of VM
Distinction between virtual and physical memory Paging The memory space is a large one-dimensional array, which extends to the disk Disk broken up into regular sized pages Pages are brought in memory on demand And written back when needed Segmentation The memory is broken up into variable sized segments We will not consider segmentation in detail CE 454 Ahmed Ezzat

6 Virtual Memory: Memory Issues
Idea: Separate concepts of Addressable space (virtual memory) And memory locations (physical memory) Example: Address Space = 216 = memory cells Memory Size = 4096 memory cells How can we fit the Address Space into Main Memory? CE 454 Ahmed Ezzat

7 Virtual Memory: Paging
Break the addressable space (Virtual space) into Pages Normally Main Memory has thousands of pages page 1 page = 4096 bytes New Issue: How to manage addressing? CE 454 Ahmed Ezzat

8 Virtual Memory: Address Mapping
Mapping Virtual Memory addresses to Main Memory addresses (physical addresses) page 1 page = 4096 bytes physical address used by hardware virtual address used by program 4095 8191 4096 Physical / Virtual CE 454 Ahmed Ezzat

9 Virtual Memory: Paging
4095 8191 4096 virtual physical Illusion that Main Memory is Large Contiguous Linear Size(MM) = Size(2ndry M) Transparent to Programmer 4095 / 0 page page 4095 / 0 page CE 454 Ahmed Ezzat

10 Virtual Memory: Paging Implementation
Virtual Address Space & Physical Address Space Broken up into equal pages Page size  Always a power of 2 Common Size: 512 to 64K bytes CE 454 Ahmed Ezzat

11 Virtual Memory: Paging Implementation
Page Frames Page Tables Programs use Virtual Addresses CE 454 Ahmed Ezzat

12 Virtual Memory: Virtual and physical Memory
Page Frame: Home of VM pages in MM Page Table: Home of mappings for VM pages CE 454 Ahmed Ezzat

13 Virtual Memory: Memory Mapping
Memory Management Unit (MMU): Device that performs virtual-to-physical mapping 32-bit VM Address MMU 15-bit Physical Address CE 454 Ahmed Ezzat

14 Virtual Memory: Memory Management Unit
32-bit Virtual Address MMU Breaks VA into 2 portions 20-bit bit Virtual page # offset in page How to determine if page is in MM? Present/Absent Bit in Page Table Entry CE 454 Ahmed Ezzat

15 Virtual Memory: Demand Paging and Working Set Model
Page Fault: Requested page is not in MM Demand Paging: Page is demanded by program from disk Page is loaded into MM + initialize a PTE Repeat instruction that caused the page fault Possible Mapping of pages CE 454 Ahmed Ezzat

16 Virtual Memory: Demand Paging and Working Set Model
Most programs do not reference their address space uniformly Instead they tend to cluster on a small number of pages Working set is the set of pages that are used actively and heavily Working set typically varies slowly with time  kept in memory to reduce page faults CE 454 Ahmed Ezzat

17 Virtual Memory: Page Replacement Policy
Replacement: It is necessary to predict which page would have least impact on the running program Common Replacement Schemes: Least Recently Used (LRU) First-In-First-Out (FIFO) CE 454 Ahmed Ezzat

18 Virtual Memory: Page Replacement Policies
Least Recently Used (LRU) Generally works well TROUBLE: When the working set is larger than the Main Memory Working Set = 9 pages Pages are executed in sequence (08 (repeat)) THRASHING CE 454 Ahmed Ezzat

19 Virtual Memory: Page Replacement Policies
First-In-First-Out (FIFO) Removes Least Recently Loaded page Does not depend on Use Determined by number of page faults seen: increment counter on P/F CE 454 Ahmed Ezzat

20 Virtual Memory: Page Replacement Policies
Upon Replacement Need to know whether to write data back Add a Dirty-Bit Dirty Bit = 0; Page is clean; No writing Dirty Bit = 1; Page is dirty; Write back CE 454 Ahmed Ezzat

21 Virtual Memory: Page Size Comments
Smaller page size allows for less wasted space Benefits: Less internal fragmentation Less thrashing: large # of small pages is better than small # of large pages (from a Working Set point of view) Drawbacks: page table storage bandwidth computer cost time to load more time spent at disk miss rate CE 454 Ahmed Ezzat

22 Virtual Memory: Segmentation
Rather than having one virtual address space, having multiple can be better. For example, compiler produces multiple tables: Some grows continuously (e.g., symbol table) Some grow/shrink (e.g., stack) CE 454 Ahmed Ezzat

23 Virtual I/O Instructions
ISA-level and Microinstruction-level instructions are quite different OS Machine-level instruction set includes most of the ISA-level instructions Plus additional important instructions (system calls) Minus few damaging ISA instructions (removed from the ISA-level instructions) As an example, doing I/O at the ISA-level is tedious and complex. No user cares about the low-level details of why an I/O failed for example CE 454 Ahmed Ezzat

24 Virtual I/O Instructions: Files
File is an abstraction for presenting virtual I/O Simple form of a file: a sequence of bytes on an I/O device. If the device is disk, data can be read back. If the device is a printer, data can’t be read back In the above abstraction, any further structure to the file abstraction is left up to the application Mainframe file abstraction is more sophisticated: sequence of logical records each with a well defined structure CE 454 Ahmed Ezzat

25 Virtual I/O Instructions: Implementation Issues
Storage allocation: can be a disk sector, but often a block of consecutive sectors? Is file stored on disk as consecutive blocks or not? Programmer view the file as a linear sequence of bytes. The OS view the file as an ordered, not necessarily consecutive, collection of blocks on disk CE 454 Ahmed Ezzat

26 Virtual I/O Instructions: Implementation Issues
OS needs to keep track of which blocks are available on disk? CE 454 Ahmed Ezzat

27 Virtual Instructions for Parallel Processing
Parallel processing can be done by: Write the application as a set of cooperating processes running in parallel on different CPUs Write the application as a set of processes/threads running on the same CPU In both cases, certain virtual instructions are needed to synchronize among these processes/threads. One such mechanism is semaphores CE 454 Ahmed Ezzat

28 END CE 454 Ahmed Ezzat


Download ppt "CE 454 Computer Architecture"

Similar presentations


Ads by Google