Operating systems
1 / 66

Operating Systems - PowerPoint PPT Presentation

  • Uploaded on

Operating Systems. Prof. Navneet Goyal Department of Computer Science & Information Systems BITS, Pilani. Topics. Files Access Methods Directory Structure File System mounting File sharing Protection. Files. Most visible aspect of an OS

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about ' Operating Systems' - aneko

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Operating systems

Operating Systems

Prof. Navneet Goyal

Department of Computer Science & Information Systems

BITS, Pilani


  • Files

  • Access Methods

  • Directory Structure

  • File System mounting

  • File sharing

  • Protection


  • Most visible aspect of an OS

  • Files provide mechanism for online storage of and access to both data and programs of the OS and all the users

  • A typical file system consists of:

    • Files (each storing related data)

    • Metadata (directory structure)


  • Information can be stored on various storage media

  • OS provides a uniform logical view of information storage

  • OS abstracts from the physical properties of its storage devices to define a logical storage unit, FILE!

  • Files are mapped by the OS onto physical devices


  • File is a named collection of related information that is recorded on a secondary storage

  • Smallest allotment of logical secondary storage

  • Data cannot be written on secondary storage unless it is written on a file

  • File is a very general concept

File system
File System

  • Collection of Files

    File contains related data

  • Directory Structure

    Organizes & provides information about all files in the system

  • Partitions

    Separates physically or logically large collections of directories

File attributes
File Attributes

  • Name

  • Identifier (generally a number)

  • Type

  • Location (device: location)

  • Size (bytes, words or blocks)

  • Protection (rwx)

  • Time, date, & user identification

    (creation, last modification, last use)

File operations
File Operations

  • File is an ADT

  • Must define operations on files

  • File Operations

    • Creating

    • Writing

    • Reading

    • Repositioning within file (file seek)

    • Deleting

    • Truncating

  • OS provides system calls for each operation

File operations1
File Operations

  • Creating

    • Space in the file system must be found for the file

    • Entry for the new file must be made in the directory

  • Writing a file

    • System call specifying the name of the file and the information to be written. System keeps a pointer to the location where the next write is to take place

File operations2
File Operations

  • Reading

    • System call specifying the name of the file and where the next block of the file should be put.

    • A process is either reading from a file or writing to a file, the current operation location can be kept as per process “current-file-position” pointer

    • Both read and write ops. Use this same pointer to save space & system complexity

  • Repositioning within a file

    • Current file position pointer is repositioned to a given value. Need not involve an actual I/O. Also called as file seek

File operations3
File Operations

  • Deleting a file

    • Search the directory for the names file, release all file space, and erase the directory entry

  • Truncating a file

    • Erases the content of a file but keeps its attributes

File operations4
File Operations

  • Other Operations

    • Appending

    • Renaming

    • Copy

    • Move

  • open() system call

    • Must be invoked before a file is used

    • Open file table is maintained by OS

  • Create & Delete work with closed files

Access methods
Access Methods

  • Files contain information

  • Information must be accessed and read into memory for processing

  • Information in files can be accessed in several ways

  • Most systems provide only one method

  • Some systems provide many

Access methods1
Access Methods

  • Choosing the right one for a particular application is a typical design issue

  • Sequential Access

  • Direct Access

  • Indexes (IBMs ISAM)

Directory structure
Directory Structure

  • Stores information about all files

  • Resides on secondary storage

  • Contains file’s name & Identifier

  • Identifier in turn locates other file attributes

  • More than 1KB of information for each file

  • Directory structure size in MBs

  • Backups of files and directory structure kept on tapes

Directory structure1
Directory Structure

  • Disks are split into one or more partitions

  • Minidisks or Volumes

  • Each disk contains atleast one partition

  • Partitions can be larger than a disk

  • Partitions are “virtual disks”

  • Partition maintains information about files in “Device Directory”

Directory structure2
Directory Structure

A collection of nodes containing information about all files.

Both the directory structure and the files reside on disk

Backups of these two structures are kept on tapes

Information in a directory
Information in a Directory

  • Name

  • Type

  • Address

  • Current length

  • Maximum length

  • Date last accessed

  • Date last updated

  • Owner ID

  • Protection information

