COSC243 Part 2: Operating Systems

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "COSC243 Part 2: Operating Systems"

Transcription

1 COSC243 Part 2: Operating Systems Lecture 20: Main Memory Management Zhiyi Huang Dept. of Computer Science, University of Otago Zhiyi Huang (Otago) COSC243 Lecture 20 1 / 29

2 O/S/ course overview Introduction (1 lecture): Ch1(1-8) Process Management (5 lectures) System Structure and Processes: Ch2(1-9) Threads and data sharing: Ch4(1-4) Scheduling: Ch5(1-3,7) Synchronisation: Ch6(1-7) Deadlocks: Ch7 Storage Management (2 lectures) Main memory: Ch8(1-6) Virtual memory: Ch9(1-7) File System Interface (1 lecture): Ch10(1-5),Ch11(1-4) I/O Management (2 lectures) I/O systems: Ch13(1-4,7) Mass storage: Ch12(1-4) Zhiyi Huang (Otago) COSC243 Lecture 20 2 / 29

3 COSC243 Part II: Storage Management PRIMARY STORAGE: can be referenced directly by CPU must be loaded into memory before being referenced Cache storage Main memory Secondary storage (hard disk) access speed increases access time decreases cost increases capacity decreases Zhiyi Huang (Otago) COSC243 Lecture 20 3 / 29

4 Overview of today s lecture Background: general concepts Getting programs/data into memory Logical and physical es Memory allocation methods Paging Segmentation Zhiyi Huang (Otago) COSC243 Lecture 20 4 / 29

5 Memory Access in Program Execution The instruction execution cycle: The CPU fetches an instruction from main memory, according to the value of the program counter. The instruction may require other main memory locations to be accessed, for loading or storing contents of registers. The memory unit is responsible for accessing main memory. This unit doesn t know or care about what the data being accessed are actually used for. Zhiyi Huang (Otago) COSC243 Lecture 20 5 / 29

6 Getting a Program into Main Memory Memory management deals with how to get processes into main memory, and the organisation of that memory. This isn t a trivial task. The memory unit accesses es in primary memory. (E.g ) Source code just refers to symbols. (Variables: e.g. count.) (Procedures: e.g. get_next_item.) Symbols need to be converted into es. Technically, we talk of symbols being bound to es. Zhiyi Huang (Otago) COSC243 Lecture 20 6 / 29

7 Address Binding Symbols can be converted into es at several points: Compile time. Compilers can create: absolute code: if it s known where the process will reside in memory. (E.g. MS-DOS.COM programs.) relocatable code: if this is not known. Link time. Programs are often designed as separate modules which are compiled separately, but make reference to each other. These must be linked, so that their variables are correctly bound. Load time. When the process is loaded into main memory. Run time. If a process can be moved during execution from one place in memory to another. Zhiyi Huang (Otago) COSC243 Lecture 20 7 / 29

8 Where can binding occur? source program compiler / assembler compile time other object modules object module linkage editor system library load module load time dynamically loaded system library dynamic linking loader main memory storage run time Zhiyi Huang (Otago) COSC243 Lecture 20 8 / 29

9 Dynamic Linking and Loading When a source program is compiled, the code for the functions provided by the language (e.g. Java libraries) needs to be incorporated into the object program. In static linking, this is done before the program is executed. In dynamic linking, it is only done at run-time. A stub containing a pointer is included in place of the code for each routine. When the stub is referenced, the pointer is initialised: - if the routine is already loaded, use it; - otherwise load the routine. Advantages of dynamic linking? Saving on memory space. (don t need multiple copies of the same routines). Saving on load time. (only need to load a routine once). Ease of updating libraries (e.g. to fix bugs, change versions). Zhiyi Huang (Otago) COSC243 Lecture 20 9 / 29

10 Logical and Physical Addresses Some terminology: A logical is one referred to in a piece of executable code (e.g. to refer to a variable or a location). It is used in a process space. The CPU executes instructions involving logical es. Logical is also called virtual. A physical is the which is actually sent to the memory unit. In compile-time and load-time binding, logical es are used. At run-time, something in the computer has to map between logical and physical es. Zhiyi Huang (Otago) COSC243 Lecture / 29

11 The Memory-Management Unit The logical space of a process runs from 0 to the memory limit of the process. Physical space runs from 0 to the size of main memory. The memory management unit maps between the two. It takes a logical generated by the CPU, and adds a number N to compute the physical. The number is held in a relocation register. relocation register CPU logical N + physical memory Memory management unit To move a process in memory, just change the relocation register. Zhiyi Huang (Otago) COSC243 Lecture / 29

12 Run-Time Binding and Multitasking Run-time binding is useful for saving on memory: Only loading modules if they re needed. Allowing several processes to share one copy of a module. There are also many benefits that relate to a multitasking scenario. Until now, our multitasking scenario has involved switching between processes resident in main memory. But note: while a process is waiting for the CPU, there s no reason for it to be in main memory. Zhiyi Huang (Otago) COSC243 Lecture / 29

