Lecture 7. Memory Management

Size: px
Start display at page:

Download "Lecture 7. Memory Management"

Transcription

1 Lecture 7 Memory Management 1

2 Lecture Contents 1. Memory Management Requirements 2. Memory Partitioning 3. Paging 4. Segmentation 2

3 Memory Memory is an array of words or bytes, each with its own address. Main memory and the registers built into the processor itself are the only storage that the CPU can access directly. 3

4 1. Memory Management Requirements Five requirements of memory management are 1. Relocation 2. Protection 3. Sharing 4. Logical organisation 5. Physical organisation 4

5 1. Relocation In a multiprogramming system, the available main memory is generally shared among a number of processes. The programmer does not know where the program will be placed in memory when it is executed. - It may be swapped to disk and return to main memory at a different location (relocated). Memory references in program code must be translated to the actual physical memory address 5

6 Memory Management Terms 6

7 Addressing 7

8 2. Protection We need to make sure that each process has a separate memory space. Processes should not be able to reference memory locations in another process for reading or writing purposes without permission It is impossible to check absolute addresses at compile time to assure protection because location of a program in main memory is unpredictable 8

9 2. Protection Hence all memory references generated by a process must be checked at run time (i.e., at the time of execution) to ensure that they refer only to memory space allocated to that process Note that the memory protection requirement must be satisfied by the processor (hardware) rather than the operating system (software) because the OS cannot anticipate all of the memory references that a program will make. 9

10 2. Protection We can provide protection by using two registers: - base register: specifies starting address - limit register: specifies the memory size. 10

11 3. Sharing Any protection mechanism must have the flexibility to allow several processes to access the same portion of main memory Processes that are cooperating on some task may need to share access to the same data structure The memory management system must therefore allow controlled access to shared areas of memory without compromising essential protection 11

12 4. Logical Organization Main memory is organized as a linear (or onedimensional) address space consisting of a sequence of bytes or words Most programs are organized into modules Advantages of modularization - Modules can be written and compiled independently, with all references from one module to another resolved by the system at run time 12

13 4. Logical Organization - Different degrees of protection (e.g., read-only, execute-only, read-write) can be given to different modules. - Modules can be shared among processes 13

14 5. Physical Organization Cannot leave the programmer with the responsibility to manage memory The main memory available for a program plus its data may be insufficient - Overlaying allows various modules to be assigned the same region of memory but overlaying is time-consuming to program A programmer does not know at the time of coding how much space will be available or where that space will be 14

15 Lecture Contents 1. Memory Management Requirements 2. Memory Partitioning 3. Paging 4. Segmentation 15

16 Memory Management Techniques Six memory management techniques are 1. Fixed Partitioning 2. Dynamic Partitioning 3. Simple (or pure) Paging 4. Simple (or pure) Segmentation 5. Virtual Memory Paging 6. Virtual Memory Segmentation 16

17 2. Memory Partitioning 17

18 1. Fixed-Partitioning Scheme Equal-size partitions - Any process whose size is less than or equal to the partition size can be loaded into an available partition 18

19 Equal-size Partitions 19

20 Two Problems of Equal-size Partitions A program may too big to fit into a partition. - The programmer must design the program with the use of overlays so that only a portion of the program needs be in main memory at any one time Main memory utilization is extremely inefficient - Any program, no matter how small, occupies an entire partition. This results in internal fragmentation (i.e., unused memory internal to a partition) 20

21 1. Fixed-Partitioning Scheme Unequal-size partitions - Lessens both problems (i.e., program too big or small) - but doesn t solve the problems completely 21

22 Unequal-size Partitions In this figure, - Programs up to 16 Mbytes can be accommodated without overlay - Smaller programs can be placed in smaller partitions, reducing internal fragmentation (i.e., wasted memory internal to a partition). 22

23 Q&A Q: In a fixed-partitioning scheme, what are the advantages of using unequal-size partitions? A: The advantages of using unequal-size fixed partitions are 1. It is possible to provide one or two quite large partitions and still have a large number of partitions. The large partitions can allow the entire loading of large programs. 2. Internal fragmentation is reduced because a small program can be put into a small partition. 23

24 Placement Algorithm For equal-size partitions - Placement of processes in memory is trivial (no options) For unequal-size partitions - can assign each process to the smallest partition within which it will fit - advantage of this approach is that processes are always assigned in such a way as to minimize internal fragmentation (i.e., wasted memory within a partition). 24

25 Remaining Problems with Fixed Partitions The number of active processes is limited by the system (i.e., limited by the pre-determined number of partitions) Small processes will not use the partition space efficiently (i.e., internal fragmentation still exists) The use of fixed partitioning is almost unknown today 25