Directory operations
Directory Operations

  • Search for a file

  • Create a file

  • Delete a file

  • List a directory

  • Rename a file

  • Traverse the file system

How to Organize a Directory?


  • Efficiency – locating a file quickly

  • Naming – convenient to users

  • Two users can have same name for different files

  • The same file can have several different names

  • Grouping – logical grouping of files by properties

    (e.g. all Java programs, all games, …)

    Schemes for defining the logical structure of a directory:

  • Single level directory

  • Two level directory

  • Tree structured directory

  • Acyclic graph directory

  • General graph directory

Single level directory
Single-Level Directory

Single directory for all users: easy to support & understand

  • All files in a single directory

  • Naming problem (unique names)

  • Grouping Problem

Two level directory
Two-Level Directory

Separate directory for each user

  • each user has its own UFD (user file dir)

  • UFDs have similar structure

  • When a user logs in, the MFD (master file dir) is searched

  • MFD is indexed by user name or accnt no.

  • Each entry in MFD points to a UFD

  • User name & a file name define a path name

Two level directory1
Two-Level Directory

Separate directory for each user

  • When a user refers to a file, only his own UFD is searched

  • File names can be shared among users

  • Solves the name-collision problem

  • Disadvantages?

  • System files?

Two level directory2
Two-Level Directory

Separate directory for each user

  • File name would be searched in the current UFD only

  • Copy system files to each UFD!!

  • Standard solution: special user directory is defined to contain system files: say user 0

  • Search procedure?

Tree structured directory1
Tree-Structured Directory

  • Generalization of two-level directory (with arbitrary height)

  • Each user has a current directory (working directory)

    • Can change current directory via cd command or system call

  • Path names can be absolute or relative


  • Creating a new file is done in current directory

  • Delete a file

    • rm <file-name>

  • Creating a new subdirectory is done in current directory

    • mkdir <dir-name>


  • Efficient searching

  • Grouping Capability

Acyclic graph directory
Acyclic-Graph Directory

  • 2 programmers working on a joint project

  • File pertaining to project stored in a subdirectory of each user

  • Shared subdirectory!

  • Tree structure prohibits the sharing of files or directories!

  • A shared file or dir will exist in the file system in two or more places at once

  • AGD allows files & dirs to be shared

Acyclic graph directory1
Acyclic-Graph Directory

  • Shared file is not the same as two copies of the file

  • With a shared file, only one actual file exists

  • Shared subdirectories

  • Files created in this SD will auto. appear in all the shared SDs

  • LINKS!!

Acyclic graph directory2
Acyclic-Graph Directory

  • A link is a pointer to another file or subdirectory

  • Link may be implemented as an absolute or a relative path

  • When a reference to a file is made

    • directory is searched

    • If directory entry is marked as a link, name of the real file is included in the link information

    • Link is resolved using the path name to locate the real file

  • Tree traversal is used to traverse directories

Acyclic graph directory3
Acyclic-Graph Directory


  • Duplicate all information in both the sharing directories

  • Original & copy indistinguishable

  • Maintaining consistency when a file is modified is a problem

Acyclic graph directory4
Acyclic-Graph Directory


  • AGD is more flexible but more complex

  • File may have multiple absolute path names. Different file names refer to the same file!!

Acyclic graph directory5
Acyclic-Graph Directory

  • Have shared subdirectories

  • and files using acyclic graph

  • Two different names exist

  • (aliasing problem)

  • If ‘dict’ deletes list ⇒

  • dangling pointer (UNIX case)

  • Solutions:

    • Preserve file until all references to it are deleted

      • Reference count solution

General graph directory
General-Graph Directory

  • Add links to an existing tree structured directory, resulting in a simple graph structure

  • Want to avoid searching any shared components twice

  • Reference count solution does not hold due to self-reference

  • => use garbage collection

  • Acyclic structure is much easier to work with

  • How do we guarantee no cycle?

    • Allow links only to file not subdirectories

    • Every time a new link is added use a cycle detection algorithm

