CY2003 Computer Systems Lecture 09 Memory Management.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Chapter 6: Memory Management
Memory Management Chapter 7.
Fixed/Variable Partitioning
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.
OS Fall’02 Memory Management Operating Systems Fall 2002.
Modified from Silberschatz, Galvin and Gagne Lecture 16 Chapter 8: Main Memory.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
CSCI2413 Lecture 5 Operating Systems Memory Management 1 phones off (please)
Chapter 3.1 : Memory Management
Understanding Operating Systems1 Operating Systems Virtual Memory Thrashing Single-User Contiguous Scheme Fixed Partitions Dynamic Partitions.
COMP5102/5122 Lecture 4 Operating Systems (OS) Memory Management phones off (please)
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
Memory Management Chapter 5.
Computer Organization and Architecture
1 Chapter 3.1 : Memory Management Storage hierarchy Storage hierarchy Important memory terms Important memory terms Earlier memory allocation schemes Earlier.
Memory Allocation CS Introduction to Operating Systems.
Review of Memory Management, Virtual Memory CS448.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally MEMORYMANAGEMNT.
Memory Management Chapter 7.
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 7 Memory Management
1. Memory Manager 2 Memory Management In an environment that supports dynamic memory allocation, the memory manager must keep a record of the usage of.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
Chapter 4 Memory Management.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
6 Memory Management and Processor Management Management of Resources Measure of Effectiveness – On most modern computers, the operating system serves.
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.
CS 241 Section Week #9 (11/05/09). Topics MP6 Overview Memory Management Virtual Memory Page Tables.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Contiguous Memory Allocation Contiguous Memory Allocation  One of the simplest methods for allocating memory is to divide memory into.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
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.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Lecture 10 Page 1 CS 111 Online Memory Management CS 111 On-Line MS Program Operating Systems Peter Reiher.
Ch. 4 Memory Mangement Parkinson’s law: “Programs expand to fill the memory available to hold them.”
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.
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.
Chapter 7 Memory Management
Memory Management Chapter 7.
Memory Management.
Chapter 2 Memory and process management
Memory Allocation The main memory must accommodate both:
Partitioned Memory Allocation
Chapter 9 – Real Memory Organization and Management
CSI 400/500 Operating Systems Spring 2009
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 11/12/2018.
CS Introduction to Operating Systems
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.
Main Memory Background Swapping Contiguous Allocation Paging
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Lecture 3: Main Memory.
Memory Management (1).
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
Presentation transcript:

CY2003 Computer Systems Lecture 09 Memory Management

© LJMU, 2004CY2003- Week 092 Overview Memory management concepts –memory types cache, primary and secondary –contiguous v. non-contiguous memory allocation –single user memory allocation Fixed partition multiprogramming –concepts Variable partition multiprogramming Allocation strategies

© LJMU, 2004CY2003- Week 093 Background The process manager determines –when a process will run The memory manager determines –where a process will run The ‘first law’ of computing –however much memory a computer has, a program will be written that needs more! The functions of the memory manager include –allocating memory to processes –protecting memory areas from interference –overcoming the ‘first law’ by simulating extra memory

© LJMU, 2004CY2003- Week 094 Memory Types There are three main types of computer memory –cache on board, or very close to, the microprocessor –primary the main memory of the computer –Random Access Memory (RAM) or Read Only Memory (ROM) –secondary hard disks or other offline storage devices cache primary secondary

© LJMU, 2004CY2003- Week 095 A Simple Model In the simplest memory management model –one process is in memory at a time that process is allowed to use as much memory as available user program 1 user program 2 operating system 0x0000 0x1000 0xFFFF

© LJMU, 2004CY2003- Week 096 Overlays Even with this very simple model it is possible to increase the amount of memory available through the use of overlays main:initialisation input processing output initialisation main:initialisation input processing output main:initialisation input processing output input main:initialisation input processing output processing main:initialisation input processing output operating system 0x0000 0x1000 0xFFFF

© LJMU, 2004CY2003- Week 097 Contiguous and Non-contiguous The simple system presented so far allocates memory only in a single block –this is called contiguous storage allocation –the memory is in a single, continuous block, with no ‘holes’ or ‘gaps’ More complex memory management models have the capability to allocate memory in multiple blocks, or segments, which may be placed anywhere in primary memory –the blocks are not necessarily next to each other –this is called non-contiguous storage allocation

Fixed Partition Multiprogramming

© LJMU, 2004CY2003- Week 099 Concepts The first stage in extending the simple one- process model is to allow multiprogramming –this can improve processor utilisation if the average process only uses the processor 50% of the time and is performing I/O (waiting) for the other 50% then we can fully utilise the processor with two jobs Multiple jobs can be run if there is space in main memory, for example –the computer has 1Mb main memory the operating system occupies 200Kb each process fits into 400Kb –the computer has enough memory to run both jobs