13 Swapping Terminology: processes are swapped in and out of main memory to/from a backing store. O/S swap out swap in P1 P2 main memory backing store Swapping is done by the memory manager, which is a module of the kernel. The memory manager needs to work in synch with the CPU scheduler. Zhiyi Huang (Otago) COSC243 Lecture / 29

14 Memory Allocation and Protection Lecture on data sharing: processes are not allowed to access each other s space (except under special circumstances). Q: How is this rule implemented? A: Each process is associated with a relocation register and also a limit register. logical limit register < yes relocation register + physical CPU no TRAP: ing error main memory Zhiyi Huang (Otago) COSC243 Lecture / 29

15 Allocating Memory for Several Processes How to organise memory allocation for many processes? A simple method: divide memory into a number of fixed-size partitions. Problems? Processes can be different sizes. Presumably the partitions would have to be as big as the biggest process, which would make for huge redundancy. A more complex method: Each free region of memory is termed a hole. When a process arrives, we find a hole big enough to put it into. If the hole is bigger than the process, we keep a record of the new (smaller) hole. Zhiyi Huang (Otago) COSC243 Lecture / 29

16 Algorithms for Choosing a Hole There are different methods First-fit: allocate the first hole you find that s big enough. Best-fit: find the hole that leaves the smallest leftover hole. Worst-fit: find the hole that leaves the biggest leftover hole. Advantages/disadvantages of each? First-fit: quickest (because you don t have to search every hole), but you mightn t allocate the optimal-sized hole. Best-fit: you have to search the whole set of holes each time. A disadvantage is that you end up creating very small holes. Worst-fit: again, you have to do an exhaustive search. You minimise the problem of creating small holes, but you might not use the large holes as effectively as you could; you might put small processes into them which mean that there are no holes large enough for a subsequent large process. Zhiyi Huang (Otago) COSC243 Lecture / 29

17 External Fragmentation If memory is broken into many holes, there might be enough memory in total to fit a particular process, but not all in one place. This situation is called external fragmentation. P1 P0 holes process memory Worst-case external fragmentation: a hole between every pair of processes. Zhiyi Huang (Otago) COSC243 Lecture / 29

18 Internal Fragmentation The operating system has to keep a table of all the currently available holes in memory. Hole Memory region H 1 H 2... There s a large overhead in keeping track of lots of very small holes. P1 new hole? process hole To avoid creating tiny holes, we sometimes allocate a process more memory than it needs. Unused memory within a process is called internal fragmentation. Zhiyi Huang (Otago) COSC243 Lecture / 29

19 Noncontiguous Memory Allocation The allocation methods described so far have all required the memory allocated for a process to be contiguous. Obviously, noncontiguous allocation has advantages. One way of providing noncontiguous allocation is through paging. In paging, a process logical space is broken into fixed-size units called pages, and main memory is broken into units of the same size, called frames. PAGES FRAMES CPU logical memory physical memory Zhiyi Huang (Otago) COSC243 Lecture / 29

20 Paging In a paged memory allocation scheme, the logical es generated by the CPU are broken by special hardware into two components: a page number (identifying a page), and an offset (an within that page). CPU logical p off f page table page P0 P1 P2 P3 frame F1 F4 F3 F6 physical off F0 F1 F2 F3 F4 F5 F6 memory A page table indicates for each page which frame it s stored in. Paging allows a process to be stored noncontigously in memory. Paging is a way of implementing run-time binding. Zhiyi Huang (Otago) COSC243 Lecture / 29

21 An example Consider the following scenario: Pages (and frames) are 10 bytes in size. There are 70 bytes of main memory in total. Process P1 has a logical space of 40 bytes, and a page table which looks like this: page frame Q: What physical es would be accessed by the following stream of logical es? 0, 11, 25, 31 10, 41, 35, 61 Zhiyi Huang (Otago) COSC243 Lecture / 29

22 Memory protection: valid/invalid bits A process takes up a certain number of pages n. But the page table typically has more than n entries. CPU logical p off page P0 P1 P2 P3 frame F1 F4 F3 F6 physical f off F0 F1 F2 F3 F4 F5 F6 memory Zhiyi Huang (Otago) COSC243 Lecture / 29

23 Memory protection: valid/invalid bits A process takes up a certain number of pages n. But the page table typically has more than n entries. CPU logical p off page P0 P1 P2 P3 frame F1 F4 F3 F6 physical f off F0 F1 F2 F3 F4 F5 F6 memory So the page table also stores a valid/invalid bit, which is set to invalid for out-of-range memory references. Zhiyi Huang (Otago) COSC243 Lecture / 29

24 Memory protection: valid/invalid bits A process takes up a certain number of pages n. But the page table typically has more than n entries. CPU logical p off page P0 P1 P2 P3 frame F1 F4 F3 F6 physical v v v v i i i f off F0 F1 F2 F3 F4 F5 F6 memory So the page table also stores a valid/invalid bit, which is set to invalid for out-of-range memory references. Zhiyi Huang (Otago) COSC243 Lecture / 29

