1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Memory management (hệ điều HÀNH NÂNG CAO SLIDE)

70 69 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • PowerPoint Presentation

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

  • Slide 21

  • Slide 22

  • Slide 23

  • Slide 24

  • Slide 25

  • Slide 26

  • Slide 27

  • Slide 28

  • Slide 29

  • Slide 30

  • Slide 31

  • Slide 32

  • Slide 33

  • Slide 34

  • Slide 35

  • Slide 36

  • Slide 37

  • Slide 38

  • Slide 39

  • Slide 40

  • Slide 41

  • Slide 42

  • Slide 43

  • Slide 44

  • Slide 45

  • Slide 46

  • Slide 47

  • Slide 48

  • Slide 49

  • Slide 50

  • Slide 51

  • Slide 52

  • Slide 53

  • Slide 54

  • Slide 55

  • Slide 56

  • Slide 57

  • Slide 58

  • Slide 59

  • Slide 60

  • Slide 61

  • Slide 62

  • Slide 63

  • Slide 64

  • Slide 65

  • Slide 66

  • Slide 67

  • Slide 68

  • Slide 69

  • Slide 70

Nội dung

Chapter Memory Management • • • The main purpose of a computer system is to execute programs These programs, together with the data they access, must be in main memory (at least partially) during execution Many memory-management schemes exist, reflecting various approaches, and the effectiveness of each algorithm depends on the situation Selection of a memory-management scheme for a system depends on many factors, especially on the hardware design of the system • OBJECTIVES – To provide a detailed description of various ways of organizing memory hardware – To discuss various memory-management techniques, including paging and segmentation Main Memory 1.1.Background 1.1.1 Basic hardware • Main memory and the registers built into the processor itself are the only storage that the CPU can access directly • There are machine instructions that take memory addresses as arguments, but none that take disk addresses • Registers that are built into the CPU are generally accessible within one cycle of the CPU clock • Most CPUs can decode instructions and perform simple operations on register contents at the rate of one or more operations per clock tick • Memory access may take many cycles of the CPU clock to complete, in which case the processor normally needs to stall, since it does not have the data required to complete the instruction that it is executing • The remedy is to add fast memory between the CPU and main memory-A memory buffer used to accommodate a speed differential, called a cache • Each process has a separate memory space and to ensure that the process can access only these legal addresses • This protection by using two registers, usually a base and a limit Figure 2.1 A base and a limit register define a logical address space 1.1.2 Address Binding • Addresses in the source program are generally symbolic (such as count) A compiler will typically bind these symbolic addresses to relocatable addresses (such as “14 bytes from the beginning of this module'') • The linkage editor or loader will in turn bind the relocatable addresses to absolute addresses (such as 74014) • Classically, the binding of instructions and data to memory addresses can be done at any step along the way: Figure 2.2 Multistep processing of a user program – Compile time If you know at compile time where the process will reside in memory, then absolute code can be generated • For example, if you know that a user process will reside starting at location R, then the generated compiler code will start at that location and extend up from there • If, at some later time, the starting location changes, then it will be necessary to recompile this code • The MS-DOS COM-format programs are bound at compile time – Load time If it is not known at compile time where the process will reside in memory, then the compiler must generate relocatable code • In this case, final binding is delayed until load time • If the starting address changes, we need only reload the user code to incorporate this changed value (do not need to recompile this code) – Execution time If the process can be moved during its execution from one memory segment to another, then binding must be delayed until run time Special hardware must be available for this scheme to work-MMU (memory management unit) 1.1.3 Logical Versus Physical Address Space • Logical address-virtual address: An address generated by the CPU • The set of all logical addresses generated by a program is a logical address space • Physical address: An address seen by the memory unit • The set of all physical addresses corresponding to these logical addresses is a physical address space • The run-time mapping from virtual to physical addresses is done by a hardware device called the memory-management unit (MMU) • For simplicity of implementation, segments are numbered and are referred to by a segment number, rather than by a segment name Thus, a logical address consists of a two tuple: < segment-number, offset > • Normally, the user program is compiled, and the compiler automatically constructs segments reflecting the input program 1.6.2 Hardware • Although the user can now refer to objects in the program by a two-dimensional address, the actual physical memory is still, of course, a onedimensional sequence of bytes Thus, OS must define an implementation to map two dimensional user-defined addresses into onedimensional physical addresses • This mapping is effected by a segment table Each entry in the segment table has a segment base and a segment limit The segment base contains the starting physical address where the segment resides in memory, whereas the segment limit specifies the length of the segment Figure 2.16 Segmentation hardware • Example of Segmentation Example: Cho biết không gian địa logic có 16 trang (Page) trang có 512 từ nhớ (byte) ánh xạ vào nhớ vật lý 128 khung trang (Frame) a Địa luận lý có 13 bit địa vật lý có 16 bit b Địa luận lý có 16 bit địa vật lý có 13 bit c Địa luận lý có bit địa vật lý có bit d Tất a, b, c sai Cho biết khơng gian địa logic có trang (Page) trang có 2048 từ nhớ (byte) ánh xạ vào nhớ vật lý 32 khung trang (Frame) a Địa luận lý có 11 bit địa vật lý có bit b Địa luận lý có 14 bit địa vật lý có 16 bit c Địa luận lý có 19 bit địa vật lý có bit d Địa luận lý có 11 bit địa lý có 16 bit Virtual Memory (Reference) 2.1 Background 2.2 Demand Paging 2.3 Copy-on-Write 2.4 Page Replacement 2.5 Allocation of Frames 2.6 Thrash 2.7 Memory mapped Files 2.8 Allocating Kernel Memory 2.9 Other Considerations 2.1 Background • Virtual memory–separation of user logical memory from physical memory –Only part of the program needs to be in memory for execution –Logical address space can therefore be much larger than physicaladdress space –Allows address spaces to be shared by several processes –Allows for more efficient process creation • Virtual memory can be implemented via: –Demand paging –Demand segmentation 2.2 Demand Paging Figure 2.1 Transfer of a paged memory to contiguous disk space 2.3 Copy-on-Write • Copy-on-Write (COW) allows both parent and child processes to initially sharethe same pages in memory • COW allows more efficient process creation as only modified pages are copied • Free pages are allocated from a pool of zeroedout pages 2.4 Page Replacement Figure 2.2 Page replacement 2.5 Allocation of Frames • Each process needs minimumnumber of pages • Example: IBM 370 –6 pages to handle SS MOVE instruction: –instruction is bytes, might span pages –pages to handle from –2 pages to handle to • Two major allocation schemes –fixed allocation –priority allocation 2.6 Thrash • Thrashing-a process is busy swapping pages in and out Figure 2.3 Thrashing 2.7 Memory mapped Files Figure 2.4 Memory-mapped files 2.8 Allocating Kernel Memory • Treated differently from user memory • Often allocated from a free-memory pool – Kernel requests memory for structures of varying sizes – Some kernel memory needs to be contiguous 2.9 Other Considerations Reference: Silberschatz-Galvin-Gagne, Operating System Concepts, USA, 2005.(http://www.osbook.com) ... ways of organizing memory hardware – To discuss various memory- management techniques, including paging and segmentation 1 Main Memory 1.1.Background 1.1.1 Basic hardware • Main memory and the registers... The remedy is to add fast memory between the CPU and main memory- A memory buffer used to accommodate a speed differential, called a cache • Each process has a separate memory space and to ensure... the memory requirements of each process and the amount of available memory space in determining which processes are allocated memory – When a process is allocated space, it is loaded into memory,

Ngày đăng: 29/03/2021, 08:40

TỪ KHÓA LIÊN QUAN