Memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved.

Slides:



Advertisements
Similar presentations
Chapter 4 Memory Management Basic memory management Swapping
Advertisements

Memory.
Part IV: Memory Management
Chapter 6: Memory Management
Chapter 2: Memory Management, Early Systems
Understanding Operating Systems Fifth Edition
Memory Management Chapter 7.
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable supply of ready processes to.
Chapter 7 Memory Management
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2009, Prentice.
Chapter 7 Memory Management
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
Memory Management Chapter 7. Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management - 2 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Memory Management Chapter 7 B.Ramamurthy. Memory Management Subdividing memory to accommodate multiple processes Memory needs to allocated efficiently.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory Management Chapter 5.
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Memory management. Instruction execution cycle Fetch instruction from main memory Decode instruction Fetch operands (if needed0 Execute instruction Store.
Memory Management Chapter 7.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Dr.
Chapter 4 Memory Management.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
Subject: Operating System.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Memory Management. Introduction To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Memory.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
2010INT Operating Systems, School of Information Technology, Griffith University – Gold Coast Copyright © William Stallings /2 Memory Management.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Memory Management One of the most important OS jobs.
Memory Management Chapter 7.
Chapter 7 Memory Management
Memory Management Chapter 7.
Memory Management.
ITEC 202 Operating Systems
Chapter 2 Memory and process management
Day 19 Memory Management.
Memory management.
Memory Allocation The main memory must accommodate both:
Main Memory Management
Module IV Memory Organization.
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Multistep Processing of a User Program
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
So far… Text RO …. printf() RW link printf Linking, loading
Memory Management-I 1.
Chapter3 Memory Management Techniques
Main Memory Background Swapping Contiguous Allocation Paging
Lecture 3: Main Memory.
Memory Management (1).
Chapter 8: Memory Management strategies
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Operating Systems: Internals and Design Principles, 6/E
Chapter 7 Memory Management
Page Main Memory.
Presentation transcript:

CHAPTER 3 MEMORY MANAGEMENT PART I by Ugur Halıcı

memory management In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. Memory management is achieved through memory management algorithms. Each memory management algorithm requires its own hardware support. In this chapter, we shall see the partitioning, paging and segmentation methods.

Memory Management In order to be able to load programs at anywhere in memory, the compiler must generate relocatable object code. Also we must make it sure that a program in memory, addresses only its own area, and no other program’s area. Therefore, some protection mechanism is also needed.

3.1 Fixed Partitioning memory OS n KB small 3n KB Medium 6n KB Large In this method, memory is divided into partitions whose sizes are fixed. OS is placed into the lowest bytes of memory. Relocation of processes is not needed

3.1 Fixed Partitioning memory OS n KB small 3n KB Medium 6n KB Large Processes are classified on entry to the system according to their memory they requirements. We need one Process Queue (PQ) for each class of process. small area Q medium area Q large area Q

3.1 Fixed Partitioning memory OS n KB small 3n KB Medium 6n KB Large If a process is selected to allocate memory, then it goes into memory and competes for the processor. The number of fixed partition gives the degree of multiprogramming. Since each queue has its own memory region, there is no competition between queues for the memory. small area Q medium area Q large area Q

3.1 Fixed Partitioning memory OS n KB small 3n KB Medium 6n KB Large The main problem with the fixed partitioning method is how to determine the number of partitions, and how to determine their sizes. small area Q medium area Q large area Q

Fixed Partitioning with Swapping memory OS 2K P1 6K P2 12K empty This is a version of fixed partitioning that uses RRS with some time quantum. When time quantum for a process expires, it is swapped out of memory to disk and the next process in the corresponding process queue is swapped into the memory. P3 P4 P5 empty

Fixed Partitioning with Swapping memory OS 2K P1 6K P2 12K empty P3 P4 empty P5 Secondary storage

Fixed Partitioning with Swapping memory OS 2K 6K P2 12K empty Swap out P1 P3 P4 empty P5 P1 Secondary storage

Fixed Partitioning with Swapping memory OS 2K P3 6K P2 12K empty Swap in P3 P1 P4 empty P5 Secondary storage

Fixed Partitioning with Swapping memory OS 2K P3 6K P2 12K empty P1 P4 empty P5 Secondary storage

Fixed Partitioning with Swapping memory OS 2K 6K P2 12K empty Swap out P3 P1 P4 empty P5 P3 Secondary storage

Fixed Partitioning with Swapping memory OS 2K P1 6K P2 12K empty Swap in P1 P3 P4 empty P5 Secondary storage

Fixed Partitioning with Swapping memory OS 2K P1 6K P2 12K empty P3 P4 empty P5 Secondary storage

fragmentation memory OS 2K 6K Empty (6K) 12K empty Empty (3K) If a whole partition is currently not being used, then it is called an external fragmentation. P1 (2K) P2 (9K) If a partition is being used by a process requiring some memory smaller than the partition size, then it is called an internal fragmentation.

3.2 Variable Partitioning With fixed partitions we have to deal with the problem of determining the number and sizes of partitions to minimize internal and external fragmentation. If we use variable partitioning instead, then partition sizes may vary dynamically. In the variable partitioning method, we keep a table (linked list) indicating used/free areas in memory.

3.2 Variable Partitioning Initially, the whole memory is free and it is considered as one large block. When a new process arrives, the OS searches for a block of free memory large enough for that process. We keep the rest available (free) for the future processes. If a block becomes free, then the OS tries to merge it with its neighbors if they are also free.

3.2 Variable Partitioning There are three algorithms for searching the list of free blocks for a specific amount of memory. First Fit Best Fit Worst Fit

first fit First Fit : Allocate the first free block that is large enough for the new process. This is a fast algorithm.

Initial memory mapping first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

first fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P4 of 3KB loaded here by FIRST FIT

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 of 15KB arrives

first fit OS P1 12 KB P4 3 KB <FREE> 7 KB P2 20 KB P5 15 KB P5 of 15 KB loaded here by FIRST FIT

Best fit Best Fit : Allocate the smallest block among those that are large enough for the new process. In this method, the OS has to search the entire list, or it can keep it sorted and stop when it hits an entry which has a size larger than the size of new process. This algorithm produces the smallest left over block. However, it requires more time for searching all the list or sorting it If sorting is used, merging the area released when a process terminates to neighboring free blocks, becomes complicated.

Initial memory mapping best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB loaded here by BEST FIT

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P5 of 15KB arrives

best fit OS P1 12 KB <FREE> 10 KB P2 20 KB P5 15 KB P5 of 15 KB loaded here by BEST FIT

worst fit Worst Fit : Allocate the largest block among those that are large enough for the new process. Again a search of the entire list or sorting it is needed. This algorithm produces the largest over block.

Initial memory mapping worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P3 6 KB <FREE> 4 KB Initial memory mapping

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB <FREE> 16 KB P4 of 3KB arrives

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB P4 of 3KB Loaded here by WORST FIT

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB No place to load P5 of 15K

worst fit OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB No place to load P5 of 15K Compaction is needed !!

compaction Compaction is a method to overcome the external fragmentation problem. All free blocks are brought together as one large block of free space. Compaction requires dynamic relocation. Certainly, compaction has a cost and selection of an optimal compaction strategy is difficult. One method for compaction is swapping out those processes that are to be moved within the memory, and swapping them into different memory locations

Memory mapping before compaction OS P1 12 KB <FREE> 10 KB P2 20 KB P4 3 KB <FREE> 13 KB P3 6 KB <FREE> 4 KB Memory mapping before compaction

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap out P2

compaction OS P1 12 KB P2 20 KB P4 3 KB Swap in P3 6 KB P2 Secondary storage

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary storage Swap out P4

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary Swap in storage Swap in P4 with a different starting address

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Secondary storage Swap out P3

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB Swap in P3 Secondary storage

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB <FREE> 27 KB Memory mapping after compaction Now P5 of 15KB can be loaded here

compaction OS P1 12 KB P2 20 KB P4 3 KB P3 6 KB P5 12 KB <FREE> 12 KB P5 of 15KB is loaded

relocation Static relocation: A process may be loaded into memory, each time possibly having a different starting address Necessary for variable partitioning Dynamic relocation: In addition to static relocation, the starting address of the process may change while it is already loaded in memory Necessary for compaction