25 An example of paging with valid/invalid bits Consider the following scenario: Pages (and frames) are 10 bytes in size. There are 70 bytes of main memory in total. Process P1 has a logical space of 40 bytes, and a page table which looks like this: page frame valid/invalid bit 0 1 v 1 4 v 2 3 v 3 6 v 4 i... i What happens if the CPU requests logical 48? invalid-memory-access, segmentation fault Zhiyi Huang (Otago) COSC243 Lecture / 29

26 Paging: some questions What happens to external fragmentation in a paging scheme? A: this scheme eliminates it. What happens to internal fragmentation? A: each process has to be allocated a discrete number of pages. So there s going to be internal fragmentation when a process doesn t fit exactly. It ll be on average half a page per process, assuming process size is independent of page size. So how big should pages be? A: small, but not so small that the disk I/O and housekeeping become too great. How many page tables do we need? A: one for each process. How does the O/S keep track of a process page table? A: It keeps a copy in its PCB. (Remember I said that the PCB contains memory management information...) Zhiyi Huang (Otago) COSC243 Lecture / 29

27 Implementing Paging The fastest/most expensive way of implementing pages is to store the page table in a set of special-purpose registers. But this isn t feasible if the page table is big (as it normally is). The alternative is to store the page table in main memory. But this could slow things down hugely: to access an in memory, we now need two or more memory accesses. The solution is to keep a cache of page table entries that have been used recently, in a special set of parallel-access registers called associative registers, aka. Translation Look-aside Buffer (TLB). Zhiyi Huang (Otago) COSC243 Lecture / 29

28 Segmentation In the paging scheme above, it s the hardware that partitions a CPU-generated into pages. But there are some reasons for allowing a process to partition its own space. subroutine SQRT stack main program symbol table logical space A segmentation allocation scheme supports this view of memory. Zhiyi Huang (Otago) COSC243 Lecture / 29

29 Implementing Segmentation In a segmentation scheme, a logical is a pair of < segment_number, offset >. These are mapped onto physical es by the segmentation hardware, using a segment table. Each entry in the table has a segment base (the starting physical ) and a segment limit (the size of the segment). Segments can be stored noncontiguously. Like the page table, the segment table can either be put into fast registers or main memory. Zhiyi Huang (Otago) COSC243 Lecture / 29

30 Advantages / disadvantages of segmentation? Advantages: makes protection and sharing easy to deal with (as items in a segment have the same protection status). You just need one protection bit per segment. it just makes it easier to write machine code. (And thus to write compilers.) Disadvantages: external fragmentation is back. But with less of a vengeance. NB: clever schemes (e.g. MULTICS) use paging and segmentation. The idea is that a memory reference is a segment base plus segment offset, where the segment offset is itself broken into two components: a page number and a page offset. There is a question about the MULTICS scheme in Tutorial 11B Zhiyi Huang (Otago) COSC243 Lecture / 29

31 Reading For this lecture, you should have read Chapter 8 (Sections 1 6) of Silberschatz et al. For next lecture, you should read Chapter 9 (Sections 1 7). Zhiyi Huang (Otago) COSC243 Lecture / 29

Memory Management. Main memory Virtual memory

Memory Management. Main memory Virtual memory Memory Management Main memory Virtual memory Main memory Background (1) Processes need to share memory Instruction execution cycle leads to a stream of memory addresses Basic hardware CPU can only access

More information

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Memory management basics (1) Requirements (1) Operating Systems Part of E1.9 - Principles of Computers and Software Engineering Lecture 7: Memory Management I Memory management intends to satisfy the following

More information

Chapter 9: Memory Management

Chapter 9: Memory Management Chapter 9: Memory Management Background Logical versus Physical Address Space Overlays versus Swapping Contiguous Allocation Paging Segmentation Segmentation with Paging Operating System Concepts 9.1 Background

More information

Chapter 9: Memory Management. Background

Chapter 9: Memory Management. Background 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 it

More information

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging Memory Management Outline Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging 1 Background Memory is a large array of bytes memory and registers are only storage CPU can

More information

Agenda. Memory Management. Binding of Instructions and Data to Memory. Background. CSCI 444/544 Operating Systems Fall 2008

Agenda. Memory Management. Binding of Instructions and Data to Memory. Background. CSCI 444/544 Operating Systems Fall 2008 Agenda Background Memory Management CSCI 444/544 Operating Systems Fall 2008 Address space Static vs Dynamic allocation Contiguous vs non-contiguous allocation Background Program must be brought into memory

More information

CH 7. MAIN MEMORY. Base and Limit Registers. Memory-Management Unit (MMU) Chapter 7: Memory Management. Background. Logical vs. Physical Address Space

CH 7. MAIN MEMORY. Base and Limit Registers. Memory-Management Unit (MMU) Chapter 7: Memory Management. Background. Logical vs. Physical Address Space Chapter 7: Memory Management CH 7. MAIN MEMORY Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation adapted from textbook slides Background Base and Limit Registers