General graph directory1
General Graph Directory

  • Problem with AGD: ensuring no cycles

  • Allowing users to create files & directories to an existing tree structure preserves the tree-structured nature

  • But, when we allow links to be added to an existing tree structure, the tree structure is destroyed, resulting in a simple graph structure

File system mounting
File System Mounting

  • Just as a file must be opened before it is used, a file system must be mounted before it can be accessed

  • Procedure?

File system mounting1
File System Mounting


  • The OS is given the name of the device, and the location within the file structure at which to attach the file system (or mount point)

  • Typically, a mount point is an empty directory

  • The OS verifies that the device contains a valid file system by asking the device driver to read the directory

  • Finally, the OS notes in its directory structure that a file system is mounted at the specified mount point; This scheme enables the OS to traverse its directory structure, switching among file systems as appropriate

File sharing
File Sharing

  • Sharing of files on multi-user systems is desirable

  • Sharing may be done through a protection scheme

  • On distributed systems, files may be shared across a network

  • Network File System (NFS) is a common distributed file-sharing method

File sharing multiple users
File Sharing: Multiple Users

  • User IDs identify users, allowing permissions and protections to be per-user

  • Group IDs allow users to be in groups, permitting group access rights

File sharing remote file systems
File Sharing: Remote File Systems

  • Uses networking to allow file system access between systems

    • Manually via programs like FTP

    • Automatically, seamlessly using distributed file systems

    • Semi automatically via the world wide web

  • Client-server model allows clients to mount remote file systems from servers

    • Server can serve multiple clients

    • Client and user-on-client identification is insecure or complicated

    • NFS is standard UNIX client-server file sharing protocol

    • CIFS is standard Windows protocol

    • Standard operating system file calls are translated into remote calls

  • Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing


  • File owner/creator should be able to control:

    • what can be done

    • by whom

  • Types of access

    • Read

    • Write

    • Execute

    • Append

    • Delete

    • List

Access control list acl
Access Control List (ACL)

  • Various users may need different types of access to a file or directory

  • The most general scheme is to associate with each file & directory an access-control list (ACL) specifying the user name & the types of access allowed for each user

  • Advantages

    • Enable complex access methodology

  • Disadvantages

    • Constructing such a list may be a tedious and unrewarding task, especially if we do not know in advance the list of users in the system

    • The directory entry, previously of fixed size, now needs to be of variable size, resulting in more complicated space management

Access lists groups unix
Access Lists & Groups (UNIX)

  • Various users may need different types of access to a file or directory

  • The most general scheme is to associate with each file & directory an access-control list (ACL) specifying the user name & the types of access allowed for each user

  • Advantages

    • Enable complex access methodology

  • Disadvantages

    • Constructing such a list may be a tedious and unrewarding task, especially if we do not know in advance the list of users in the system

    • The directory entry, previously of fixed size, now needs to be of variable size, resulting in more complicated space management

Disk partition
Disk partition



inode list

data blocks

  • Boot area

    • Code required to bootstrap the operating system

  • Superblock

    • Attributes and metadata of the file system itself

  • inode list

    • a linear array of inodes

  • data blocks

    • data blocks for files and directories


  • It contains

    • Size in blocks of the file system

    • Size in blocks of the inode list

    • Number of free blocks and inodes

    • Free block list(Partial)

    • Free inode list(Partial)

  • The kernel reads the superblock and stores it in memory when mounting the file system


  • Each file has an inode associated with it

  • Inode contains metadata for file

  • on-disk inode refers to inode stored in disk within the inode list

  • in-core inode refers to inode stored in memory when a file is open


  • Kernel maintains file information in a structure called inode.

    • Creation, modification time stamps

    • Ownership, file size etc.

  • Commonly used INODE information can be found by using ls command

On disk inode






File type, permissions



Owner UID



Owner GID



Size in bytes



Array of block addresses




On-disk inode

  • The size of on-disk inode is 64 bytes

In core inode
In-core Inode

  • It contains all the fields of on-disk inode, and some additional fields, such as

    • The status of the in-core inode (whether the inode is locked, which process is waiting, etc.)

    • The logical device number containing the file

    • The inode number of the file

    • Pointers to keep the inode on a free list

    • Pointers to keep the inode on a hash queue.

    • Block number of last block read.