0% found this document useful (0 votes)
10 views51 pages

Os Unit4-1

Uploaded by

kannayogesh865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views51 pages

Os Unit4-1

Uploaded by

kannayogesh865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

UNIT – IV

STORAGE MANAGEMENT AND FILE

SYSTEMS INTERFACE
STORAGE MANAGEMENT:

• Storage management is the process of


• Controlling and coordinating computer memory
• Assigning portions called blocks to various
running programs to optimize overall system
performance(Allocating Process)
• Freeing it for reuse when no longer needed
(Deallocating process)
• Motivation
• Keep several processes in memory to improve a
systems performance
– Allows Multiprogramming

• Instruction execution cycle


All computers have an instruction execution
cycle.
A basic instruction execution cycle can be
broken down into the following steps:
– Fetch cycle
– Execute cycle
Steps in Fetch/ExecuteCycle
• The instruction is fetched from memory addressed by PC
(Program Counter)
• PC is advanced to address the next instruction
• Instruction Decoder decodes the instruction held in IR
• Instruction is then executed.
• Results are stored back to the memory
Memory Space Protection:
Memory protection is away to control memory
access rights on a computer.
SWAPPING:
• Swapping refers to moving entire processes in
and out of main memory.
• RoundRobin CPU-Scheduling Algorithm
-Each process is provided a fix time to execute called time
slice or quantum

• Priority-based scheduling algorithms


-Each process is assigned apriority. Process with highest
priority is to be executed first and so on
-Processes with same priority are executed on first come
first serve basis
CONTIGUOUS MEMORY AL LOCATION
• Memory Allocation
Memory Allocation is the process of assigning
blocks of memory on request for the program
execution.
• Memory Allocation mechanism
• Operating system uses the following memory
allocation mechanism.
• Single-partition allocation
• Multiple-partition allocation
Single-partition allocation:
• The operating system resides in the low
memory. The remaining memory treated as a
single partition.
• This single partition is available for userspace.
• Only one job can be loaded in this user space
Multiple-partition allocation:
• Main memory is divided into a number of fixed-
sized partitions where each partition should
contain only one process.
• When a partition is free, a process is selected
from the input queue and is loaded into the free
partition.
Memory Allocation:

1.Fixed Partitions Scheme:


• In this type of allocation, main memory is divided
into a number of fixed-sized partitions where each
partition should contain only one process.
2.Variable Partition Scheme:
• Partitions are of variable length and
number .Process is allocated exactly as much
memory as required
Methods to assign processes to partitions:
• There are two ways to assign processes to
partitions
• Use multiple queues
-Assign each process to the smallest partition within which
it will fit ,by using the scheduling queues
• Use single queue
– In this method, only one ready queue is present for
scheduling the jobs for all the blocks irrespective of
size.
Dynamic Allocation Placement Algorithms
• The following algorithm is used to decide which
free block to allocate to a program

• First fit
» Allocate the first hole that is big enough;
» Process is placed in the first hole it can fit in.

• Best fit
» Allocate the smallest hole that is big.

• Worst-fit
» Allocate the largest hole, also search entire list.
Fragmentation:
• Fragmentation occurs when a system contains total
free memory to satisfy any request.

• Internal fragmentation
-Internal fragmentation is that the allocated memory
may be slightly larger than requested memory.
• External fragmentation
-External fragmentation is done when the total
memory space exists to satisfy a request.
PAGING:
• Paging is a memory-management scheme that
permits the logical address space of a process
can be non contiguous.
• Pages
• Logical memory is also divided into blocks of
same size called pages
Memory Allocation in Paging
SEGMENTATION:
• Segmentation is the Memory Management
Scheme that supports user view of memory.
• Logical address space is the collection of
segments
• Segmentation Architecture
– Segments are numbered and referred to by a segment
number ,thus a logical address consists of a tuple:

Segment Number Offset


Segmentation with Paging
• In Segmented Paging, the main memory is divided
into variable size segments which are further
divided into fixed size pages

• Segment Number → It points to the appropriate