More information

Chapter 8: Memory Management!

Chapter 8: Memory Management! The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still

More information

Background. Memory Management. Base and Limit Registers. Binding of Instructions and Data to Memory. Logical vs. Physical Address Space

Background. Memory Management. Base and Limit Registers. Binding of Instructions and Data to Memory. Logical vs. Physical Address Space Background Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage CPU can access directly Register access

More information

Memory Management (Ch.9)

Memory Management (Ch.9) Memory Management (Ch.9)! Background! Address Binding - Linking and Loading! Swapping! Memory Protection! Contiguous Memory Allocation! Paging! Segmentation! Combined Paging and Segmentation Silberschatz

More information

8.1 Background. Base and Limit Registers. Chapter 8: Memory-Management Management Strategies. Objectives

8.1 Background. Base and Limit Registers. Chapter 8: Memory-Management Management Strategies. Objectives Chapter 8: Memory-Management Management Strategies Objectives To provide a detailed description of various ways of organizing memory hardware To discuss various memory-management techniques, including

More information

OS - Memory Management

OS - Memory Management OS - Memory Management Memory management is the functionality of an operating system which handles or manages primary memory. Memory management keeps track of each and every memory location either it is

More information

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

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 602 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

Operating Systems Concepts

Operating Systems Concepts Operating Systems Concepts MODULE 7: MEMORY MANAGEMENT Andrzej Bednarski, Ph.D. student Department of Computer and Information Science Linköping University, Sweden E-mail: andbe@ida.liu.se URL: http://www.ida.liu.se/~andbe

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

Operating Systems Memory Management

Operating Systems Memory Management Operating Systems Memory Management ECE 344 ECE 344 Operating Systems 1 Memory Management Contiguous Memory Allocation Paged Memory Management Virtual Memory ECE 344 Operating Systems 2 Binding of Instructions

More information

Virtual Memory & Memory Management

Virtual Memory & Memory Management CS 571 Operating Systems Virtual Memory & Memory Management Angelos Stavrou, George Mason University Memory Management 2 Logical and Physical Address Spaces Contiguous Allocation Paging Segmentation Virtual

More information

OPERATING SYSTEM - MEMORY MANAGEMENT

OPERATING SYSTEM - MEMORY MANAGEMENT OPERATING SYSTEM - MEMORY MANAGEMENT http://www.tutorialspoint.com/operating_system/os_memory_management.htm Copyright tutorialspoint.com Memory management is the functionality of an operating system which

More information

Lecture 4: Memory Management

Lecture 4: Memory Management Lecture 4: Memory Management Background Program must be brought into memory and placed within a process for it to be run Input queue collection of processes on the disk that are waiting to be brought into

More information

What is the Base register and what is the Limit register?

What is the Base register and what is the Limit register? What is the Base register and what is the Limit register? Base register: Specifies the smallest legal physical memory address. Limit register: Specifies the size of the range. A pair of base and limit

More information

Learning Outcomes. Memory Management

Learning Outcomes. Memory Management Learning Outcomes Memory Management Appreciate the need for memory management in operating systems, understand the limits of fixed memory allocation schemes. Understand fragmentation in dynamic memory

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 Memory Management Examine basic (not virtual) memory

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 Chapter 8: Memory Management Background Logical/Virtual Address Space vs Physical Address Space Swapping Contiguous Memory Allocation Segmentation

More information

CHAPTER 8 Exercises 8.1 Answer: 8.2 Answer: 8.3 Answer:

CHAPTER 8 Exercises 8.1 Answer: 8.2 Answer: 8.3 Answer: CHAPTER 8 Although many systems are demand paged (discussed in Chapter 12), there are still many that are not, and in many cases the simpler memory-management strategies may be better, especially for small

More information

Last Class: Memory Management. Today: Paging

Last Class: Memory Management. Today: Paging Last Class: Memory Management Uniprogramming Static Relocation Dynamic Relocation Lecture 15, page 1 Today: Paging Processes typically do not use their entire space in memory all the time. Paging 1. divides

More information

Memory Management - 1

Memory Management - 1 Memory Management - 1 Memory Management Unit memory is a critical resource efficient use sharing memory management unit Memory Management Unit: Main Aims relocation physical memory assigned to process

More information

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania, Fall 2002 Lecture Note: Memory Management.

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania, Fall 2002 Lecture Note: Memory Management. CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania, Fall 2002 Lecture Note: Memory Management 1 Memory Management q The memory management portion of the Operating System

More information

Memory Management Basics

Memory Management Basics Memory Management Basics 1 Basic Memory Management Concepts Address spaces Physical address space The address space supported by the hardware Starting at address, going to address MAX sys Logical/virtual

More information

Lectures 21 : Memory Management (ii) Thu 19 Nov 2009

Lectures 21 : Memory Management (ii) Thu 19 Nov 2009 CS211: Programming and Operating Systems Lectures 21 : Memory Management (ii) Thu 19 Nov 2009 CS211 Lectures 21 : Memory Management (ii) 1/23 This afternoon... 1 Recall... Memory management 2 Contiguous

