Management From the memory view, we can list four important tasks that the OS is responsible for ; To know the used and unused memory partitions To allocate.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

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.
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.
Allocating Memory.
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 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.
Memory Management 2010.
Memory Management (continued) CS-3013 C-term Memory Management CS-3013 Operating Systems C-term 2008 (Slides include materials from Operating System.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Memory Management Chapter 5.
Computer Organization and Architecture
Lecture 9: SHELL PROGRAMMING (continued) Creating shell scripts!
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
Chapter 7 Memory Management
1 Lecture 8: Memory Mangement Operating System I Spring 2008.
Review of Memory Management, Virtual Memory CS448.
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.
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.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
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.
Page 110/20/2015 CSE 30341: Operating Systems Principles So far…  Page  Fixed size pages solve page allocation problem (and external fragmentation) 
Memory Management – Page 1 of 49CSCI 4717 – Computer Architecture Memory Management Uni-program – memory split into two parts –One for Operating System.
Memory Management Chapter 7.
Memory Management. Roadmap Basic requirements of Memory Management Memory Partitioning Basic blocks of memory management –Paging –Segmentation.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
CS6502 Operating Systems - Dr. J. Garrido Memory Management – Part 1 Class Will Start Momentarily… Lecture 8b CS6502 Operating Systems Dr. Jose M. Garrido.
1 Memory Management n In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes.
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 Allocation The main memory must accommodate both:
Paging COMP 755.
Chapter 9 – Real Memory Organization and Management
William Stallings Computer Organization and Architecture
Main Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy 11/12/2018.
Economics, Administration & Information system
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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.
Virtual Memory Management
Unit 6: Real Memory organization management
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
Chapter3 Memory Management Techniques
Main Memory Background Swapping Contiguous Allocation Paging
Memory Management Chapter 7.
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.
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.
COMP755 Advanced Operating Systems
Operating Systems: Internals and Design Principles, 6/E
Chapter 7 Memory Management
Presentation transcript:

Management From the memory view, we can list four important tasks that the OS is responsible for ; To know the used and unused memory partitions To allocate memory spaces for the processes To monitor the swapping operation between the main and the secondary memory Protect the allocated memory partitions from the unauthorised usage by the different processes

Basic Hardware of Memory Basically, all the memory managing services are done to organize the of the memory by the processes. Each process should has it’s separated memory space. This is done by the OS through the allocation of two registers. These registers are the BASE register and the LIMIT register. The BASE register will contain the starting address of the process and the LIMIT register will contain the size of the process. OS is the only one that monitors and changes the values of these registers by using the privilege instructions, which are allowed only in the kernel mode. It is clear that the OS uses these registers to protect the memory spaces of the processes that are found in the main memory. An example, to explain this is illustrated following two figures.

The Addressing Space for a Process in the Memory

The Use of Base and Limit registers The monitoring mechanism used by the OS to protect the memory spaces of the processes The Use of Base and Limit registers

Memory Allocation : We said that the OS will know and protect the space of each process through the BASE and LIMIT registers. But before the defining of these registers, we may ask how OS allocates the memory space itself for such a process. OS depends upon two main algorithms to allocate memory spaces to the processes. 1) Fixed partitions 2) Variable partitions

Fixed partitions method : In this method, the memory is divided in advance into different fixed sizes. The OS will load any process that comes in the partition that is enough for it. But if that partition is not available then the process will be put in the queue that linked to this partition as shown in the following figure (a). This technique is called multiple queues. The problem with this technique is the accumulation of the processes on a queue while there are other queues suitable for the processes in the busy queue. This is clear in the figure (a) since queue 1 ,4 are busy while queue 3 is empty. The solution for this problem is to use the single queue technique as shown in the figure (b). In this technique all processes are put in one queue and one of them is selected when any partition be free. However, there are two approach to select from between the processes in that single queue, these are 1) first fit : to select the first suitable process 2) best fit : to select the process with nearest size comparing with the free partition The disadvantage of the fixed partition method : is the problem of internal fragmentation . That happens when the partition is bigger than the process since the rest of the partition can not be used for any allocation

The Fixed Partitions of the Memory Multiple input queues Single input queues 700 K Partition 3 Partition 2 Partition 4 400 K 200 K 100 K 0 K Operating system Partition 1 (a) (b) Partition 1 Operating system The Fixed Partitions of the Memory

