Download presentation
Presentation is loading. Please wait.
1
Chapter 2 Memory and process management
Part 1: Memory Management of OS
2
Topic : Define the function of memory manager.
Describe the characteristics of the different levels in the hierarchy of memory organization. Explain memory management strategies: Fetch, Placement and Replacement strategies. Identify between resident and transient routines.
3
- Explain the following terminology:
- Fixed-partition memory management - Memory swapping technique - Explain how virtual memory works Segmentation Paging
4
Memory Management Memory management is the act of managing computer memory. This involves providing ways to allocate portions of memory to programs at their request and freeing it for reuse when no longer needed.
5
Function of Memory Manager
Memory management is done by memory manager. Function of memory manager : Keep track of which parts of memory are in use and which parts are not in use Allocate memory to processes when they need it and deallocate it when they are done Manage swapping between main memory and disk when main memory is too small to hold all the processes
6
Characteristics of the Different Levels in the Hierarchy of Memory Organization
A 'memory hierarchy' in computer storage distinguishes each level in the 'hierarchy' by response time. Since response time, complexity, and capacity are related, the levels may also be distinguished by the controlling technology. There are four major storage levels. Internal – Processor registers and cache. Main – the system RAM and controller cards. On-line mass storage – Secondary storage. Off-line bulk storage – Tertiary and Off-line storage.
8
REGISTER MAIN MEMORY SECONDARY STORAGE TERTIARY STORAGE CACHE Memory Hierarchy
9
Memory Management Strategies
fetch strategy The method used to determine which block is to be obtained next. Determine when to load and how much to load at a time. E.g., demand fetching, anticipated fetching (pre-fetching). placement strategy The method used to determine where to put a new block To determine where information is to be placed. E.g., Best-Fit, First-Fit, Worst-Fit replacement strategy The method used to determine which resident block is to be displaced. Determine which memory area is to be removed under contention conditions. E.g., FIFO
10
3 algorithm for searching free block for a specific amount of memory:
1) First fit Allocate the first free block that is large enough for the new process. This a fast algorithm. 2) Best fit Allocate the smallest block among those that are large enough for the new process. OS search entire list, or it can keep it sorted and stop it when it has an entry which has a size larger than the size of process. This algorithm produces the smallest left over block.
11
3) Worst fit Allocate the largest block among those that are large enough for the new process. Search or sorting of the entire list is needed. This algorithm produces the largest left over block.
12
Memory Swapping Technique
Swapping is a simple memory/process management technique used by the operating system to increase the utilization of the processor by moving some blocked process from the main memory to the secondary memory(hard disk); Thus forming a queue of temporarily suspended process and the execution continues with the newly arrived process. After performing the swapping process, the operating system has two options in selecting a process for execution : Operating System can admit newly created process (OR) Operating system can activate suspended process from the swap memory.
13
Process A enters the main memory for execution
Process B is waiting for execution since the main memory is full Process B has higher priority since it must be executed the soonest Process A is swapped out from the main memory to the disk The main memory now has empty spaces for other process Process B is swapped in from the disk to main memory Process B has finished execution and is swapped out to disk Process A enters the main memory again to continue execution
14
Resident Routines OS is a collection of software routines
Resident routines (Rutin Tetap) The part of a program that must remain in memory at all times. Instructions and data that remain in memory can be accessed instantly. A routine that stays in the memory eg routines that control physical I/O and directly support application programs as they run One such program might be an anti-virus program. This has given rise to the term resident protection.
15
Transient Routines Transient routines (Rutin Sementara)
A routine that is stored on disk loaded as needed routines that format disks
16
Resident & transient routines
The operating system is a collection of software routines. Resident routines Transient routines Routines that directly support application programs as they run Stored on disk and read into memory only when needed Example: routine that control physical I/O Example: routine that formats disks
17
Fixed-partition memory management
The simplest approach to managing memory for multiple, concurrent programs. On many systems, multiple programs are loaded into memory and executed concurrently.
18
Fixed-partition memory management
Divides the available space into fixed-length partitions, each of which holds one program. Partition sizes are generally set when the system is initially started, so the memory allocation decision is made before the actual amount of space needed by a given program is known. Advantages: - Its major advantage is simplicity Disadvantages: Because the size of a partition must be big enough to hold the largest program that is likely to be loaded, fixed-partition memory management wastes space
19
Fixed-partition memory management
management divides the available space into fixed length partitions each of which holds one program. Fixed-partition memory management structure diagram
20
Virtual memory The word virtual means “not in actual fact.”
To the programmer or user, virtual memory acts just like real memory, but it isn’t real memory. Virtual memory is a model that holds space for the operating system and several application programs. The operating system and selected pages occupy real memory. Application programs are stored on an external paging device.
21
Segmentation With segmentation, programs are divided into variable size segments, instead of fixed size pages. Every logical address is formed of a segment name and an offset within that segment. In practice, segments are numbered. Programs are segmented automatically by compiler or assembler.
22
Segmentation For logical to physical address mapping, a segment table is used. When a logical address <s, d> is generated by processor: Base and limit values corresponding to segment s are determined using the segment table. The OS checks whether d is in the limit. ( 0=<limit) If so, then the physical address is calculated as ( based + d), and the memory is accessed.
23
Dynamic address translation.
Segmentation Dynamic address translation. To dynamically translate a segment address to an absolute address: 1) Break the address into segment and displacement portions 2) Use the segment number to find the segment’s absolute entry point address in a program segment table 3) Add the displacement to the entry point address.
24
Paging A program’s segments can vary in length.
Under paging, a program is broken into fixed-length pages. Page size is generally small (perhaps 2K to 4K), and chosen with hardware efficiency in mind. Like segments, a program’s pages are loaded into noncontiguous memory. Addresses consist of two parts , a page number in the high-order positions and a displacement in the low-order bits. Addresses are dynamically translated as the program runs. When an instruction is fetched, its base-plus displacement addresses are expanded to absolute addresses by hardware. Then the page’s base address is looked up in a program page table (like the segment table, maintained by the operating system) and added to the displacement.
25
Paging Advantages: 1. Address translation: each task has the same virtual address 2. Address translation: turns fragmented physical addresses into contiguous virtual addresses 3. Memory protection 4. Demand loading (prevents big load on CPU when a task first starts running, conserves memory) 5. Memory mapped files 6. Virtual memory swapping (lets system degrade gracefully when memory required exceeds RAM size)
26
Segmentation and Paging
1) With segmentation and paging, addresses are divided into a segment number, a page number within that segment, and a displacement within that page. 2) After the instruction control unit expands the relative address, dynamic address translation begins. 3) First, the program’s segment table is searched for the segment number, which yields the address of the segment’s page table. 4) The page table is then searched for the page’s base address, which is added to the displacement to get an absolute address.
27
Segmentation and Paging
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.