More information

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) (Review) Memory Management

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) (Review) Memory Management Outline V22.0202-001 Computer Systems Organization II (Honors) (Introductory Operating Systems) Lecture 14 Memory Management March 28, 2005 Announcements Lab 4 due next Monday (April 4 th ) demos on 4

More information

Memory Management and Paging. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Memory Management and Paging. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Announcements PA #2 due Friday March 18 11:55 pm - note extension of a day Read chapters 11 and 12 From last time...

More information

III. Memory Management, Virtual Memory

III. Memory Management, Virtual Memory TDIU25: Operating Systems III. Memory Management, Virtual Memory SGG9: chapters 8 and 9 o Memory management: o contiguous allocation, fragmentation, segmentation, paging o Virtual memory: o demand paging,

More information

Basic Memory Management

Basic Memory Management Basic Memory Management Basic Memory Management CS 256/456 Dept. of Computer Science, University of Rochester Program must be brought into memory and placed within a process for it to be run. Mono-ming

More information

4 Main Memory Management

4 Main Memory Management 4 Main Memory Management 4.1 Introduction A large part of the OS s responsibility is organising main memory for processes. GOAL pack as many processes into memory as possible so that the processor will

More information

Goals of memory management. Today s desktop and server systems. Tools of memory management. A trip down Memory Lane

Goals of memory management. Today s desktop and server systems. Tools of memory management. A trip down Memory Lane Goals of memory management CSE 451: Operating Systems Spring 212 Module 11 Memory Management Allocate memory resources among competing processes, maximizing memory utilization and system throughput Provide

More information

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18 PROCESS VIRTUAL MEMORY CS124 Operating Systems Winter 2013-2014, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

Paging & Segmentation

Paging & Segmentation & Frédéric Haziza Department of Computer Systems Uppsala University Spring 2007 Outline 1 Paging Implementation Protection Sharing 2 Setup Implementation Definition Paging Memory-management

More information

Virtual and Physical Addresses

Virtual and Physical Addresses Virtual and Physical Addresses Physical addresses are provided by the hardware: one physical address space per machine; valid addresses are usually between 0 and some machinespecific maximum; not all addresses

More information

Announcement. HW#3 will be posted today. Exercise # 4 will be posted on Piazza today.

Announcement. HW#3 will be posted today. Exercise # 4 will be posted on Piazza today. Announcement HW#3 will be posted today. Exercise # 4 will be posted on Piazza today. Operating Systems: Internals and Design Principles Chapter 7 Memory Management Seventh Edition William Stallings Modified

More information

Contiguous Allocation. Contiguous Allocation. Free List. Dynamic Storage-Allocation Problem. Fragmentation

Contiguous Allocation. Contiguous Allocation. Free List. Dynamic Storage-Allocation Problem. Fragmentation Contiguous Allocation Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector. User processes then held in high memory. Memory Management --

More information

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example The Deadlock Problem Deadlocks A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 tape drives. P 1 and P 2 each

More information

Lesson 6: Memory Management & Virtualization

Lesson 6: Memory Management & Virtualization Lesson 6: Memory Management & Virtualization Contents Dynamic allocation, Memory fragmentation Paging Address translation with paging Paging hardware Page table structures Segmentation Virtual memory background

More information

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College April 7, 2015

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College April 7, 2015 CS 31: Intro to Systems Virtual Memory Kevin Webb Swarthmore College April 7, 2015 Reading Quiz Memory Abstraction goal: make every process think it has the same memory layout. MUCH simpler for compiler

More information

Lecture 10: Memory Management

Lecture 10: Memory Management Lecture 10: Memory Management CSE 120: Principles of Operating Systems guest starring Amin Vahdat Project 2 Due 11/14 Memory Management Next few lectures are going to cover memory management Goals of memory

More information

Start of Lecture: March 10, Chapter 8: Main Memory

Start of Lecture: March 10, Chapter 8: Main Memory Start of Lecture: March 10, 2014 1 Reminders Assignment 2 is done! Assignment 3 has been released, due last day of classes Exercise 4 is due on March 18 Paul Lu started talking about memory management

More information

COSC243 Part 2: Operating Systems

COSC243 Part 2: Operating Systems COSC243 Part 2: Operating Systems Lecture 25: Revision Zhiyi Huang Dept. of Computer Science, University of Otago Zhiyi Huang (Otago) COSC243 Lecture 25 1 / 11 Overview What s going to be in the exam?

More information

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 7 Memory Management Dave Bremer Otago Polytechnic, N.Z. 2009, Prentice Hall Roadmap Basic requirements of Memory Management

More information

Embedded RTOS Memory Management

Embedded RTOS Memory Management CS512 Embedded RTOS Embedded RTOS Memory Management C.-Z. Yang http://syslab.cse.yzu.edu.tw/~czyang Background Program must be brought into memory and placed within a process for it to be run. Binding

More information

Memory Management: Main Memory

