OSY MSBTE CHP5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Chp 5 (14M)

Internal fragmentation Exernal fragmentation


If the process is larger than the If the process is removed, then
memory, then internal fragmentation occurs. external fragmentation occurs.
Fixed-sized memory blocks are Variable-sized memory blocks are
designated for internal fragmentation. designated for external fragmentation.
Internal fragmentation happens External fragmentation happens
when memory is split into fixed-sized When memory is split into variable
distributions. Size distributions.
The best-fit block is the solution to Paging, compaction, and
internal fragmentation. segmentation are solutions to
external fragmentation

Paging Segmentation
In paging, the program is divided into fixed or In segmentation, the program is
mounted size pages. divided into variable size segments.
For the paging operating system For segmentation compiler is
is accountable. accountable.
Page size is determined by Here, the segment size is given by
hardware. the user.
It is faster in comparison to Segmentation is slow.
segmentation.
Paging is invisible to the user. Segmentation is visible to the user.

For 6m

Bitmap Linked list


Bitmap memory management uses a bitmap Linked list memory management uses a
data structure linked list data structure
It is efficient for quickly checking the It may not be as efficient for quickly checking
availability of memory blocks the availability of memory blocks compared
to bitmap
It has more space overhead It has less space overhead
It is Fixed in size It is Dynamic in size
Memory is allocated at compile time Memory is allocated at run time
It is effecient for both Allocation and While allocation and deallocation operations
Deallocation can be efficient, they may require more
complex pointer manipulation compared to
bitmap
4. Explain free space management technique- Bitmap and linked list.
Ans. The system keeps tracks of the free disk blocks for
allocating space to files when they are created. The
system maintains a free space list which keeps track of
the disk blocks that are not allocated to some file or
directory. The free space list can be implemented
mainly as:
1. Bitmap or Bit vector:

• A Bitmap or Bit Vector is series or collection of bits


where each bit corresponds to a disk block.
• The bit can take two values: 0 and 1: 0 indicates that
the block is allocated and 1 indicates a free block.
• The given instance of disk blocks on the disk in
Figure 1 (where green blocks are allocated) can be
represented by a bitmap of 16 bits as:
0000111000000110.
2. Linked List:
In this approach, the free disk blocks are
linked together i.e. a free block contains a
pointer to the next free block. The block
number of the very first disk block is stored
at a separate location on disk and is also
cached in memory.
In Figure-2, the free space list head points to
Block 5 which points to Block 6, the next free
block and so on. The last free block would
contain a null pointer indicating the end of
free list. A drawback of this method is the I/O
required for free space list traversal.
5. Explain Partitioning and it’s types
Ans. Partitioning is a technique that divides a memory into multiple partitions.
These partitions can be of different size or same size.

Types of partitioning

• Fixed partitioning i.e. static partitioning


• Variable partitioning i.e. dynamic partitioning

Fixed Partitioning: Main memory is divided into multiple partitions of fixed


size at the time of system generation. A process may be loaded into a partition
of equal size or greater size. Partitions can be of equal size or unequal size.
Variable Partitioning: Refer to below ans 1st point

6. Describe Variable partitioning with help of example

• When a process enters in main memory, it is allocated exact size that is required by that
process. So in this method, partitions can vary in size depending on memory space
required by a process entering in main memory.
• The operating system keeps a table indicating which parts of memory are available and
which are occupied. Initially all memory is available for user programs and is
considered as one large block of available memory, a hole.
• When a job arrives and needs memory, we search for a hole large enough for this job. If
we find one, we allocate only as much as is needed, keeping the rest available to satisfy
future requests.

For example, assume 256K memory available and a resident monitor of 40K. This situation
leaves 216K for user programs
7. Explain Fixed size memory partitioning

Ans. Memory is divided into number of fixed size partitions, which is called as fixed or
static memory partitioning. Each partition contains exactly one process. The number of
programs to be executed depends on number of partitions. When the partition is free, a
selected process from the input queue is loaded into the free partition. When the process
terminates, the partition becomes available for another process. The operating system
keeps a table indicating parts of memory which are available and which are occupied.
Initially, all memory is available for user processes and it is considered as one large block
of available memory, a hole. When a process arrives, large enough to hole of memory is
allocated to the processes.
9. *Explain LRU page replacement algorithm for following reference string.
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 Calculate the page fault

Ans. LRU:

• The Least Recently Used (LRU) page replacement policy replaces the page that has not
been used for the longest period of time.
• LRU replacement associates with each page the time of that page's last use.
• When a page must be replaced, LRU chooses the page that has not been used for the
longest period of time.
• The LRU policy is often used as a page-replacement algorithm and is considered to be
good.
10. *Find out the total number of page faults using:

i. Least Recently used Page Replacement

ii. Optimal Page Replacement

Page replacement algorithms of memory management, if the

pages are coming in the order:

70120304230321201701
Extra
Explain system call implementation and explain how parameter passing
is done in system call

Ans.

Three general methods exist for passing parameters to the OS:

1. Parameters can be passed in registers.


2. When there are more parameters than registers, parameters can be stored
in a block and the block address can be passed as a parameter to a
register.
3. Parameters can also be pushed on or popped off the stack by the operating
system.

You might also like