© LJMU, 2004CY2003- Week 0910 Fixed Partitions The simplest multiprogramming scheme is the fixed partition multiprogramming model Memory is divided up into N partitions of fixed size –the partitions do not have to be the same size –the size of each may be determined by operators e.g. the IBM OS/360: partitions determined each morning –the maximum size of each process must be known The operating system keeps a track of which partitions are being used and which are free –processes are allocated to partitions when free

© LJMU, 2004CY2003- Week 0911 Multiple Partition Queues 0 100K 200K 400K 700K process E process F process G process D process C process A process B process A process C process D process E process F process G process B process F process B process G operating system

© LJMU, 2004CY2003- Week 0912 Single Partition Queue 0 100K 200K 400K 700K process A process B process C process D process B process C process Dprocess E process F process G process A operating system process E process F process G

Variable Partition Multiprogramming

© LJMU, 2004CY2003- Week 0914 What is Swapping? In a batch oriented operating system, fixed partition multiprogramming is simple and effective –as long as enough jobs can be kept in memory to keep the processor busy there is no real reason to use a more complicated memory allocation scheme In timesharing systems the situation is different –there are usually more users than there is main memory to hold all their processes –excess processes must be kept on hard disk Moving processes to and from between main memory and hard disk is called swapping

© LJMU, 2004CY2003- Week 0915 Fixed Partition Swapping In principle, a swapping system could be based on the fixed partition allocation scheme –whenever a process blocked it could be moved out to hard disk and the partition freed for use by another process to be swapped in However, this is likely to waste a lot of memory –if a large process is swapped out of a large partition, there may only be small processes ready to run If we are going to the trouble of implementing the ability to swap, then it is better to allow the partition sizes to change size (dynamically)

© LJMU, 2004CY2003- Week 0916 The Problem of Fixed Partitions process A process B process C process D process E process D (blocked) process E process A process D although process D is now ready to run again, there is no partition free that is big enough to hold it there is now a lot of wasted memory 0 100K 200K 400K 700K operating system

© LJMU, 2004CY2003- Week 0917 Variable Partitions When using variable partitions, the number, location and size of each partition is governed by the processes actually being run –when a process is to be swapped in (by being newly created or recently unblocked) a new partition big enough to hold the process is created –when a process is to be swapped out the partition is freed This flexibility improves memory usage buts also complicates allocation and deallocation –as well as keeping track of the memory used

© LJMU, 2004CY2003- Week 0918 How Variable Partitions Work process A process B process C process D process E operating system 0 1 Mb

Allocation Strategies

© LJMU, 2004CY2003- Week 0920 Allocation with Linked Lists A more sophisticated allocation data structure is required to deal with a variable number of free and used partitions –there are various data structures and associated algorithms available A linked list is one such possible data structure –a linked list consists of a number of entries (‘links’!) –each link contains data items –each link also contains a pointer to the next in the chain start free?nextstartsizefree?nextstartsizefree?endstartsize

© LJMU, 2004CY2003- Week 0921 First Fit The linked list is initialised to a single link of the entire memory size, flagged as ‘free’ Whenever a block of memory is requested the linked list is scanned in order until a link is found which represents free space of sufficient size –if requested space is exactly the size of the free space all the space is allocated –else, the free link is split into two the first entry is set to the size requested and marked ‘used’ the second entry is set to remaining size and marked ‘free’ When a block is freed the link is marked ‘free’

© LJMU, 2004CY2003- Week 0922 Next Fit The first fit algorithm starts scanning at the start of the linked list whenever a block is requested As a minor variation, the next fit algorithm maintains a record of where it got to, in scanning through the list, each time an allocation is made –the next time a block is requested the algorithms restarts its scan from where ever it left off last time –the idea is to give an even chance to all of memory to getting allocated, rather than concentrating at the start However, simulations have shown that next fit actually gives worse performance than first fit!

© LJMU, 2004CY2003- Week 0923 Best Fit First fit just looks for the first available hole –it doesn’t take into account that there may be a hole later in the list that exactly fits the requested size –first fit may break up a big hole when the right size hole exists later on The best fit algorithm always searches the entire linked list to find the smallest hole big enough to satisfy the memory request –however, it is slower than first fit because of searching –surprisingly, it also results in more wasted memory! because it tends to fill up memory with tiny, useless holes

© LJMU, 2004CY2003- Week 0924 Summary Memory management concepts –memory types cache, primary and secondary –contiguous v. non-contiguous memory allocation –single user memory allocation Fixed partition multiprogramming –concepts Variable partition multiprogramming Allocation strategies