Memory Management: Main Memory Memory Management: Main Memory It s all about bookkeeping The von Neumann model: fetch instructions from memory; decode instructions; possibly read or write data to or from memory; rinse and repeat In

More information

Chapter 2 Memory Management: Early Systems. Understanding Operating Systems, Fourth Edition

Chapter 2 Memory Management: Early Systems. Understanding Operating Systems, Fourth Edition Chapter 2 Memory Management: Early Systems Understanding Operating Systems, Fourth Edition Memory Management: Early Systems Memory is second only to processes in importance (and in intensity) with which

More information

Last Class: Memory Management. Recap: Paging

Last Class: Memory Management. Recap: Paging Last Class: Memory Management Static & Dynamic Relocation Fragmentation Paging Lecture 12, page 1 Recap: Paging Processes typically do not use their entire space in memory all the time. Paging 1. divides

More information

Objectives and Functions

Objectives and Functions Objectives and Functions William Stallings Computer Organization and Architecture 6 th Edition Week 10 Operating System Support Convenience Making the computer easier to use Efficiency Allowing better

More information

Memory Management. Today. Next Time. ! Basic memory management! Swapping! Kernel memory allocation. ! Virtual memory

Memory Management. Today. Next Time. ! Basic memory management! Swapping! Kernel memory allocation. ! Virtual memory Memory Management Today! Basic memory management! Swapping! Kernel memory allocation Next Time! Virtual memory Memory management! Ideal memory for a programmer Large Fast Non volatile Cheap! Nothing like

More information

Chapter 7 Memory Management

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

More information

OPERATING SYSTEMS MEMORY MANAGEMENT

OPERATING SYSTEMS MEMORY MANAGEMENT OPERATING SYSTEMS MEMORY MANAGEMENT Jerry Breecher 8: Memory Management 1 OPERATING SYSTEM Memory Management What Is In This Chapter? Just as processes share the CPU, they also share physical memory. This

More information

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct)

Memory unit sees only the addresses, and not how they are generated (instruction counter, indexing, direct) Memory Management 55 Memory Management Multitasking without memory management is like having a party in a closet. Charles Petzold. Programming Windows 3.1 Programs expand to fill the memory that holds

More information

Memory Management. Prof. P.C.P. Bhatt. P.C.P Bhat OS/M4/V1/2004 1

Memory Management. Prof. P.C.P. Bhatt. P.C.P Bhat OS/M4/V1/2004 1 Memory Management Prof. P.C.P. Bhatt P.C.P Bhat OS/M4/V1/2004 1 What is a Von-Neumann Architecture? Von Neumann computing requires a program to reside in main memory to run. Motivation The main motivation

More information

Computer Systems Engineering Department, QUEST, Nawabshah OPERATING SYSTEMS

Computer Systems Engineering Department, QUEST, Nawabshah OPERATING SYSTEMS OPERATING SYSTEMS Memory Management Introduction Fixed Partitioning Variable Partitioning Memory Hole/Allocation management Problems Introduction Techniques to manage Main memory efficiently Provides multitasking

More information

Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses

Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses Outline Address spaces and address binding compile-time load-time run-time Memory management: mapping virtual address to physical addresses Paging contiguous allocation and fragmentation paging hardware

More information

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory.

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory. Memory If we define memory as a place where data is stored there are many levels of memory: Processor registers Primary (or main) memory RAM Secondary memory slower and more permanent disks Tertiary memory

More information

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 to ensure a reasonable supply of ready processes to consume available processor

More information

1. Background. Chapter 8: Main Memory. Background (cont) Chapter 8: Memory Management

1. Background. Chapter 8: Main Memory. Background (cont) Chapter 8: Memory Management Chapter 8: Main Memory 1. Background Typical instruction/execution cycle Fetches an instruction from memory Decode Operand fetched from memory Result stored back in memory Memory units see ONLY a stream

More information

ICS Principles of Operating Systems

ICS Principles of Operating Systems ICS 143 - Principles of Operating Systems Operating Systems - Review of content from midterm to final Prof. Ardalan Amiri Sani Prof. Nalini Venkatasubramanian ardalan@uci.edu nalini@ics.uci.edu Deadlocks

More information

LOGICAL AND PHYSICAL ORGANIZATION MEMORY MANAGEMENT TECHNIQUES (CONT D)

LOGICAL AND PHYSICAL ORGANIZATION MEMORY MANAGEMENT TECHNIQUES (CONT D) 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

Memory Management. Memory Management

Memory Management. Memory Management Memory Management Logical vs. physical address space Fragmentation Paging Segmentation Reading: Silberschatz, Ch. 8 Memory Management Observations: Process needs at least CPU and memory to run. CPU context

More information

Module 4: Memory Management

Module 4: Memory Management Module 4: Memory Management The von Neumann principle for the design and operation of computers requires that a program has to be primary memory resident to execute. Also, a user requires to revisit his

More information