26 2. Dynamic Partitioning (DP) With dynamic partitioning, the partitions are of variable length and number When a process is brought into main memory, it is allocated exactly as much memory as it requires and no more 26

27 Dynamic Partitioning Example OS (8M) P2 (14M) P1 (20M) Empty (6M) Empty P4(8M) P2 (56M) (14M) Empty (6M) P3 (18M) Empty (4M) Refer to Figure

28 2. Dynamic Partitioning (DP) DP starts out well, but eventually it leads to a situation in which there are a lot of small discontiguous holes in memory. As time goes on, memory becomes more and more fragmented, and memory utilization declines. This phenomenon is referred to as external fragmentation (i.e., wasted memory external to all partitions). That is, there is enough total memory space to satisfy a request but the available spaces are not contiguous. Refer to Figure

29 2. Dynamic Partitioning (DP) External fragmentation can be resolved using compaction (e.g., defragmenter). - From time to time, OS moves processes so that they are contiguous and so that all of free memory is together in one block - Compaction is a time consuming procedure and wasteful of processor time Refer to Figure

30 Q&A Q: What is the difference between internal and external fragmentation? A: - Internal fragmentation is a phenomenon associated with fixed partitioning. Internal fragmentation refers to the wasted/unused space/memory internal to a partition (i.e., wasted memory within a partition) due to the fact that the block of data loaded is smaller than the partition. 30

31 Q&A - External fragmentation is a phenomenon associated with dynamic partitioning. External fragmentation refers to the fact that many small discontiguous areas of main memory external to any partition are wasted (i.e., wasted spaces external to all partitions, or wasted memory outside all partitions). That is, there is enough total memory space to satisfy a request but the available spaces are not contiguous. 31

32 Placement Algorithm When it is time to load or swap a process into main memory, and if there is more than one free block of memory of sufficient size, then OS must decide which free block to allocate to the process Placement algorithms are best-fit, worst-fit, nextfit, and first-fit. 32

33 Placement Algorithm Best-fit placement algorithm - searches entire list and chooses the block that is closest in size to the request - is usually the worst performer because leftover hole is small - since smallest block is found for process, main memory is quickly segmented by blocks too small to satisfy memory allocation requests - memory compaction must be done more frequently than with the other algorithms 33

34 Placement Algorithm Worst-fit placement algorithm - Searches entire list and chooses the block that is largest in size to the request - produces largest leftover hole, which may be more useful than smaller leftover hole created by best-fit approach. 34

35 Placement Algorithm Next-fit placement algorithm - scans memory from the location of the last placement, and chooses the next available block that is large enough - tends to produce slightly worse results than the first-fit replacement algorithm - will more frequently lead to an allocation from a free block at the end of memory 35

36 Placement Algorithm Next-fit placement algorithm - largest block of free memory, which usually appears at the end of the memory space, is quickly broken up into small fragments - compaction may be required more frequently with next-fit 36

37 Placement Algorithm First-fit placement algorithm - scans memory from the beginning and chooses the first available block that is large enough - is not only the simplest but usually the best and fastest as well 37

38 Placement Algorithm? 19 M 19 M Next fit Worst fit 38

39 Buddy System Both fixed and dynamic partitioning schemes have drawbacks. - fixed partitioning scheme limits the number of active processes and may use space inefficiently if there is a poor match between available partition sizes and process sizes. - dynamic partitioning scheme is more complex to maintain and includes overhead of compaction. An interesting compromise is buddy system 39

40 Buddy System Entire space available for allocation is treated as a single block of size 2 n (e.g., n = 10, 2 n = 1024) If a request of size m, where 2 n-1 < m 2 n, is made, then entire block is allocated Otherwise, block is split into two equal buddies - Process continues until smallest block greater than or equal to m is generated 40

41 Example of Buddy System 41

42 Tree Representation of Buddy System B = 42

43 Buddy System Buddy system is a reasonable compromise to overcome the disadvantages of both the fixed and variable partitioning schemes In contemporary OSs, virtual memory based on paging and segmentation is superior. 43

44 Buddy System Buddy system has found application in parallel systems as an efficient means of allocation and release for parallel programs. A modified form of the buddy system is used for UNIX kernel memory allocation 44

45 Relocation When program is loaded into memory, the actual (or absolute) memory locations are determined A process may occupy different partitions which means different absolute memory locations during execution. This is due to - swapping out and in (by swapper - swaps entire process, not pager - swap a page) - compaction 45

46 Types of Addresses Logical address (virtual address): is a reference to a memory location independent of the current assignment of data to memory - A translation from a logical address to a physical address must be made before the memory access can be achieved. - Logical address is generated by CPU. 46

