2. Virtual Memory
• Virtual memory is implemented by demand paging.
• VM is the separation of user logical memory from physical memory.
• Demand paging can be described as a memory management technique that is
used in operating systems to improve memory usage and system
performance.
• Demand paging is a technique used in virtual memory systems where pages
enter main memory only when requested or needed by the CPU.
• In demand paging, the operating system loads only the necessary pages of a
program into memory at runtime, instead of loading the entire program into
memory at the start.
• A page fault occurred when the program needed to access a page that is not
currently in memory. The operating system then loads the required pages
from the disk into memory and updates the page tables accordingly. This
process is transparent to the running program and it continues to run as if the
page had always been in memory.
3. Why Virtual Memory?
• Most programs do not need to keep everything resident to run
efficiently:
• Most error-handling routines are used rarely.
• Arrays and other data structures have morestorage allocated than
they usually need.
• Certain program features are rarely used.
4. Concept of Demand Page…..
• Demand paging follows that pages should only be brought into memory if
the executing process demands them. This is often referred to as lazy
evaluation as only those pages demanded by the process are swapped
from secondary storage to main memory.
• Contrast this to pure swapping, where all memory for a process is swapped
from secondary storage to main memory during the process startup.
• Commonly, to achieve this process a page table implementation is used.
The page table maps logical memory to physical memory.
• The page table uses a bitwise operator to mark if a page is valid or invalid.
A valid page is one that currently resides in main memory.
• An invalid page is one that currently resides in secondary memory.
6. Benefits of Virtual Memory
• Efficient use of physical memory: Query paging allows for more efficient
use because only the necessary pages are loaded into memory at any given
time.
• Support for larger programs: Programs can be larger than the physical
memory available on the system because only the necessary pages will be
loaded into memory.
• Faster program start: Because only part of a program is initially loaded into
memory, programs can start faster than if the entire program were loaded
at once.
• Reduce memory usage: Query paging can help reduce the amount of
memory a program needs, which can improve system performance by
reducing the amount of disk I/O required.
7. Drawbacks of the Demand Paging
• Page Fault Overload: The process of swapping pages between
memory and disk can cause a performance overhead, especially if the
program frequently accesses pages that are not currently in memory.
• Degraded performance: If a program frequently accesses pages that
are not currently in memory, the system spends a lot of time
swapping out pages, which degrades performance.
• Fragmentation: Query paging can cause physical memory
fragmentation, degrading system performance over time.
• Complexity: Implementing query paging in an operating system can
be complex, requiring complex algorithms and data structures to
manage page tables and swap space.
8. Introduction to File Systems
• All file systems consist of structures necessary for storing and
managing data. These structures typically include an operating system
boot record, directories, and files.
• Functions of a File System:
• Tracking allocated and free space
• Maintaining directories and file names
• Tracking where each file is physically stored on the disk
9. Definition:
• Computers use particular kinds of file systems to store and organize
data on media, such as a hard drive, the CDs, DVDs, and BDs in an
optical drive or on a flash drive.
• Any place that a PC stores data is employing the use of some type of
file system. A file system can be thought of as an index or database
containing the physical location of every piece of data on a hard drive.
• A file system is setup on a drive during a format. See How To Format a
Hard Drive for more information.
10. File System
• File system is the part of the operating system which is responsible for file
management.
• It provides a mechanism to store the data and access to the file contents
including data and programs.
• Some Operating systems treats everything as a file for example Ubuntu.
• The File system takes care of the following issues
• File Structure: The task of the file system is to maintain an optimal file
structure.
• Recovering Free space: if file gets deleted its space is recovered
• disk space assignment to the files : Using disk scheduling algorithm
• tracking data location: We need to keep track of all the blocks on which
the part of the files reside.
11. Types of File Systems
• FAT File System
• NTFS File System
• Disk file systems
• Flash file systems
• Tape file systems
• Database file systems
• Transactional file systems
• Network file systems
• work file systems
• Shared disk file systems
• Special file systems
• Device file systems
12. FAT File System
• FAT12 - The initial version of the FAT file system, FAT12 was
introduced in 1977, even before MS-DOS, and was the primary file
system for Microsoft operating systems up to MS-DOS 4.0. FAT12
supports drive sizes up to 32MB.
• FAT16 - The second implementation of FAT was FAT16, introduced in
1988. FAT16 was the primary file system for MS-DOS 4.0 up to
Windows 95. FAT16 supports drive sizes up to 2GB.
• FAT32 - FAT32 is the latest version of the FAT file system. It was
introduced in 1996 for Windows 95 OSR2 users and was the primary
file system for consumer Windows versions through Windows ME.
FAT32 supports drive sizes up to 8TB.
13. NTFS File System
• Definition: New Technology File System (NTFS) is a file system that
was introduced by Microsoft in 1993 with Windows NT 3.1. NTFS
supports hard drive sizes up to 256TB.
• NTFS is the primary file system used in Microsoft's Windows 7,
Windows Vista, Windows XP, Windows 2000 and Windows NT
operating systems.
• The Windows Server line of operating systems also primarily use
NTFS.
• The File Allocation Table (FAT) file system was the primary file system
in Microsoft's older operating systems but it is still supported today
along with NTFS.
14. Disk file systems
• A disk file system takes advantages of the ability of disk storage media to
randomly address data in a short amount of time.
• Additional considerations include the speed of accessing data following that
initially requested and the anticipation that the following data may also be
requested. This permits multiple users (or processes) access to various data on
the disk without regard to the sequential location of the data.
• Examples include FAT (FAT12, FAT16, FAT32), exFAT, NTFS, HFS and HFS+, HPFS,
UFS, ext2, ext3, ext4, XFS, btrfs, ISO 9660, Files11, Veritas File System, VMFS,
ZFS, ReiserFS and UDF.
• Some disk file systems are journaling file systems or versioning file systems.
• Optical discs
• ISO 9660 and Universal Disk Format (UDF) are two common formats that target Compact
Discs, DVDs and Blu-ray discs. Mount Rainier is an extension to UDF supported by Linux 2.6
series and Windows Vista that facilitates rewriting to DVDs.
15. Flash file system
• A flash file system considers the special abilities, performance and
restrictions of flash memory devices.
• Frequently a disk file system can use a flash memory device as the
underlying storage media but it is much better to use a file system
specifically designed for a flash device.
16. Tape file systems
• A tape file system is a file system and tape format designed to store files on
tape in a self-describing form.
• Magnetic tapes are sequential storage media with significantly longer
random data access times than disks, posing challenges to the creation and
efficient management of a general-purpose file system.
• In a disk file system there is typically a master file directory, and a map of
used and free data regions.
• Any file additions, changes, or removals require updating the directory and
the used/free maps.
• Random access to data regions is measured in milliseconds so this system
works well for disks.
• Tape requires linear motion to wind and unwind potentially very long reels
of media. This tape motion may take several seconds to several minutes to
move the read/write head from one end of the tape to the other
17. Database file systems
• Another concept for file management is the idea of a database-based
file system. Instead of, or in addition to, hierarchical structured
management, files are identified by their characteristics, like type of
file, topic, author, or similar rich metadata.
18. Network file systems
• A network file system is a file system that acts as a client for a remote
file access protocol, providing access to files on a server.
• Examples of network file systems include clients for the NFS, AFS,
SMBprotocols, and file-system-like clients for FTP and WebDAV
19. Shared disk file systems
• A shared disk file system is one in which a number of machines
(usually servers) all have access to the same external disk subsystem
(usually a SAN).
• The file system arbitrates access to that subsystem, preventing write
collisions.
• Examples include GFS2 from Red Hat, GPFS from IBM, SFS from
DataPlow, CXFS from SGIand StorNext from Quantum Corporation.
20. Special file systems
• A special file system presents non-file elements of an operating
system as files so they can be acted on using file system APIs.
• This is most commonly done in Unix-like operating systems, but
devices are given file names in some non-Unix-like operating systems
as well.
21. Device file systems
• A device file system represents I/O devices and pseudo-devices as
files, called device files.
• Examples in Unix-like systems include devfs and, in Linux 2.6 systems,
udev.
• In non-Unix-like systems, such as TOPS-10 and other operating
systems influenced by it, where the full filename or pathname of a file
can include a device prefix, devices other than those containing file
systems are referred to by a device prefix specifying the device,
without anything following it.
22. Flat file systems
• In a flat file system, there are no subdirectories.
• When floppy disk media was first available this type of file system was
adequate due to the relatively small amount of data space available.
CP/M machines featured a flat file system, where files could be
assigned to one of 16 user areas and generic file operations narrowed
to work on one instead of defaulting to work on all of them. These
user areas were no more than special attributes associated with the
files, that is, it was not necessary to define specific quota for each of
these areas and files could be added to groups for as long as there
was still free storage space on the disk..
23. Aspects of file systems
• Space management
• File systems allocate space in a granular manner, usually multiple
physical units on the device. The file system is responsible for
organizing files and directories, and keeping track of which areas of
the media belong to which file and which are not being used. For
example, in Apple DOS of the early 1980s, 256-byte sectors on 140
kilobyte floppy disk used a track/sector map.
24. Filenames
• A filename (or file name) is used to identify a storage location in the
file system. Most file systems have restrictions on the length of
filenames. In some file systems, filenames are not case sensitive (i.e.,
filenames such as FOO and foo refer to the same file); in others,
filenames are case sensitive (i.e., the names FOO and foo refer to two
separate files).
25. Directories
• File systems typically have directories (also called folders) which allow the user to
group files into separate collections. This may be implemented by associating the
file name with an index in a table of contents or an inode in a Unix-like file
system.
• Directory structures may be flat (i.e. linear), or allow hierarchies where
directories may contain subdirectories.
• The first file system to support arbitrary hierarchies of directories was used in the
Multics operating system.
• The native file systems of Unix-like systems also support arbitrary directory
hierarchies, as do, for example, Apple's Hierarchical File System, and its successor
HFS+ in classic Mac OS (HFS+ is still used in Mac OS X), the FAT file system in MS-
DOS 2.0 and later and Microsoft Windows, the NTFS file system in the Windows
NT family of operating systems, and the ODS-2 (On-Disk Structure-2) and higher
levels of the Files-11 file system in OpenVMS.
26. File System Structure
• File System provide efficient access to the
disk by allowing data to be stored, located
and retrieved in a convenient way.
• A file System must be able to store the
file, locate the file and retrieve the file.
• Most of the Operating Systems use
layering approach for every task including
file systems.
• Every layer of the file system is
responsible for some activities.
• The image shown below, elaborates how
the file system is divided in different
layers, and also the functionality of each
layer.
27. File System Structure…
• When an application program asks for a file, the first request is directed to
the logical file system. The logical file system contains the Meta data of the
file and directory structure.
• If the application program doesn't have the required permissions of the file
then this layer will throw an error. Logical file systems also verify the path
to the file.
• Generally, files are divided into various logical blocks.
• Files are to be stored in the hard disk and to be retrieved from the hard
disk. Hard disk is divided into various tracks and sectors.
• Therefore, in order to store and retrieve the files, the logical blocks need to
be mapped to physical blocks. This mapping is done by File organization
module. It is also responsible for free space management.
28. File System Structure…
• Once File organization module decided which physical block the
application program needs, it passes this information to basic file
system.
• The basic file system is responsible for issuing the commands to I/O
control in order to fetch those blocks.
• I/O controls contain the codes by using which it can access hard disk.
These codes are known as device drivers.
• I/O controls are also responsible for handling interrupts.