Segment Number.
• Page Number → It Points to the exact page within
the segment
• Page Offset → Used as an offset within the page
frame
VIRTUALMEMORY
• Virtual memory is a technique that allows
execution of processes that are not
completely in the physical memory.
DEMAND PAGING:
• A demand-paging system is a paging system with swapping.
• Itinitially loads pages only into memory (not the entire process) as
they are needed.
• Page Fault:
Page Fault is an interrupt that a rises upon a
reference to a page that is not in main memory.
• Handling a Page Fault
Performance of Demand Paging
• The performance of Demand Paging is measured by
computing the effective access time for a demand paged
memory.
• Let p be probability of a Page Fault Rate 0 p 1.
• if p = 0 no page faults
• if p = 1,every reference is a fault
Effective Access Time (EAT)
• The Effective Access Time (EAT) is computed as follows
EAT= (1 –p) x memory access +p x page fault time.
Page fault time = page fault over head
+[swap page out ]
+swap page in
+restart over head)
PAGE REPLACEMENT
• Page replacement algorithm decides which
memory pages to be paged out to disk
(Swapout) to allocate memory for another
page
• Types of Page replacement algorithm
• FIFO Page Replacement
• Optimal Page Replacement
• LRU Page Replacement
• FIFOPageReplacement
• FIFO stands for First-InFirst-Out
• Simple page replacement algorithm
• Chooses the―oldest page in the memory
Referencestring: 1, 2,3,4, 1,2, 5,1,2,3, 4, 5

• Numberof page fault=9


• The page fault occurs for the given reference string is shown below

Faultrate=9/12 = 0.75
Optimal Page Replacement:
• Replace the page that will not be used for the
longest period of time in the future
Reference string: 1, 2,3,4, 1,2, 5,1,2,3, 4, 5

Number of page fault=7

Fault rate=7/12 = 0.58


LRU Page Replacement:
Replace the page that has not been used for the
longest period of time in past.
Reference string: 1, 2,3,4, 1,2, 5,1,2,3, 4, 5

Number of page fault=10

Fault rate=10/12 = 0.83


THRASHING
• If a process does not have enough pages ,the
page-fault rate is very high. This leads to high
paging activity called Thrashing.
• A process is spending more time paging than
executing.
Working-Set Model
• The working set strategy is a variable-allocation
method with local scope based on the
assumption of locality of references.

• The pages used by a process within a window


of time are called its working set.
• Page-Fault Frequency
• It establish―acceptable ‖page-fault rate
– If actual rate too low, process loses frame
– If actual rate too high, process gains frame

Page-Fault Frequency (PFF) Strategy


– Define an upper bound U and lower bound L for page fault rates.
– Allocate more frames to a process if fault rate is higher than U.
– Allocate less frames if fault rate is less than L.
FILE CONCEPTS
• Named collection of related information that is recorded on
secondary storage such as magnetic disks, magnetic tapes and
optical disks.
• File System
• File system is the mechanism used to control how
data and program is stored and retrieved.
• File system consists of the following parts
– files
– directory structure
– Partitions
File Types
• indicate the internal structure of the file.
The Different types of file
– Data files
– Text file
– Source file
– Object file
– Executable file
• File Attributes
– Name
– Identifier
– Type
– Location
– Size
– Production
– Time, date, and user identification

File operations
– Create
– Write
– Read
– Reposition
– Delete
– Truncate
• Types of Lock
• Shared lock
A shared lock is a reader lock in that several
processes can acquire the lock concurrently.
• Exclusive lock
An exclusive lock behaves like a writer lock; only
one process at a time can acquire such a lock.
FILE ACCESS METHODS
• Sequential access
- information in the file is processed in order
• Direct/Random access
- accessing the records directly
• Indexed sequential access
- index is created for each file which contains
pointers to various blocks
DIRECTORY STRUCTURE
• Directory is a file system structure in which
computer files are stored.
• Directory is also known as folders.
• Files are organized by storing related files in the
same directory.
Logical Structure schemes:
• The different schemes for defining the logical
structure of a directory are
» Single-Level Directory
» Two-level Directory
» Tree-Structured Directories
» Acyclic-Graph Directories
» General Graph Directory

1. Single-Level Directory
• All files are contained in the same directory
Two-level Directory:
• One master file directory(MFD)
• Each user has their own UFD
Tree-Structured Directories
• An extension to the two-tiered directory structure It is extended to
a tree of arbitrary height
• Allows users to create their own subdirectories and to organize
their files
A cyclic-Graph Directories:
– Generalization of the tree-structured directory scheme
FILE SYSTEM MOUNTING
• Mounting is a process by which the
operating system makes files and directories on a
storage device .
• File must be opened before it is used, a file system
must be mounted before it can be available to
processes on the system.
FILE PROTECTION
The information stored in a computer system must
be kept safe from
• Physical damage (reliability)
• Improper access (protection)
Types of Access
– Read: Read from the file
– Write:Write or rewrite the file
– Execute:Load the file into memory and execute it
– Append:Write new information at the end of the file
– Delete: Delete the file and free its space for possible reuse
– List:List the name and attributes of the file

You might also like