47 Types of Addresses Physical address (or absolute address): is an actual location in main memory. - Physical address is managed by memorymanagement unit (MMU) Relative address: is expressed as a location relative to some known point, usually a value in a processor register. 47

48 Types of Addresses Base register is also called relocation register. 48

49 Address Translation > 49

50 Address Translation Base register indicates starting address in main memory of the program Bounds register indicates ending address in main memory of the program Value in base register is added to relative address to produce absolute address. Resulting address is compared to value in bounds register. If the address is within bounds, then instruction execution may proceed. Otherwise, an interrupt is generated to OS for error processing 50

51 Lecture Contents 1. Memory Management Requirements 2. Memory Partitioning 3. Paging 4. Segmentation 51

52 3. Paging Main memory is divided into equal, fixed-size blocks. Each block is called a frame. Each program stored on disk is divided into equal, fixed-size blocks. Each block is called a page. Page size equals frame size. In paging scheme, wasted space in memory for each process is due to internal fragmentation consisting of only a fraction of the last page of a process. There is no external fragmentation. 52

53 3. Paging 53

54 3. Paging Traditionally, support for paging has been handled by hardware. However, recent designs have implemented paging by closely integrating the hardware and operating system, especially on 64- bit microprocessors. OS maintains a page table for each process. Page table contains the frame location for each page in the process. That is, the page table contains the base address of each page in physical memory 54