Section I Section Real Time Systems. Processes. 1.7 Memory Management. (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction

Section I Section Real Time Systems. Processes. 1.7 Memory Management. (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction EE206: Software Engineering IV 1.7 Memory Management page 1 of 28 Section I Section Real Time Systems. Processes 1.7 Memory Management (Textbook: A. S. Tanenbaum Modern OS - ch. 3) Memory Management Introduction

More information

CSC501 Operating Systems Principles. Memory Management

CSC501 Operating Systems Principles. Memory Management CSC501 Operating Systems Principles Memory Management 1 Previous Lectures q Linker & Loader q Today Q Memory Management 2 Layer user filesystem inter-machine net. memory mgr (high) device mgr + drivers

More information

PROJECT REPORT MEMORY MANAGEMENT DATE :

PROJECT REPORT MEMORY MANAGEMENT DATE : PROJECT REPORT MEMORY MANAGEMENT DATE : GROUP MEMBERS: MEMORY MANAGEMENT PURPOSE: To simulate memory management of a simple system in order to better comprehend the complex memory management system of

More information

Operating Systems, 6 th ed. Test Bank Chapter 7

Operating Systems, 6 th ed. Test Bank Chapter 7 True / False Questions: Chapter 7 Memory Management 1. T / F In a multiprogramming system, main memory is divided into multiple sections: one for the operating system (resident monitor, kernel) and one

More information

Lecture 17: Paging Mechanisms

Lecture 17: Paging Mechanisms Operating Systems (A) (Honor Track) Lecture 17: Paging Mechanisms Tao Wang School of Electronics Engineering and Computer Science http://ceca.pku.edu.cn/wangtao Fall 2013 Acknowledgements: Prof. Xiangqun

More information

An Introduction to Memory Management: appendix. Copyright : University of Illinois CS 241 Staff 1

An Introduction to Memory Management: appendix. Copyright : University of Illinois CS 241 Staff 1 An Introduction to Memory Management: appendix Copyright : University of Illinois CS 241 Staff 1 Memory partitioning Nowadays memory management is based on a sophisticated technique known as (paged) virtual

More information

Virtual vs Physical Addresses

Virtual vs Physical Addresses Virtual vs Physical Addresses Physical addresses refer to hardware addresses of physical memory. Virtual addresses refer to the virtual store viewed by the process. virtual addresses might be the same

More information

Operating Systems. Memory Management. Memory management

Operating Systems. Memory Management. Memory management Oerating Systems Memory management Memory Management List of Toics 1. Memory Management 2. Memory In Systems Design 3. Binding Times 4. Introduction to Memory Management 5. Raw Memory Model 6. Single Contiguous

More information

7. Memory Management

7. Memory Management Lecture Notes for CS347: Operating Systems Mythili Vutukuru, Department of Computer Science and Engineering, IIT Bombay 7. Memory Management 7.1 Basics of Memory Management What does main memory (RAM)

More information

William Stallings Computer Organization and Architecture

William Stallings Computer Organization and Architecture William Stallings Computer Organization and Architecture Chapter 8 Operating System Support Rev. 3.2 (2009-10) by Enrico Nardelli 8-1 Objectives and Functions Convenience Making the computer easier to

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

Chapter 7 Memory Management

Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 7 Memory Management Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Memory Management Subdividing

More information

Memory Management. In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes

Memory Management. In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes Memory Management Is the task carried out by the OS and hardware to accommodate multiple processes in main memory If only a few processes can be kept in main memory, then much of the time all processes

More information

CSE 513 Introduction to Operating Systems. Class 7 - Virtual Memory (2)

CSE 513 Introduction to Operating Systems. Class 7 - Virtual Memory (2) CSE 513 Introduction to Operating Systems Class 7 - Virtual Memory (2) Jonathan Walpole Dept. of Comp. Sci. and Eng. Oregon Health and Science University Key memory management issues Utilization Programmability

More information

Memory Management CS 447. Prof. R.K. Joshi Dept of CSE IIT Bombay

Memory Management CS 447. Prof. R.K. Joshi Dept of CSE IIT Bombay Memory Management CS 447 Prof. R.K. Joshi Dept of CSE IIT Bombay Some Simple Memory schemes Some Simple Memory schemes Some Simple Memory schemes Overlays: User level memory management (e.g. TurboPascal)

More information

Virtual Memory. COMP375 Computer Architecture and Organization

Virtual Memory. COMP375 Computer Architecture and Organization Virtual Memory COMP375 Computer Architecture and Organization You never know when you're making a memory. Rickie Lee Jones Design Project The project is due 1:00pm (start of class) on Monday, October 19,

More information

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358 Virtual Memory Reading: Silberschatz chapter 10 Reading: Stallings chapter 8 1 Outline Introduction Advantages Thrashing Principal of Locality VM based on Paging/Segmentation Combined Paging and Segmentation

More information

Operating Systems Part M15 Virtual Memory, Shared Libraries, Microkernels, Sandboxing and Virtualization. Florina Ciorba 24 November 2015

Operating Systems Part M15 Virtual Memory, Shared Libraries, Microkernels, Sandboxing and Virtualization. Florina Ciorba 24 November 2015 Operating Systems Part M15 Virtual Memory, Shared Libraries, Microkernels, Sandboxing and Virtualization Florina Ciorba 24 November 2015 Today s Overview (Main) Memory management Shared libraries Compiling,

More information

8 Memory Management. 8.1 Requirements. 8 Memory Management Protection Relocation INTRODUCTION TO MEMORY MANAGEMENT OPERATING SYSTEMS

8 Memory Management. 8.1 Requirements. 8 Memory Management Protection Relocation INTRODUCTION TO MEMORY MANAGEMENT OPERATING SYSTEMS OPERATING SYSTEMS INTRODUCTION TO MEMORY MANAGEMENT 1 8 Memory Management In a multiprogramming system, in order to share the processor, a number of processes must be kept in. Memory management is achieved

More information

ICS Principles of Operating Systems

ICS Principles of Operating Systems ICS 143 - Principles of Operating Systems Lectures 15 and 16 - Virtual Memory Prof. Ardalan Amiri Sani Prof. Nalini Venkatasubramanian ardalan@uci.edu nalini@ics.uci.edu Virtual Memory Background Demand

More information

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet. Memory Management 1 Memory Management Multitasking without memory management is like having a party in a closet. Charles Petzold. Programming Windows 3.1 Programs expand to fill the memory that holds them.

More information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIRST, SECOND, THIRD SEMESTER FINAL EXAMINATION, 2014/2015 SESSION ITC2053/TIS2233 OPERATING SYSTEM DSEWE-F-2-/14, DSEW-E-F-1/14,

More information

Memory Management Thrashing, Segmentation and Paging

Memory Management Thrashing, Segmentation and Paging Memory Management Thrashing, Segmentation and Paging CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers Sakai: 01:198:416 Sp11 (https://sakai.rutgers.edu) Summary of Page

More information

Last Class: Demand Paged Virtual Memory!

Last Class: Demand Paged Virtual Memory! Last Class: Demand Paged Virtual Memory! Benefits of demand paging: Virtual address space can be larger than physical address space. Processes can run without being fully loaded into memory. Processes

More information

Topics. Caches and Virtual Memory. Cache Operations. Cache Operations. Write Policies on Cache Hit. Read and Write Policies.

Topics. Caches and Virtual Memory. Cache Operations. Cache Operations. Write Policies on Cache Hit. Read and Write Policies. Topics Caches and Virtual Memory CS 333 Fall 2006 Cache Operations Placement strategy Replacement strategy Read and write policy Virtual Memory Why? General overview Lots of terminology Cache Operations

More information

Memory Management Duties. Overview of Presentation. (User View: code segments) User View: address space

Memory Management Duties. Overview of Presentation. (User View: code segments) User View: address space Overview of Presentation responsibilities of a memory manager user view of memory management memory management strategies, algorithms fixed partitions, variable partitions algorithms, fragmentation, coalescing

More information

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems Lecture Outline Operating Systems Objectives Describe the functions and layers of an operating system List the resources allocated by the operating system and describe the allocation process Explain how

More information

Today. Memory management. Memory Management. Computer Hardware Review

Today. Memory management. Memory Management. Computer Hardware Review Memory management Knut Omang Ifi/Paradial 1 Oct, 2009 (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

Chapter 3 Memory Management: Virtual Memory

Chapter 3 Memory Management: Virtual Memory Understanding Operating Systems, Fifth Edition 3-1 Chapter 3 Memory Management: Virtual Memory At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics

More information

Chapter 9: Virtual-Memory Management

Chapter 9: Virtual-Memory Management Chapter 9: Virtual-Memory Management Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocation Kernel Memory Other

More information

CHAPTER 8 : VIRTUAL MEMORY. Introduction

CHAPTER 8 : VIRTUAL MEMORY. Introduction CHAPTER 8 : VIRTUAL MEMORY Introduction In simple paging and segmentation, we realised that we can : Load program pages or segments into frames that may not necessarily be contigous. Make memory address

More information

Virtual Memory (Ch.10)

Virtual Memory (Ch.10) Virtual Memory (Ch.10)! Background! Demand Paging! Page Faults! Page Replacement! Page Replacement Algorithms! Thrashing! Strategies for Thrashing Prevention Silberschatz / OS Concepts / 6e - Chapter 10

More information

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management.

Technical Properties. Mobile Operating Systems. Overview Concepts of Mobile. Functions Processes. Lecture 11. Memory Management. Overview Concepts of Mobile Operating Systems Lecture 11 Concepts of Mobile Operating Systems Mobile Business I (WS 2007/08) Prof Dr Kai Rannenberg Chair of Mobile Business and Multilateral Security Johann

More information

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

Chapter 9: Virtual-Memory Management. Operating System Concepts with Java 8 th Edition Chapter 9: Virtual-Memory Management Operating System Concepts with Java 8 th Edition 9.1 Silberschatz, Galvin and Gagne 2009 Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement

More information