Variable partition method : In this method the OS looks to the memory as one space excluding the space that is allocated to the OS itself as shown in the figure of slide no. 9. This figure is an example showing how the OS allocates the spaces for 7 different sizes processes that come to the memory in different times. The Variable partition method is more efficient than the fixed partition method but it is more complicated. It is more efficient because the process will take what it needs not more so there is no internal fragmentation. And It is more complicated because the partitions will change in size and location with time. However, there are three technique to select the suitable partition for any process that want a space of memory to use, these techniques are : 1) first fit : select the first free space that is enough for the process 2) best fit: select the free space that is most near to the size of the process 3) worst fit : select the free space that is most far to the size of the process The disadvantage of the variable partition method is the problem of the external fragmentation , that is because some spaces that make up between the processes are small and not useful for use. This problem might be solved by compaction operation that is done by the OS from time to time when necessary, and as shown in the figure on slide no. 10

The variable Partitions of the Memory

Compaction operation to solve the problem of external fragmentation

The swapping As we know, the OS works in multi processes environment. And normally, The main memory is small, so it can not contain all the processes at any time. From another side, some of the processes in the main memory sometime become inactive, so the OS may decide to move out these processes to certain secondary memory called suspended processes store . In this case a space in the main memory becomes available and the OS may bring a new process from the input queue or may bring a suspended process that was moved out previously. The operation of bringing a process out of the main memory and bringing another process in its place is called swapping as shown in the figure of slide no. 12. The swapping is very important activity that is done by the OS under the following conditions: 1) if the process was waiting for I/O operation for long time then it better to swap it temporarily out the suspended store and swap another process in another process 2) if the process was waiting for a response from a user for long time then it better to swap it temporarily out the suspended store and swap another process in another process 3) if the process was waiting in the ready state then it is better to keep it in the memory without swapping 4) The OS must take care when selects a process from the suspended store to be swapped in. This depends on the importance of each process and if it is ready to swap in or not.

Swapping of Processes between Main and Backing Memory

The paging Till now we are talking about the principle that the process consists of one piece. So the OS must find a partition in the main memory that is equal or bigger than the process’s size. This principle can be broken by the idea of paging. In this case the process is divided into fixed size pieces called pages. In the same time the main memory is also divided into frames with size same as the page size. Here, the process can be put in the main memory as pages in different locations as shown in the figure of slide no. 13. It is clear that the memory is managed better with paging than before, that is because : 1) we don’t need to put all the process in one place 2) the problem of external fragmentation is reduced 3) we can put many processes in the main memory at the same time in more efficient way

Free Frames Allocation for Pages Main memory Back store Frames Free Frames Allocation for Pages

Dynamic Address Translation The important question in paging technique is how to translate the logical address into physical address. First of all this operation is called Dynamic Address Translation . In this operation the process’s space is divided into pages with page size defined by the system administrator and fed to the OS. Now, each instruction in any page is reached by the page number [p] and the displacement [d] within the page as shown in figure (a) of slide no. 16. Then, this page number is used to search the page table to know the frame number [ f ] where the OS put that page in. Then, this frame number will be added to the displacement [d] to reach the real location in the main memory as shown in figure (b) of slide no. 16.

Dynamic Addressing Translation For Paging Method

Segmentation As we said in paging technique, the process is divided into pages by the administrator without taking care to the boundaries of each page. In other words, the same page may contains data of different importance or different characteristics. This will affect the security of the data when there is sharing on these data between two processes as shown in the figure of slide no. 18. In segmentation technique, this problem is solved since the division of the process into segments is done by the process owner himself. For example, figure of slide no. 19 shows a typical division of a process. Here, the data security is insured because the programmer will know exactly the contents of each segment.

The problem of data security in paging technique Process 1 Page0 Page1 Page2 Page3 Page4 Page5 Page6 Process 2 needs data from page 4 of process 1 code Process 1 data This page contains shared and unshared information The problem of data security in paging technique

Division of Program into Segments

Dynamic Address Translation Like the paging technique, there is also an operation that translate the logical address into real address, which is also called Dynamic Address Translation . Figure of slide no. 21 shows the idea behind this translation. The translation starts when the processor produces a logical address that consists of two parts. These two parts are the segment number ( a number given to each segment in the process when it is loaded in the memory ) and the displacement [d] within this segment. The OS will use the segment number to search the segment table ( there a segment table for each process in the memory). This table consists of records so that each record belongs to a segment within the process. The record itself consists of two parts where the first part is the base address and the second part is the limit address. The displacement will be compared with the limit value to check for error ( if the displacement > limit ) . If the displacement is okay then the base address ( the starting address in the memory) will be added to the displacement to get the real address in the memory.

Dynamic Addressing Translation For Segmentation Method

Figure in the slide no. 23 shows an example for a process that consists of 5 segments. These segments are loaded in the memory according to information of the records shown in the segment table. Summary talk, we can compare between the paging and segmentation as below Paging segmentation 1) The process is divided by the administrator the process is divided by the owner 2) No external fragmentation but internal no internal fragmentation but fragmentation external fragmentation Not necessary the process to be loaded in same as paging one place Problem of data sharing the problem is solved

Practical Example for Segmentation Method