55 3. Paging A logical address (generated by CPU) is a reference to a memory location independent of the current assignment of data to memory. - A translation to a physical address must be made before the memory access can be achieved. - Logical address consists of a page number p and page offset within the page d (page#, offset) = (p, d). 55

56 3. Paging A physical address (or absolute address - managed by MMU) is an actual location in main memory. Physical address consists of a frame number f and frame offset d within the frame (frame#, offset) = (f, d). A relative address is a particular example of logical address. That is, it is the (n + m)-bit decimal equivalent of p 2 d 2 or s 2 d 2. 56

57 Paging Hardware. 57

58 Page Table 58

59 Assignment of Processes and Free Frames A.0 A.1 A.2 A.3 D.0 B.0 D.1 B.1 D.2 B.2 C.0 C.1 C.2 C.3 D.3 D.4 59

60 3. Paging Paging is similar to fixed partitioning. The differences are - partitions are rather small - a program may occupy more than one partition - and these partitions need not be contiguous 60

61 16-bit Logical and Relative Addresses Page size is 1K (byte) = 2 10 = 1024 bytes So m = 10 bits are needed for offset and n = 6 bits are needed for page number 61

62 Logical-to-Physical Translation in Paging frame 6 = = 62

63 Logical-to-Physical Translation in Paging Consider an address of n + m bits, where leftmost n bits are page number, rightmost m bits are offset. In our example, n = 6 and m =

64 Logical-to-Physical Translation in Paging The following steps are needed for address translation: - Extract the page number as the leftmost n bits of the logical address. - Use the page number as an index into the process page table to find the frame number k. 64

65 Logical-to-Physical Translation in Paging - The starting physical address of the frame is k 2 m, and the physical address of the referenced byte is that number plus the offset. This physical address needs not be calculated; it is easily constructed by appending the offset to the frame number. Example: logical address = , frame number k = 6 = physical address = = = 6622 =

66 Lecture Contents 1. Memory Management Requirements 2. Memory Partitioning 3. Paging 4. Segmentation 66

67 4. Segmentation A program can be divided into segments - Segments may vary in length - There is a maximum segment length (2 m ) Logical address consist of two parts: a segment number s and segment offset d (i.e., offset within the segment) (segment#, offset) = (s, d). 67

68 4. Segmentation Segmentation is similar to dynamic partitioning The difference is that with segmentation a program may occupy more than one partition, and these partitions need not be contiguous Segmentation eliminates internal fragmentation but, like dynamic partitioning, it suffers from external fragmentation. However, because a process is broken up into a number of smaller pieces, the external fragmentation should be less 68

69 4. Segmentation 69

70 Segmentation 70

71 Segmentation = Relative address: maximum segment size is 2 12 = 4096 bytes. Thus, m = 12 bits, n = 4 bits 1950 >

72 Logical-to-Physical Translation in Segmentation Consider an address of n + m bits, where leftmost n bits are segment number and rightmost m bits are the offset. In our example, n = 4 and m = 12. Thus the maximum segment size is 2 12 = The following steps are needed for address translation: - Extract segment number as leftmost n bits of logical address (e.g., ). 72

73 Logical-to-Physical Translation in Segmentation - Use segment number as an index into process segment table to find starting physical address of the segment (i.e., the value of base). - Compare the offset, expressed in rightmost m bits, to the length of the segment. If offset is greater than or equal to the segment length, the address is invalid. - Desired physical address is sum of starting physical address of the segment and the offset. 73

74 Summary One of the most important and complex tasks of OS is memory management. Main memory is a resource to be allocated to and shared among a number of active processes. To use processor and I/O facilities efficiently, it is desirable to maintain as many processes in main memory as possible. It is desirable to free programmers from memory restrictions in program development. 74

75 Summary The basic tools of memory management are paging and segmentation. - With paging, each process is divided into relatively small, fixed-size pages. - Segmentation provides for the use of pieces of varying size. It is also possible to combine paging and segmentation in a single memory management scheme. 75

76 Review Questions Q. What are the differences among a frame, a page, and a segment? A. In a paging system, main memory is divided into equal, fixed-size blocks. Each block is called a frame. 76

77 Review Questions In a paging system, a program stored on disk is divided into equal, fixed-size blocks. Each block is called a page. The sizes of a page and a frame are equal. Thus, one page can be loaded into one frame exactly. 77

78 Review Questions In a segmentation system, a program stored on disk is divided into variable-size blocks. Each block is called a segment. Although there is a maximum segment length, it is not required that all segments of all programs be of the same length. 78

79 chmod Command Assume that the access permissions of the file hello.exe are -rw How to set permissions r (read), w (write), and x (execute) on the file hello.exe for a user - chmod u=rwx hello.exe - chmod u+x hello.exe - chmod 700 hello.exe 79

80 chmod Command 80

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Chapter 7 1 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible 2 1 Memory

More information

Memory Management. Memory Management Requirements

Memory Management. Memory Management Requirements Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time 1 Memory Management

More information

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles Chapter 7 Memory Management Ninth Edition William Stallings Frame Page Segment A fixed-length block of main memory. A fixed-length block of data that

More information

Memory Management william stallings, maurizio pizzonia - sistemi operativi

Memory Management william stallings, maurizio pizzonia - sistemi operativi Memory Management 1 summary goals and requirements techniques that do not involve virtual memory 2 memory management tracking used and free memory primitives allocation of a certain amount of memory de-allocation

More information

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358 Memory Management Reading: Silberschatz chapter 9 Reading: Stallings chapter 7 1 Outline Background Issues in Memory Management Logical Vs Physical address, MMU Dynamic Loading Memory Partitioning Placement

More information

Requirements, Partitioning, paging, and segmentation

Requirements, Partitioning, paging, and segmentation Requirements, Partitioning, paging, and segmentation Main Memory: The Big Picture kernel memory proc struct kernel stack/u area Stack kernel stack/u area Stack kernel stack/u area Stack Data Text (shared)

More information

Requirements, Partitioning, paging, and segmentation

Requirements, Partitioning, paging, and segmentation Requirements, Partitioning, paging, and segmentation Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory

More information

3. Memory Management

3. Memory Management Principles of Operating Systems CS 446/646 3. Memory Management René Doursat Department of Computer Science & Engineering University of Nevada, Reno Spring 2006 Principles of Operating Systems CS 446/646

More information

General Objective:To understand the basic memory management of operating system. Specific Objectives: At the end of the unit you should be able to:

General Objective:To understand the basic memory management of operating system. Specific Objectives: At the end of the unit you should be able to: F2007/Unit6/1 UNIT 6 OBJECTIVES General Objective:To understand the basic memory management of operating system Specific Objectives: At the end of the unit you should be able to: define the memory management

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Most demanding di aspect of an operating system Cost has dropped. Consequently size of main memory has expanded enormously. Can we say that we have enough still. Swapping in/out. Memory

More information

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings Memory Management Requirements Memory management is intended to satisfy the following requirements:

More information

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses. 1 Memory Management Address Binding The normal procedures is to select one of the processes in the input queue and to load that process into memory. As the process executed, it accesses instructions and

More information

UNIT III MEMORY MANAGEMENT

UNIT III MEMORY MANAGEMENT UNIT III MEMORY MANAGEMENT TOPICS TO BE COVERED 3.1 Memory management 3.2 Contiguous allocation i Partitioned memory allocation ii Fixed & variable partitioning iii Swapping iv Relocation v Protection

More information

Main Memory (Part I)

Main Memory (Part I) Main Memory (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Main Memory 1393/8/5 1 / 47 Motivation and Background Amir

More information

The Memory Management Unit. Operating Systems. Autumn CS4023

The Memory Management Unit. Operating Systems. Autumn CS4023 Operating Systems Autumn 2017-2018 Outline The Memory Management Unit 1 The Memory Management Unit Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate

More information

12: Memory Management

12: Memory Management 12: Memory Management Mark Handley Address Binding Program goes through multiple steps from compilation to execution. At some stage, addresses in the program must be bound to physical memory addresses:

More information

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1 Chapter 9: Memory Management Background Swapping Contiguous Memory Allocation Segmentation

More information

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure. File Systems I/O Management Hard Drive Management Virtual Memory Swap Memory Management Storage and I/O Introduction CSI3131 Topics Process Management Computing Systems Memory CPU Peripherals Processes

More information

Operating Systems Unit 6. Memory Management

Operating Systems Unit 6. Memory Management Unit 6 Memory Management Structure 6.1 Introduction Objectives 6.2 Logical versus Physical Address Space 6.3 Swapping 6.4 Contiguous Allocation Single partition Allocation Multiple Partition Allocation

More information

CS399 New Beginnings. Jonathan Walpole

CS399 New Beginnings. Jonathan Walpole CS399 New Beginnings Jonathan Walpole Memory Management Memory Management Memory a linear array of bytes - Holds O.S. and programs (processes) - Each cell (byte) is named by a unique memory address Recall,

More information

Last class: Today: Deadlocks. Memory Management

Last class: Today: Deadlocks. Memory Management Last class: Deadlocks Today: Memory Management CPU il1 L2 Memory Bus (e.g. PC133) Main Memory dl1 On-chip I/O Bus (e.g. PCI) Disk Ctrller Net. Int. Ctrller Network Binding of Programs to Addresses Address

More information

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France

Operating Systems Memory Management. Mathieu Delalandre University of Tours, Tours city, France Operating Systems Memory Management Mathieu Delalandre University of Tours, Tours city, France mathieu.delalandre@univ-tours.fr 1 Operating Systems Memory Management 1. Introduction 2. Contiguous memory

More information

Memory Management (1) Memory Management

Memory Management (1) Memory Management EECS 3221 Operating System Fundamentals No.8 Memory Management (1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Memory Management A program usually resides on a

More information

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Memory Management (1) Memory Management. CPU vs. memory. No.8. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University EECS 3221 Operating System Fundamentals No.8 Memory Management (1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Memory Management A program usually resides on a

More information

MEMORY MANAGEMENT/1 CS 409, FALL 2013

MEMORY MANAGEMENT/1 CS 409, FALL 2013 MEMORY MANAGEMENT Requirements: Relocation (to different memory areas) Protection (run time, usually implemented together with relocation) Sharing (and also protection) Logical organization Physical organization

More information

Background. Contiguous Memory Allocation

Background. Contiguous Memory Allocation Operating System Lecture 8 2017.5.9 Chapter 8 (Main Memory) Background Swapping Contiguous Memory Allocation Segmentation - Paging Memory Management Selection of a memory-management method for a specific

More information

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2

6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 6 - Main Memory EECE 315 (101) ECE UBC 2013 W2 Acknowledgement: This set of slides is partly based on the PPTs provided by the Wiley s companion website (including textbook images, when not explicitly

More information

Paging, and segmentation

Paging, and segmentation Paging, and segmentation Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory as possible 2 Big Picture

More information

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging

Chapter 8: Memory Management. Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Memory management is crucial in better utilizing one of the most important

More information

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management Chapter 9 Real Memory Organization and Management Outline 9.1 Introduction 9.2 Memory Organization 9.3 Memory Management 9.4 Memory Hierarchy 9.5 Memory Management Strategies 9.6 Contiguous vs. Noncontiguous

More information

Chapter 9 Real Memory Organization and Management

Chapter 9 Real Memory Organization and Management Chapter 9 Real Memory Organization and Management Outline 9.1 Introduction 9.2 Memory Organization 9.3 Memory Management 9.4 Memory Hierarchy 9.5 Memory Management Strategies 9.6 Contiguous vs. Noncontiguous

More information

CS420: Operating Systems

CS420: Operating Systems Main Memory James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background Program must

More information

Chapters 9 & 10: Memory Management and Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory Chapters 9 & 10: Memory Management and Virtual Memory Important concepts (for final, projects, papers) addressing: physical/absolute, logical/relative/virtual overlays swapping and paging memory protection

More information

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition Chapter 8: Memory Management 8.1 Silberschatz, Galvin and Gagne 2009 Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are

More information

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science

Memory Management. CSCI 315 Operating Systems Design Department of Computer Science Memory Management CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture are based on those from Operating Systems Concepts, 9th ed., by Silberschatz, Galvin,

More information

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1 Main Memory Electrical and Computer Engineering Stephen Kim (dskim@iupui.edu) ECE/IUPUI RTOS & APPS 1 Main Memory Background Swapping Contiguous allocation Paging Segmentation Segmentation with paging

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Silberschatz, Galvin and Gagne 2005 Background Program/Code

More information

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University CSC 4103 - Operating Systems Spring 2007 Lecture - XII Main Memory - II Tevfik Koşar Louisiana State University March 8 th, 2007 1 Roadmap Dynamic Loading & Linking Contiguous Memory Allocation Fragmentation

More information

Process. Memory Management

Process. Memory Management Process Memory Management One or more threads of execution Resources required for execution Memory (RAM) Program code ( text ) Data (initialised, uninitialised, stack) Buffers held in the kernel on behalf

More information

Operating systems. Part 1. Module 11 Main memory introduction. Tami Sorgente 1

Operating systems. Part 1. Module 11 Main memory introduction. Tami Sorgente 1 Operating systems Module 11 Main memory introduction Part 1 Tami Sorgente 1 MODULE 11 MAIN MEMORY INTRODUCTION Background Swapping Contiguous Memory Allocation Noncontiguous Memory Allocation o Segmentation

More information

Operating Systems (2INC0) 2017/18

Operating Systems (2INC0) 2017/18 Operating Systems (2INC0) 2017/18 Memory Management (09) Dr. Courtesy of Dr. I. Radovanovic, Dr. R. Mak (figures from Bic & Shaw) System Architecture and Networking Group Agenda Reminder: OS & resources

More information

Preview. Memory Management

Preview. Memory Management Preview Memory Management With Mono-Process With Multi-Processes Multi-process with Fixed Partitions Modeling Multiprogramming Swapping Memory Management with Bitmaps Memory Management with Free-List Virtual

More information

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others Memory Management 1 Process One or more threads of execution Resources required for execution Memory (RAM) Program code ( text ) Data (initialised, uninitialised, stack) Buffers held in the kernel on behalf

More information

Chapter 9: Memory Management. Background

Chapter 9: Memory Management. Background 1 Chapter 9: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory and placed within a process for

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 L17 Main Memory Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Was Great Dijkstra a magician?

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 8: Memory Management Background" Swapping " Contiguous Memory Allocation" Paging" Structure

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.1 Background Program must be brought into memory

More information

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation

Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Basic Hardware Address Binding Logical VS Physical Address Space Dynamic Loading Dynamic Linking and Shared

More information

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others Memory Management 1 Learning Outcomes Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

More information

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management

8.1 Background. Part Four - Memory Management. Chapter 8: Memory-Management Management Strategies. Chapter 8: Memory Management Part Four - Memory Management 8.1 Background Chapter 8: Memory-Management Management Strategies Program must be brought into memory and placed within a process for it to be run Input queue collection of

More information

Part Three - Memory Management. Chapter 8: Memory-Management Strategies

Part Three - Memory Management. Chapter 8: Memory-Management Strategies Part Three - Memory Management Chapter 8: Memory-Management Strategies Chapter 8: Memory-Management Strategies 8.1 Background 8.2 Swapping 8.3 Contiguous Memory Allocation 8.4 Segmentation 8.5 Paging 8.6

More information

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory

Module 9: Memory Management. Background. Binding of Instructions and Data to Memory Module 9: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 9.1 Background Program must be brought into memory

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium 8.2 Silberschatz, Galvin

More information

Part-A QUESTION BANK UNIT-III 1. Define Dynamic Loading. To obtain better memory-space utilization dynamic loading is used. With dynamic loading, a routine is not loaded until it is called. All routines

More information

UNIT 1 MEMORY MANAGEMENT

UNIT 1 MEMORY MANAGEMENT UNIT 1 MEMORY MANAGEMENT Structure Page Nos. 1.0 Introduction 5 1.1 Objectives 6 1.2 Overlays and Swapping 6 1.3 Logical and Physical Address Space 8 1.4 Single Process Monitor 9 1.5 Contiguous Allocation

More information

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University

Main Memory. CISC3595, Spring 2015 X. Zhang Fordham University Main Memory CISC3595, Spring 2015 X. Zhang Fordham University 1 Memory Management! Background!! Contiguous Memory Allocation!! Paging!! Structure of the Page Table!! Segmentation!! Example: The Intel Pentium

More information

MEMORY MANAGEMENT. Jo, Heeseung

MEMORY MANAGEMENT. Jo, Heeseung MEMORY MANAGEMENT Jo, Heeseung TODAY'S TOPICS Why is memory management difficult? Old memory management techniques: Fixed partitions Variable partitions Swapping Introduction to virtual memory 2 MEMORY

More information

Memory Management. Jo, Heeseung

Memory Management. Jo, Heeseung Memory Management Jo, Heeseung Today's Topics Why is memory management difficult? Old memory management techniques: Fixed partitions Variable partitions Swapping Introduction to virtual memory 2 Memory

More information

Process. One or more threads of execution Resources required for execution

Process. One or more threads of execution Resources required for execution Memory Management 1 Learning Outcomes Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

More information

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [MEMORY MANAGEMENT] Shrideep Pallickara Computer Science Colorado State University L20.1 Frequently asked questions from the previous class survey Virtual addresses L20.2 SLIDES

More information

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit

Performance of Various Levels of Storage. Movement between levels of storage hierarchy can be explicit or implicit Memory Management All data in memory before and after processing All instructions in memory in order to execute Memory management determines what is to be in memory Memory management activities Keeping

More information

Chapter 8: Memory Management Strategies

Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies, Silberschatz, Galvin and Gagne 2009 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

Operating Systems. Memory Management. Lecture 9 Michael O Boyle

Operating Systems. Memory Management. Lecture 9 Michael O Boyle Operating Systems Memory Management Lecture 9 Michael O Boyle 1 Memory Management Background Logical/Virtual Address Space vs Physical Address Space Swapping Contiguous Memory Allocation Segmentation Goals

More information

Chapter 9 Memory Management

Chapter 9 Memory Management Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

CS6401- Operating System UNIT-III STORAGE MANAGEMENT UNIT-III STORAGE MANAGEMENT Memory Management: Background In general, to rum a program, it must be brought into memory. Input queue collection of processes on the disk that are waiting to be brought into

More information

CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

CIS Operating Systems Contiguous Memory Allocation. Professor Qiang Zeng Spring 2018 CIS 3207 - Operating Systems Contiguous Memory Allocation Professor Qiang Zeng Spring 2018 Previous class Uniprocessor policies FCFS, Shortest Job First Round Robin Multilevel Feedback Queue Multiprocessor

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 8: MEMORY MANAGEMENT Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the

More information

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Gordon College Stephen Brinton Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 1 Background Program must be brought into memory

More information

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012 Memory management Knut Omang Ifi/Oracle 1 Oct, 212 (with slides from V. Goebel, C. Griwodz (Ifi/UiO), P. Halvorsen (Ifi/UiO), K. Li (Princeton), A. Tanenbaum (VU Amsterdam), and M. van Steen (VU Amsterdam))

More information

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [MEMORY MANAGEMENT] Shrideep Pallickara Computer Science Colorado State University MS-DOS.COM? How does performing fast

More information

Module 8: Memory Management

Module 8: Memory Management Module 8: Memory Management Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts 8.1 Silberschatz and Galvin

More information

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array

More information

9.1 Background. In Chapter 6, we showed how the CPU can be shared by a set of processes. As a result of

9.1 Background. In Chapter 6, we showed how the CPU can be shared by a set of processes. As a result of Chapter 9 MEMORY MANAGEMENT In Chapter 6, we showed how the CPU can be shared by a set of processes. As a result of CPU scheduling, we can improve both the utilization of the CPU and the speed of the computer's

More information

Chapter 8 Virtual Memory

Chapter 8 Virtual Memory Chapter 8 Virtual Memory Contents Hardware and control structures Operating system software Unix and Solaris memory management Linux memory management Windows 2000 memory management Characteristics of

More information

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition

Chapter 7: Main Memory. Operating System Concepts Essentials 8 th Edition Chapter 7: Main Memory Operating System Concepts Essentials 8 th Edition Silberschatz, Galvin and Gagne 2011 Chapter 7: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure

More information

Memory and multiprogramming

Memory and multiprogramming Memory and multiprogramming COMP342 27 Week 5 Dr Len Hamey Reading TW: Tanenbaum and Woodhull, Operating Systems, Third Edition, chapter 4. References (computer architecture): HP: Hennessy and Patterson

More information

Logical versus Physical Address Space

Logical versus Physical Address Space CHAPTER 8: MEMORY MANAGEMENT Background Logical versus Physical Address Space Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts, Addison-Wesley 1994

More information

Part II: Memory Management. Chapter 7: Physical Memory Chapter 8: Virtual Memory Chapter 9: Sharing Data and Code in Main Memory

Part II: Memory Management. Chapter 7: Physical Memory Chapter 8: Virtual Memory Chapter 9: Sharing Data and Code in Main Memory Part II: Memory Management Chapter 7: Physical Memory Chapter 8: Virtual Memory Chapter 9: Sharing Data and Code in Main Memory 1 7. Physical Memory 7.1 Preparing a Program for Execution Program Transformations

More information

Virtual Memory. Chapter 8

Virtual Memory. Chapter 8 Chapter 8 Virtual Memory What are common with paging and segmentation are that all memory addresses within a process are logical ones that can be dynamically translated into physical addresses at run time.

More information

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1 Basic Memory Management Program must be brought into memory and placed within a process for it to be run Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Mono-programming

More information

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018 Memory: Overview CS439: Principles of Computer Systems February 26, 2018 Where We Are In the Course Just finished: Processes & Threads CPU Scheduling Synchronization Next: Memory Management Virtual Memory

More information

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY

I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY I.-C. Lin, Assistant Professor. Textbook: Operating System Principles 7ed CHAPTER 8: MEMORY MANAGEMENT Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of

More information

Chapter 8: Memory Management

Chapter 8: Memory Management Chapter 8: Memory Management Chapter 8: Memory Management Background Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging 8.2 Background Program must be brought into memory and placed

More information

UNIT-III VIRTUAL MEMORY

UNIT-III VIRTUAL MEMORY MEMORY MANAGEMENT: The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be at least partially in main memory during execution. To improve

More information

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance Administrivia Project discussion? Last time Wrapped up deadlock Today: Start memory management SUNY-BINGHAMTON CS35 SPRING 8 LEC. #13 1 Handling Deadlock Deadlock Prevention Techniques Prevent hold and

More information

Computer Systems II. Memory Management" Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed

Computer Systems II. Memory Management Subdividing memory to accommodate many processes. A program is loaded in main memory to be executed Computer Systems II Memory Management" Memory Management" Subdividing memory to accommodate many processes A program is loaded in main memory to be executed Memory needs to be allocated efficiently to

More information

CS307: Operating Systems

CS307: Operating Systems CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn

More information

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition

Chapter 8: Memory- Management Strategies. Operating System Concepts 9 th Edition Chapter 8: Memory- Management Strategies Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Chapter 8: Memory Management Strategies Background Swapping Contiguous Memory Allocation

More information

Chapter 8: Memory- Management Strategies

Chapter 8: Memory- Management Strategies Chapter 8: Memory Management Strategies Chapter 8: Memory- Management Strategies Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and

More information

a process may be swapped in and out of main memory such that it occupies different regions

a process may be swapped in and out of main memory such that it occupies different regions Virtual Memory Characteristics of Paging and Segmentation A process may be broken up into pieces (pages or segments) that do not need to be located contiguously in main memory Memory references are dynamically

More information

MEMORY MANAGEMENT: Real Storage. Unit IV

MEMORY MANAGEMENT: Real Storage. Unit IV MEMORY MANAGEMENT: Real Storage Unit IV OUTLINE Storage Organization Storage Management Storage Hierarchy Storage Management Strategies Storage Placement Strategies Segmentation Paging & Demand Paging

More information

Q1. What is Deadlock? Explain essential conditions for deadlock to occur?

Q1. What is Deadlock? Explain essential conditions for deadlock to occur? II nd Midterm session 2017-18 Subject: Operating System ( V CSE-B ) Q1. What is Deadlock? Explain essential conditions for deadlock to occur? In a multiprogramming environment, several processes may compete

More information

Goals of Memory Management

Goals of Memory Management Memory Management Goals of Memory Management Allocate available memory efficiently to multiple processes Main functions Allocate memory to processes when needed Keep track of what memory is used and what

More information

Chapter 8: Main Memory

Chapter 8: Main Memory Chapter 8: Main Memory Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Segmentation Paging Structure of the Page Table Example: The Intel 32 and 64-bit Architectures Example:

More information

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization

Memory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical

More information

4.1 Paging suffers from and Segmentation suffers from. Ans

4.1 Paging suffers from and Segmentation suffers from. Ans Worked out Examples 4.1 Paging suffers from and Segmentation suffers from. Ans: Internal Fragmentation, External Fragmentation 4.2 Which of the following is/are fastest memory allocation policy? a. First

More information

Memory Management. Contents: Memory Management. How to generate code? Background

Memory Management. Contents: Memory Management. How to generate code? Background TDIU11 Operating systems Contents: Memory Management Memory Management [SGG7/8/9] Chapter 8 Background Relocation Dynamic loading and linking Swapping Contiguous Allocation Paging Segmentation Copyright

More information

Memory Management. Dr. Yingwu Zhu

Memory Management. Dr. Yingwu Zhu Memory Management Dr. Yingwu Zhu Big picture Main memory is a resource A process/thread is being executing, the instructions & data must be in memory Assumption: Main memory is infinite Allocation of memory

More information