Download presentation
1
Subject: Operating System.
Memory Management. Subject: Operating System.
2
Memory management. In a multiprogramming system, memory must be subdivided to accommodate multiple processes. This task of subdivision is carried out dynamically by the OS and is called MEMORY MANAGEMENT.
3
REQUIREMENTS. Memory management should satisfy these five requirements: RELOCATION PROTECTION SHARING LOCAL ORGANIZATION PHYSICAL ORGANIZATION
4
RELOCATION. The processes are swapped in and swapped out.
It is very limiting to place the swapped out process in its original place. It is then relocated in a different area in the memory.
5
PROTECTION. The relocated process must be protected against the unwanted interference. Protection should be given by the processor rather than the OS.
6
SHARING. Any protection mechanism must allow several processor to access the same portion for main memory. Keeping protection in mind; Sharing should be restricted.
7
LOGICAL ORGANISATION Does not correspond to the way in which programs are constructed. Programs organized in modules.
8
PHYSICAL ORGANIZATION.
It is divided into two parts: Main Memory Secondary Memory Main Memory: fast, costly, volatile. Secondary Memory: cheap, slow but non volatile. Overlaying.
9
FIXED PARTITIONING. Divides main memory into a set of non-overlapping regions called partitions. Partitions can be of equal or unequal sizes.
11
EQUAL SIZE PARTITIONS Partitions are of equal size.
Process whose size is less than or equal to the partition size can be loaded into any available partition. If all partitions are full, the OS can swap a process out of any partition and load the new process
12
DIFFICULTIES. Process may be too big to fit into a partition.
Any program, no matter how small, occupies an entire partition causing INTERNAL FRAGMENTATION
13
UNEQUAL SIZE PARTITIONS
Partitions are not of equal size In Programs with large bytes, processes can be accommodated without OVERLAYS. Smaller partitions allow smaller programs to be accommodated with less internal fragmentation.
14
PLACEMENT ALGORITHM. Equal size partitions Unequal size partitions
15
EQUAL SIZE PARTITIONS. Process placement is trivial.
Process can be loaded in any partition available. If no partition is available, then one of the processes must be swapped out.
16
UNEQUAL SIZE PARTITIONS.
Two ways to assign processes to partition. Simplest way is to assign a single queue to each partition. Each process is assign to the smallest partition in which it will fit.
18
Internal fragmentation is minimized.
ADVANTAGES. Internal fragmentation is minimized.
19
Unequal size partitions
Another approach would be to employ a single queue for all partitions.
21
Provides a degree of flexibility.
Advantage: Provides a degree of flexibility.
22
Advantages of fixed partitioning.
Simple. Requires minimal operating system software.
23
Disadvantage of fixed partitioning
Limits the number of active processes Small jobs will not utilize partition space efficiently
24
Example IBM mainframe operating system, OS/MFT
(multiprogramming with a fixed number of tasks)
25
Dynamic Partitioning. Developed to overcome difficulties of fixed partitioning. Partitions are of variable length and number. Allocated exactly as much memory as it requires and no more.
27
Drawbacks. Method starts well, but eventually leads to holes.
Memory becomes fragmented. Thus, memory utilization declines. This is referred to as ‘external fragmentation’.
28
Ways to overcome…. Technique known as ‘compaction’.
OS shifts process so that all free memory is together in one block. Thus, an additional process can be loaded. Time consuming and waste of processor time.
29
Placement Algorithm. OS must decide which free block to allocate.
Three placements algorithms:- BEST FIT: Chooses block closest in size to request. FIRST FIT: First available block i.e large enough. NEXT FIT: Next available block i.e large enough.
32
FIRST FIT. Simplest but usually best and fast.
Litters the front end with small partition.
33
NEXT FIT. Frequently fragments a free block at the end.
Thus, compaction required.
34
Worst performance. Fragment left as small as possible.
BEST FIT. Worst performance. Fragment left as small as possible.
35
Replacement Algorithm.
When processes are blocked and no memory even after compaction. Replacement algorithm is used to avoid wasting processor time. OS will swap are process to make room for new process. OS must choose which process to replace.
36
BUDDY SYSTEM. It is a compromise to overcome the drawbacks of fixed and variable partitioning.
39
RELOCATION. A process may occupy different partitions during course of its life. Different regions in memory are allocated at different occasions. Thus, locations referred by the process is not fixed.
40
ADDRESSES. LOGICAL ADDRES.
Reference to a memory location independent of the assignment of the data to memory. RELATIVE ADDRESS. Address expressed as a location relative to some known point. PHYSICAL ADDRESS. Actual location in main memory.
41
PAGING. Partition memory into small fixed-size chunks and divide each process into the same size chunks. The chunks of a process are called pages and chunks of memory are called frames OS maintains a page table for each process.
43
Page Tables for Example
44
ADVANTAGES. Paging is similar to fixed partitioning, only difference is that the partitions here are smaller and a program might occupy more than one partition and they need not be contiguous. This approach solves many problems inherent partitioning.
45
DISADVANTAGES. Waste of space in memory due to internal fragmentation.
No external fragmentation.
46
SEGMENTATION. A User program and associated data can be subdivided into a number of segments. There is a maximum segment length. Since, segments are not equal, segmentation is similar to dynamic partitioning.
47
…contd… Addressing consists of two parts: a segment number and an offset. It makes use of segment table, for each process and for the list of free blocks of main memory.
48
ADVANTAGES. Segmentation provides a convenient way for organizing programs and data. Segmentation eliminates internal fragmentation.
49
DISADVANTAGES. Limitation of maximum segment size.
Segmentation suffers from external fragmentation.
50
VIRTUAL MEMORY MANAGEMENT.
Allows execution of processes that are not completely in memory. Separation of logical memory from physical memory.
51
VIRTUAL ADDRESS SPACE Refers to the logical (or virtual) view of how a process is stored in memory. Include holes known as SPARSE ADDRESS SPACE. Allows files and memory to be shared through page sharing.
52
VIRTUAL ADDRESS SPACE DIAGRAM: Max Heap Stack Data Code
53
DEMAND PAGING Virtual memory is implemented through demand paging.
A strategy to load pages only as they are needed. Here we make use of Lazy Swapper.
54
BASIC CONCEPT. The VALID-INVALID bit scheme is used.
Access to a page marked invalid causes a PAGE-FAULT TRAP.
55
PAGE REPLACEMENT The operating system, swaps out a process, freeing all its frames and reducing the level of multiprogramming. Page replacement can be done by: BASIC PAGE REPLACEMENT. FIFO PAGE REPLACEMENT. OPTIMAL PAGE REPLACEMENT. LRU PAGE REPLACEMENT
56
BASIC PAGE REPLACEMENT
Here, if no frame is free, we find one that is not currently being used and free it. It doubles the page-fault service time and increases the effective access time accordingly
57
FIFO PAGE REPLACEMENT First-in, First-out (FIFO) Algorithm.
Replace the page at the head of the queue. A bad replacement choice, increases the page-fault rate and slows process execution.
58
OPTIMAL PAGE REPLACEMENT
Replace the page that wil not be used for the longest period of time. It has the lowest page fault rate.
59
LRU PAGE REPLACEMENT Least-Recently-Used (LRU) algorithm.
It replaces the page that has been least recently used for the longest time.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.