Lecture1 Memory Mgmt

download Lecture1 Memory Mgmt

of 49

Transcript of Lecture1 Memory Mgmt

  • 8/12/2019 Lecture1 Memory Mgmt

    1/49

    CHAROTAR INSTITUTE OF TECHNOLOGY

    DEPARTMENT OF INFORMATION TECHNOLOGY

    IT502OPERATING SYSTEM

    DEPARTMENT OF INFORMATION TECHNOLOGY

    CHAROTAR INSTITUTE OF TECHNOLOGY, CHANGA

  • 8/12/2019 Lecture1 Memory Mgmt

    2/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 2

    Topics for discussion

    Functions Of Operating System

    What is Memory Manager?

    The notion Of Address Space

    Approaches Of Memory Management

    Memory management without Swapping Or Paging

    Multiprogramming and memory usageModeling Multiprogramming

    Multiprogramming with Fixed Partitions

    Relocation and Protection

    Swapping

  • 8/12/2019 Lecture1 Memory Mgmt

    3/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 3

    Major Functions Of Operating System

    Processor management

    That is assignment of processor to different tasksbeing performed by the computer system.

    Memory management

    allocation of main memory and other storage areas tothe system programmes as well as user programmesand data.

    File management,

    that is, the storage of file of various storage devices toanother. It also allows all files to be easily changedand modified through the use of text editors or someother files manipulation routines.

  • 8/12/2019 Lecture1 Memory Mgmt

    4/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 4

    Input/output management,

    that is, co-ordination and assignment of the differentoutput and input device while one or more programmesare being executed.

    Interpretation of commands and instructions

    Establishment and enforcement of a priority system.That is, it determines and maintains the order in whichjobs are to be executed in the computer system.

    In this session we are suppose to study the detailsabout Memory mangement.

  • 8/12/2019 Lecture1 Memory Mgmt

    5/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 5

    So the first question that arises in our minds is:

    What do you mean by memory?

    Memory refers to storage needed by the kernel, theother components of the operating system and theuser programs.

    Ideally memory should beLarge, Fast and Non volatile

    Then next question arises is:

    What are the different types of memory devicesinherent in computer?

    Cache, Main memory(RAM),ROM and hard Disks

  • 8/12/2019 Lecture1 Memory Mgmt

    6/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 6

    How do different types of memory differ?

    In practice, a memory hierarchy is used

    1. Small amount of fast, expensive memory cache

    2. Some medium-speed, medium price main memory

    3. Gigabytes of slow, cheap disk storage

    Now there is need of a controllling structure

    to decide what memory to use and when?

    This decision is taken by memory manager

    Definition: Thepart of operating system that manages

    memory is called the memory manager. It handles the memory hierarchy

  • 8/12/2019 Lecture1 Memory Mgmt

    7/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 73/30/2014Page 7

    The notion of address space

    An address space is set of addresses that a process

    can use to address memory.

    Before executing any process cpu has to allocateaddress space to it

    For example, consider changa campus as memory and

    out department as a process CITC building has been allocated some space. Our

    address space is then Building 1.

  • 8/12/2019 Lecture1 Memory Mgmt

    8/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 8

    Memory Management Approaches

    Monoprogramming vs. Multiprogramming

    One program at a time vs. many

    Fixed program set vs. swapping

    When programs are switched out, save state to disk

    Complete image vs. partial image (Virtual memory)

    Some program images wont fit in available RAM

    Modern systems are all multi-programmed, withswapping and virtual memory

    But first we will learn monoprogramming without

    swapping or paging

  • 8/12/2019 Lecture1 Memory Mgmt

    9/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 9

    The simplest possible scheme is to have just one

    process in memory at a time, and allow that processto use all memory

    The user loads entire memory with a program from adisk or a tape and it takes over whole machine

    The actual technique used on microcomputers is asfollows

    The memory is divided between operating system anda single user process

    The location may of memory may be at different

    places as shown in figure in next slide

    Monoprogramming without swapping or paging

  • 8/12/2019 Lecture1 Memory Mgmt

    10/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 1010

    Fig. 3-1. Three simple ways of organizing memory-

    Simplest Memory Management

    Monoprogramming without Swapping or Paging

  • 8/12/2019 Lecture1 Memory Mgmt

    11/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 11

    Uses And Advantages

    Uses:-

    It was used for

    1. (a) was used for mainframes and minicomputers

    2. (b) is used on some palmtop computers andembedded systems

    3. (c) was used by early PCs running MS-DOS whereBIOS device drivers were in ROM

    Advantages:-

    1. The sole advantage of monoprogramming is itssimplicity.

    2. There is very little software required in the operatingsystem for memory management in this case. Theprocessis given all of the available memory which itcan then use as it desires.

  • 8/12/2019 Lecture1 Memory Mgmt

    12/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 12

    Disadvantages of Monoprogramming

    Monoprogramming is wasteful of CPU and memory

    resources.

    While the program is performing I/O, the CPU is idle

    Likewise, if the program doesnt use all of theavailable memory, the excess memory in the system

    is wasted. Programs cannot be larger than the size of the

    available physical memory.

  • 8/12/2019 Lecture1 Memory Mgmt

    13/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 13

    Multiprogramming

    In multiprogramming, as you know, multiple

    processes are conceptually executed at the

    same time.

    This permits the operating system to switch the CPUto a different process when the current process

    becomes blocked. The difficulty, of course, is that memory is

    now required to hold the images of each

    process that is a candidate for execution.

  • 8/12/2019 Lecture1 Memory Mgmt

    14/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 14

    Multiprogramming Questions

    How effective is multiprogramming? That is,

    how much more quickly can we execute processesthan if monoprogramming was used?

    How much higher is CPU utilization?

    How much higher is memory utilization?

    Is the additional memory needed to supportmultiple processes worth the cost?

  • 8/12/2019 Lecture1 Memory Mgmt

    15/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 15

    Answering the Questions

    One obvious way to answer these questions

    is to run the same set of processes using

    monoprogramming, and then again usingmultiprogramming.

    Unfortunately, this is a very expensive and time

    consuming procedure, and only answers thequestions relative to the particular set of

    processes used in the analysis.

    A more general, mathematical analysis is

    desired.

  • 8/12/2019 Lecture1 Memory Mgmt

    16/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 16

    A Simple Multiprogramming Model

    Assumption 1: there are n processes in

    memory.

    Assumption 2: the probability of each process beingblocked is p (a number between 0 and 1).

    Assumption 3: all processes are independent.

    Assumption 4: there is one CPU, and weignore time spent doing context switches.

  • 8/12/2019 Lecture1 Memory Mgmt

    17/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 17

    Performing the Analysis

    We know the CPU will be idle only if all n

    processes are blocked.

    Using elementary probability, we know that

    probability of all processes being blocked is Pn

    and probability of at least one process not being

    blocked is 1 pn (CPU utilization) The chart on the next slide illustrates CPU

    utilization for three different processing

    blocking probabilities: 20%, 50% and 80%.

  • 8/12/2019 Lecture1 Memory Mgmt

    18/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 18

    Modeling Multiprogramming

    CPU utilization as a function of number of processes in memory

    Degree of multiprogramming

    Suppose that a process spends a fraction pof its time waiting for I/O to completewith nprocesses in memory at a time, the probability that all n processes are waitingfor I/O is p^n. CPU utilization is 1 - p^n (with the assumption that the processes areindependent)

    Modeling Multiprogramming

  • 8/12/2019 Lecture1 Memory Mgmt

    19/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 19

    Memory Management in Multiprogramming

    With monoprogramming, memory management

    was simple: give all available memory to the job

    and were done.

    With multiprogramming we must decide how to

    arrange the memory images of the jobs in the

    primary memory of the system. With n jobsthere are n! orderings of the jobs in memory.

    We must also consider what happens when one

    of the jobs finishes can we fit a new job in the

    memory space just vacated?

  • 8/12/2019 Lecture1 Memory Mgmt

    20/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 20

    Fixed Partitioning of Memory

    One approach to the problem is to

    statically divide the available memory into a numberof regions or partitions, the size of each is fixed.

    This approach is used in the IBM OS/MFT(Multiprogramming with a Fixed number of Tasks)operating system (now largely obsolete).

  • 8/12/2019 Lecture1 Memory Mgmt

    21/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 2121

    Multiprogramming with Fixed Partitions

    Fixed memory partitions

    separate input queues for each partition

    single input queue (strategies: next convenient process,biggest process, dont ignore more than k times)

  • 8/12/2019 Lecture1 Memory Mgmt

    22/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 22

    Multiprogramming with Fixed Tasks Characteristics

    Each job (with a maximum memory requirement

    specified) is run in the smallest partition that meetsits needs.

    Underutilization of memory can still occur, since job

    sizes dont necessarily exactly match partition sizes.

    Suppose we have two 40K partitions and a 39K and a41K job. Only the 39K job can be run, wasting 41K.

    Concern must be given to memory protection, since a

    program in one partition might access memory in

    another partition by accident or on purpose

  • 8/12/2019 Lecture1 Memory Mgmt

    23/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 23

    MFT: Advantages & Disadvantages

    Advantages:

    1. Easy to implement.

    2. Provides multiprogramming (faster turnaround,

    better use of memory and CPU).

    Disadvantages:

    1. Scheduling can be complicated.2. Memory resources are still wasted.

    3. Job size is limited to physical memory size.

    4. Extra hardware and/or software are needed for

    relocation and protection.

  • 8/12/2019 Lecture1 Memory Mgmt

    24/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 2424

    Relocation and Protection

    Cannot be sure where program will be loaded in memory address locations of variables, code routines cannot be

    absolute(address translation: during loading/calculation duringexecution)

    must keep a program out of other processes partitions

  • 8/12/2019 Lecture1 Memory Mgmt

    25/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 25

    Program Relocation

    To achieve relocation, OS/MFT modifies the addresses

    in instructions when the program is loaded to reflectthe location at which the program is loaded.

    Consider figure A, if a program has entered partition 2and user wants to access 100thinstruction in theprogram then, instruction needs to be modified as

    200K +100

    This has some obvious disadvantages:

    1)the loader must mark those instructions needingmodification, and

    2)the modification of the program is a slowoperation

  • 8/12/2019 Lecture1 Memory Mgmt

    26/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 26

    Another Relocation Technique

    Another approach to relocation causes a base

    register (one of the processors general

    registers) to be set to the address at which the

    program is loaded. The instructions in the

    program then use this base register much like an

    index register when they need to referencememory.

    Disadvantages:

    Additional base registers are required The approachconsumes one of the CPUs registers.

    A program cant be easily relocated once its started.

  • 8/12/2019 Lecture1 Memory Mgmt

    27/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 27

    Perhaps the most general approach is to have a

    special CPU register used as the base register,

    and automatically add its content to every memoryaddress generated by a program.

    This register is protected from modification by

    the user and is, in fact, entirely transparent tothe users program.

    The users program now appears to be

    addressing a region of memory starting at location 0.

    Still Another Technique

  • 8/12/2019 Lecture1 Memory Mgmt

    28/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 28

    Protection

    In the IBM 360 (and others), each 2K block of

    memory has a special 4-bit code called the lock.

    Only kernel-mode programs can alter these

    locks. All locks for each programs memory are set

    to a unique value.

    A four-bit key is present in the Program StatusWord (PSW, essentially a register containing the

    next instruction address, interrupt enable

    information, and so forth). The PSW is included in

    the context of a process.

  • 8/12/2019 Lecture1 Memory Mgmt

    29/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 29

    Another Memory Protection Scheme

    Another approach is to add a special limits

    register (which can only be set by supervisor modeprograms).

    Every memory address is automatically comparedwith the limits register.

    If the limits register is exceeded, a fault is generated.

    Both these approaches require special dedicatedhardware, and that implies additional expense inproducing the CPU.

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    30/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 30

    Swapping

    Swapping is used to increase the probability that a

    process will be ready to run when the CPU wouldotherwise be idle.

    That is ,swap in process from hard disk to mainmemory

    Most of the time there is not enough memory to hold

    all the active processes at the same time So in that case we need to take that process back to

    hard disk. That is swap out process from mainmemory to hard disk

    Thus, Swapping is the process of moving a process

    between primary memory and secondary storage A process can be swappedtemporarily out of memory

    to a backing store, and then brought back intomemory for continued execution. There is specialplace allocated for this is hard disk called swap area

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    31/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 313/30/2014Page 31

    Schematic View of Swapping

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    32/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 32

    Variable Partition Sizes

    Fig. 3-4. Memory allocation changes as processes come into memory

    leave memory

    Shaded regions are unused memory

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    33/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 33

    Compaction

    Collectively the holes in memory might be large

    enough to allow the execution of another program. But our programs assume they will be executed in a

    contiguous region of memory and the holes are notcontiguous

    When Swapping creates multiple holes in thememory, it is possible to coalesce all the holes intoone larger hole that might be useful. This technique ismemory compaction

    To perform compaction we must move the occupied

    memory regions together to eliminate the holes. Compaction can consume a great deal of CPU time

    during which processes cannot execute.

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    34/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 34

    Advantages & Disadvantages

    Advantages:

    1. Conceptually there is less wasted memory.

    2. Scheduling is possibly simpler.

    Disadvantages:1. Memory resources are still wasted (holes).

    2. Job sizes are still tied to the physical memory size.

    3. Extra hardware and/or software are still needed for

    relocation and protection.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    35/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 35

    How Much Memory To Allocate?

    Many programs have predictable memory

    requirements: code, static data, and stack (to holdprocedure invocation records and local variables)

    However many others have less predictable memoryrequirements due to the need for dynamic storageallocation and recursion.

    As a result, processes may request execution in apartition larger than their static memoryrequirements.

    To solve this problem a traditional memory layout is

    used which is as shown in the next slide

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    36/49

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 36

    To accommodate the potential for growth ofsome parts of a programs memory allocation,the code, static data and heap (dynamic data)

    in the lowest part of a memory region.

    The stack is then placed at the high end of theregion, growing downward as items are pushed,and contracting upward as items are removed.

    This allows expansion of the heap and the stackinto the region between them.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    37/49

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 37

    Keeping Track of Memory Usage

    There are three common ways to keep track of

    memory usage:1. bit maps

    2. linked lists

    The basic goals of each system are to:1. identify all used/unused memory regions,

    2. support the allocation of a contiguous unused regionof n blocks of memory, and

    3. handle the deallocation (freeing) of a region ofmemory.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    38/49

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 3838

    Memory Management with Bit Maps or chained lists

    Fig. 3-6a. Part of memory with 5 processes, 3 holes tick marks show allocation units

    shaded regions are free

    Fig. 3-6b. Corresponding bit map

    Fig. 3-6c. Same information as a list

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    39/49

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 39

    Memory Management with Bit map

    We can use an array of bits is used to keep track

    of used/unused blocks of memory.

    We might choose to set a bit to 0 to represent anunused block, with a 1 bit meaning the block is used.

    The size of the block has several effects.

    Larger block sizes yield smaller bitmaps, but memorywill likely be wasted in the last block for each region.

    Smaller block sizes result in larger bitmaps, but less

    waste will occur in a regions last block.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    40/49

    IT502 OPERATING SYSTEMS INFORMATION TECHNOLOGY

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 40

    Bit Maps: Advantages & Disadvantages

    Advantages:

    1. easy to implement,

    2. easy to deallocate a region, and the size is dependentonly on the size of primary memory and of a block.

    Disadvantage:

    1. it is difficult to allocate a contiguous region of size n,since the system must search the bit map for nconsecutive 0 bits.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    41/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 41 41

    Memory Management with Linked Lists

    Fig. 3-7. Four neighbor combinations for the terminatingprocess X

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    42/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 42

    Linked Lists

    Using linked lists, the basic idea is to maintain a list of

    free regions of contiguous memory and another list ofoccupied regions.

    The free list can be ordered in various ways:

    1. ordered by memory address,

    2. or ordered by size. We explicitly assume region sizes are random.

    Allocation of a region can be done using any of manydifferent algorithms (e.g. first fit, best fit, next fit,worst fit, quick fit).

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    43/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 43

    First Fit Allocation Technique

    Scan the free list from its head, looking for the first

    unused region that satisfies (is larger than or equal

    to the size of) the allocation request.

    Then split that region, if necessary, to produce oneregion of the requested size. other unused) region

    back on the list. Advantages:

    1. Easy to implement

    2. Fast

    Disadvantage:

    1. Produces lots of very small holes

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    44/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 44

    Next Fit Allocation Technique

    This approach is similar to the first fit algorithm, but

    each new search for an acceptable unused memoryregion begins (in the list) where the last one ended.

    Disadvantage

    1. In simulations, it produces slightly worse results than

    first fit.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    45/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 45

    Best Fit Allocation Technique

    Scan the entire list to locate the smallest unused

    region that will accommodate the request formemory.

    Disadvantages:

    1. it is potentially very slow; or

    2. requires the list to be ordered on size; whichcomplicates the deallocation algorithm.

    Expected advantage:

    It should reduce the number of holes.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    46/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 46

    Worst Fit Allocation Technique

    Pick the largest available hole to satisfy each

    allocation, splitting it as necessary into the allocatedregion and a new hole.

    Disadvantage:

    1. Simulation results for this technique are negative.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    47/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 47

    Quick Fit Allocation Technique

    Maintain multiple lists, each list having holes of the

    same common sizes. To satisfy an allocation request, look first in the list

    with the appropriate size, then in lists of largerunused regions.

    Disadvantage:

    1. Deallocation is costly, since all lists must be scannedto find neighboring unused regions.

    Advantage:

    1. Allocation is fast.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    48/49

    Classified e-Material Copyrights Charotar Institute of Technology, Changa 483/30/2014Page 48

    Fragmentation

    External Fragmentationtotal memory space exists to

    satisfy a request, but it is not contiguous. Internal Fragmentationallocated memory may be

    slightly larger than requested memory; this size differenceis memory internal to a partition, but not being used.

    Reduce external fragmentation by compaction

    Shuffle memory contents to place all free memorytogether in one large block.

    Compaction is possible onlyif relocation is dynamic,and is done at execution time.

    IT502-OPERATING SYSTEMS INFORMATION TECHNOLOGY

  • 8/12/2019 Lecture1 Memory Mgmt

    49/49

    Related Exam Based Questions

    Monoprogramming without Swapping or Paging [4]

    Explain Swapping in detail [6] Define

    1. Memory Manager

    2. Compaction

    3. Degree of MultiProgrmming Explain Relocation problem in detail [2]