Top Banner
© Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63, by Parul arora U1. 1 OPERATING SYSTEMS UNIT IV
110

OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

Jul 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63, by Parul arora U1.1

OPERATING SYSTEMSUNIT IV

Page 2: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.2

Learning Objective

Summarize the full range of considerations that support file systems. Compare and contrast different approaches to file organization, recognizing the strengths and weaknesses of each. Summarize how hardware developments have lead to changes in our priorities for the design and the management of file systems.

Page 3: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63, by Parul arora U1.3

Information Management

Page 4: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.4

What is Information Mgmt. ?

It deals with the storage and retrieval of informatione.g.. A library

Page 5: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.5

Functions of Information Mgmt.• Keeping track of all information in the system• Deciding the policy abt how &where the information is stored• Allocate the information resources• Deallocating the resources

Page 6: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.6

File System ?

Data Mgmt System

DataBase System

Page 7: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.7

• A file system is concerned only with the simple logical organization.

• A data management system performs some structuring but no interpretation of the information.

• A database management system is concerned with both the structure and interpretation of data items.

Page 8: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.8

Modules of Information Mgmt.

• Symbolic file system • Basic file system • Protection file system • Logical file system • Physical file system • Device strategies

These modules collectively called as File System

Page 9: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.9

Kernal of an O.S.

P Vmultiprogram

Momory Mgmt.Process Mgmt.Device Mgmt.

File System

Page 10: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.10

Kernal of an O.S.

P Vmultiprogram

Memory Mgmt.Process Mgmt.

Device Mgmt.File System

Symbolic file system Basic file system Protection file system Logical file system Physical file system Device strategies

Page 11: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.11

• A file system is intended to provide convenient management of both permanent (long term) & temporary (short term) information

• Provide users and O.S. with means for storing, retrieving and sharing information

Page 12: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.12

Hierarchical Model of a File System

Request

Symbolic file system module (SFS)

•Basic file system module (BFS)

Access control verification module (ACV)

Logical file system module (LFS)

Physical file system module (PFS)

Allocation strategy module Device strategy module

Initiate I/O

Device handler

1

2

3

4

5

9 6

7

8

Step -1

Step -2

Step -3

Step -4

Step -5

Step -6Device Mgmt

Page 13: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.13

Example

READ FILE(ETHEL) RECORD(4) INTO LOCATION(12000)

Page 14: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63, by Parul arora U1.14

File System Interface

Page 15: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.15

File-System Interface• File Concept• Access Methods• Directory Structure• File System Mounting• File Sharing• Protection

Page 16: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.16

File ConceptContiguous logical address space

Types: Data

numericcharacterbinary

Program

Page 17: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.17

File StructureNone - sequence of words, bytesSimple record structure

Lines Fixed lengthVariable length

Complex StructuresFormatted documentRelocatable load file

Can simulate last two with first method by inserting appropriatecontrol characters

Who decides:Operating systemProgram

Page 18: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.18

File AttributesName – only information kept in human-readable formType – needed for systems that support different typesLocation – pointer to file location on deviceSize – current file sizeProtection – controls who can do reading, writing, executingTime, date, and user identification – data for protection, security,

and usage monitoringInformation about files are kept in the directory structure, which

is maintained on the disk

Page 19: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.19

File OperationsCreateWriteReadfile seek – reposition within fileDeleteTruncateOpen(Fi) – search the directory structure on disk for entry Fi,

and move the content of entry to memoryClose (Fi) – move the content of entry Fi in memory to directory

structure on disk

Page 20: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.20

Open FilesSeveral pieces of data are needed to manage open files:

File pointer: pointer to last read/write location, per process that has the file openFile-open count: counter of number of times a file is open –to allow removal of data from open-file table when last processes closes itDisk location of the file: cache of data access informationAccess rights: per-process access mode information

Page 21: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.21

Open File LockingProvided by some operating systems and file systemsMediates access to a fileMandatory or advisory:

Mandatory – access is denied depending on locks held and requestedAdvisory – processes can find status of locks and decide what to do

Page 22: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.22

File Types – Name, Extension

Page 23: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.23

Access MethodsSequential Access

read nextwrite next resetno read after last write

(rewrite)Direct Access

read nwrite nposition to n

read nextwrite next

rewrite nn = relative block number

Page 24: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.24

Sequential-access File

Page 25: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.25

Simulation of Sequential Access on a Direct-access File

Page 26: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.26

Example of Index and Relative Files

Page 27: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.27

Directory StructureA collection of nodes containing information about all files

F 1 F 2F 3

F 4

F n

Directory

Files

Both the directory structure and the files reside on disk. Backups of these two structures are kept on tapes

Page 28: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.28

A Typical File-system Organization

Page 29: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.29

Information in a Device Directory

• Name • Type• Address • Current length• Maximum length• Date last accessed (for archival)• Date last updated (for dump)• Owner ID• Protection information (discuss later)

Page 30: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.30

Operations Performed on Directory

• Search for a file• Create a file• Delete a file• List a directory• Rename a file• Traverse the file system

Page 31: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.31

Organize the Directory (Logically) to Obtain

Efficiency – locating a file quicklyNaming – convenient to users

Two users can have same name for different filesThe same file can have several different names

Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …)

Page 32: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.32

Single-Level Directory

A single directory for all users

Naming problem

Grouping problem

Page 33: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.33

Two-Level Directory

Separate directory for each user

•Path name•Can have the same file name for different user•Efficient searching•No grouping capability

Page 34: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.34

Tree-Structured Directories

Page 35: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.35

Tree-Structured Directories• Efficient searching

• Grouping Capability

• Current directory (working directory)cd /spell/mail/progtype list

Page 36: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.36

Tree-Structured DirectoriesAbsolute or relative path nameCreating a new file is done in current directoryDelete a file

rm <file-name>Creating a new subdirectory is done in current directory

mkdir <dir-name>Example: if in current directory /mail

mkdir count

mail

prog copy prt exp count

Deleting “mail” ⇒ deleting the entire subtree rooted by “mail”

Page 37: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.37

Acyclic-Graph Directories

Have shared subdirectories and files

Page 38: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.38

Acyclic-Graph DirectoriesTwo different names (aliasing)

If dict deletes list ⇒ dangling pointerSolutions:

Backpointers, so we can delete all pointersVariable size records a problemBackpointers using a daisy chain organizationEntry-hold-count solution

Page 39: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.39

General Graph Directory

Page 40: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.40

General Graph DirectoryHow do we guarantee no cycles?

Allow only links to file not subdirectoriesGarbage collectionEvery time a new link is added use a cycle detectionalgorithm to determine whether it is OK

Page 41: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.41

File System Mounting• A file system must be mounted before it can be accessed• A unmounted file system (i.e. Fig. 11-11(b)) is mounted at a

mount point

Page 42: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.42

(a) Existing. (b) Unmounted Partition

Page 43: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.43

Mount Point

Page 44: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.44

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

Page 45: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.45

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

Page 46: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.46

File Sharing – Remote File Systems

• Uses networking to allow file system access between systemsManually via programs like FTPAutomatically, seamlessly using distributed file systemsSemi automatically via the world wide web

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

Server can serve multiple clientsClient and user-on-client identification is insecure or complicatedNFS is standard UNIX client-server file sharing protocolCIFS is standard Windows protocolStandard operating system file calls are translated into remote calls

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

Page 47: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.47

File Sharing – Failure ModesRemote file systems add new failure modes, due to network

failure, server failureRecovery from failure can involve state information about

status of each remote requestStateless protocols such as NFS include all information in each

request, allowing easy recovery but less security

Page 48: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.48

File Sharing – Consistency Semantics

Consistency semantics specify how multiple users are to access a shared file simultaneously

Similar to Ch 7 process synchronization algorithmsTend to be less complex due to disk I/O and network latency (for remote file systems

Andrew File System (AFS) implemented complex remote file sharing semanticsUnix file system (UFS) implements:

Writes to an open file visible immediately to other users of the same open fileSharing file pointer to allow multiple users to read and write concurrently

AFS has session semanticsWrites only visible to sessions starting after the file is closed

Page 49: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.49

ProtectionFile owner/creator should be able to control:

what can be doneby whom

Types of accessReadWriteExecuteAppendDeleteList

Page 50: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.50

Access Lists and GroupsMode of access: read, write, executeThree classes of users

RWXa) owner access 7 ⇒ 1 1 1

RWXb) group access 6 ⇒ 1 1 0

RWXc) public access 1 ⇒ 0 0 1

Ask manager to create a group (unique name), say G, and add some users to the group.

For a particular file (say game) or subdirectory, define an appropriate access.

owner group public

chmod 761 game

Page 51: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63, by Parul arora U1.51

File System Implementation

Page 52: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.52

File System Implementation• File System Structure• File System Implementation • Directory Implementation• Allocation Methods• Free-Space Management • Efficiency and Performance• Recovery• Log-Structured File Systems• NFS

Page 53: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.53

File-System Structure• File structure

Logical storage unitCollection of related information

• File system resides on secondary storage (disks).• File system organized into layers.• File control block – storage structure consisting of

information about a file.

Page 54: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.54

Layered File System

Page 55: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.55

A Typical File Control Block

Page 56: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.56

In-Memory File System Structures• The following figure illustrates the necessary file system

structures provided by the operating systems.

• Figure 12-3(a) refers to opening a file.

• Figure 12-3(b) refers to reading a file.

Page 57: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.57

In-Memory File System Structures

Page 58: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.58

Virtual File Systems• Virtual File Systems (VFS) provide an object-oriented way of

implementing file systems.

• VFS allows the same system call interface (the API) to be used for different types of file systems.

• The API is to the VFS interface, rather than any specific type of file system.

Page 59: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.59

Schematic View of Virtual File System

Page 60: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.60

Directory Implementation• Linear list of file names with pointer to the data blocks.

simple to programtime-consuming to execute

• Hash Table – linear list with hash data structure.decreases directory search timecollisions – situations where two file names hash to the same locationfixed size

Page 61: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.61

Allocation Methods• An allocation method refers to how disk blocks are allocated

for files:

• Contiguous allocation

• Linked allocation

• Indexed allocation

Page 62: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.62

Contiguous Allocation• Each file occupies a set of contiguous blocks on

the disk.

• Simple – only starting location (block #) and length (number of blocks) are required.

• Random access.

• Wasteful of space (dynamic storage-allocation problem).

• Files cannot grow.

Page 63: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.63

Contiguous Allocation of Disk Space

Page 64: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.64

Extent-Based Systems• Many newer file systems (I.e. Veritas File System) use a

modified contiguous allocation scheme.

• Extent-based file systems allocate disk blocks in extents.

• An extent is a contiguous block of disks. Extents are allocated for file allocation. A file consists of one or more extents.

Page 65: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.65

Linked AllocationEach file is a linked list of disk blocks: blocks may be scattered

anywhere on the disk.

pointerblock =

Page 66: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.66

Linked Allocation

Simple – need only starting addressFree-space management system – no waste of space No random accessMapping

Block to be accessed is the Qth block in the linked chain of blocks representing the file.Displacement into block = R + 1

File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.

LA/511Q

R

Page 67: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.67

Linked Allocation

Page 68: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.68

File-Allocation Table

Page 69: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.69

Indexed Allocation• Brings all pointers together into the index block.• Logical view.

index table

Page 70: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.70

Example of Indexed Allocation

Page 71: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.71

Indexed Allocation • Need index table• Random access• Dynamic access without external fragmentation,

but have overhead of index block.• Mapping from logical to physical in a file of

maximum size of 256K words and block size of 512 words. We need only 1 block for index table.

LA/512Q

R

Q = displacement into index tableR = displacement into block

Page 72: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.72

Indexed Allocation – Mapping• Mapping from logical to physical in a file of

unbounded length (block size of 512 words).• Linked scheme – Link blocks of index table (no limit

on size).

LA / (512 x 511)Q1

R1

Q1 = block of index tableR1 is used as follows:

R1 / 512Q2

R2

Q2 = displacement into block of index tableR2 displacement into block of file:

Page 73: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.73

Indexed Allocation – MappingTwo-level index (maximum file size is 5123)

LA / (512 x 512)Q1

R1

Q1 = displacement into outer-indexR1 is used as follows:

R1 / 512Q2

R2

Q2 = displacement into block of index tableR2 displacement into block of file:

Page 74: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.74

Indexed Allocation – Mapping

Μ

outer-index

index table file

Page 75: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.75

Combined Scheme: UNIX (4K bytes per block)

Page 76: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.76

Free-Space ManagementBit vector (n blocks)

…0 1 2 n-1

bit[i] = 678 0 ⇒ block[i] free

1 ⇒ block[i] occupied

Block number calculation

(number of bits per word) *(number of 0-value words) +offset of first 1 bit

Page 77: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.77

Free-Space ManagementBit map requires extra space. Example:

block size = 212 bytesdisk size = 230 bytes (1 gigabyte)n = 230/212 = 218 bits (or 32K bytes)

Easy to get contiguous files Linked list (free list)

Cannot get contiguous space easilyNo waste of space

Grouping Counting

Page 78: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.78

Free-Space ManagementNeed to protect:

Pointer to free listBit map

Must be kept on diskCopy in memory and disk may differ.Cannot allow for block[i] to have a situation where bit[i] = 1 in memory and bit[i] = 0 on disk.

Solution:Set bit[i] = 1 in disk.Allocate block[i]Set bit[i] = 1 in memory

Page 79: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.79

Linked Free Space List on Disk

Page 80: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.80

Efficiency and PerformanceEfficiency dependent on:

disk allocation and directory algorithmstypes of data kept in file’s directory entry

Performancedisk cache – separate section of main memory for frequently used blocksfree-behind and read-ahead – techniques to optimize sequential accessimprove PC performance by dedicating section of memory as virtual disk, or RAM disk.

Page 81: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.81

Various Disk-Caching Locations

Page 82: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.82

Page CacheA page cache caches pages rather than disk blocks using virtual

memory techniques.

Memory-mapped I/O uses a page cache.

Routine I/O through the file system uses the buffer (disk) cache.

This leads to the following figure.

Page 83: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.83

I/O Without a Unified Buffer Cache

Page 84: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.84

Unified Buffer CacheA unified buffer cache uses the same page cache to cache both

memory-mapped pages and ordinary file system I/O.

Page 85: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.85

I/O Using a Unified Buffer Cache

Page 86: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.86

RecoveryConsistency checking – compares data in directory structure

with data blocks on disk, and tries to fix inconsistencies.

Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape).

Recover lost file or disk by restoring data from backup.

Page 87: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.87

Log Structured File Systems• Log structured (or journaling) file systems record each update to

the file system as a transaction.

• All transactions are written to a log. A transaction is considered committed once it is written to the log. However, the file system may not yet be updated.

• The transactions in the log are asynchronously written to the file system. When the file system is modified, the transaction is removed from the log.

• If the file system crashes, all remaining transactions in the log must still be performed.

Page 88: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.88

The Sun Network File System (NFS)

• An implementation and a specification of a software system for accessing remote files across LANs (or WANs).

• The implementation is part of the Solaris and SunOS operating systems running on Sun workstations using an unreliable datagramprotocol (UDP/IP protocol and Ethernet.

Page 89: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.89

NFS• Interconnected workstations viewed as a set of independent

machines with independent file systems, which allows sharing among these file systems in a transparent manner.

A remote directory is mounted over a local file system directory. The mounted directory looks like an integral subtree of the local file system, replacing the subtree descending from the local directory.Specification of the remote directory for the mount operation is nontransparent; the host name of the remote directory has to be provided. Files in the remote directory can then be accessed in a transparent manner.Subject to access-rights accreditation, potentially any file system (or directory within a file system), can be mounted remotely on top of any local directory.

Page 90: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.90

NFS• NFS is designed to operate in a heterogeneous environment of

different machines, operating systems, and network architectures; the NFS specifications independent of these media.

• This independence is achieved through the use of RPC primitives built on top of an External Data Representation (XDR) protocol used between two implementation-independent interfaces.

• The NFS specification distinguishes between the services provided by a mount mechanism and the actual remote-file-access services.

Page 91: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.91

Three Independent File Systems

Page 92: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.92

Mounting in NFS

Mounts Cascading mounts

Page 93: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.93

NFS Mount ProtocolEstablishes initial logical connection between server and client.Mount operation includes name of remote directory to be mounted

and name of server machine storing it. Mount request is mapped to corresponding RPC and forwarded to mount server running on server machine. Export list – specifies local file systems that server exports for mounting, along with names of machines that are permitted to mount them.

Following a mount request that conforms to its export list, the server returns a file handle—a key for further accesses.

File handle – a file-system identifier, and an inode number to identify the mounted directory within the exported file system.

The mount operation changes only the user’s view and does not affect the server side.

Page 94: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.94

NFS Protocol• Provides a set of remote procedure calls for remote file operations.

The procedures support the following operations:searching for a file within a directory reading a set of directory entries manipulating links and directories accessing file attributesreading and writing files

• NFS servers are stateless; each request has to provide a full set of arguments.

• Modified data must be committed to the server’s disk before results are returned to the client (lose advantages of caching).

• The NFS protocol does not provide concurrency-control mechanisms.

Page 95: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.95

Three Major Layers of NFS Architecture

• UNIX file-system interface (based on the open, read, write, and close calls, and file descriptors).

• Virtual File System (VFS) layer – distinguishes local files from remote ones, and local files are further distinguished according to their file-system types.

The VFS activates file-system-specific operations to handle local requests according to their file-system types. Calls the NFS protocol procedures for remote requests.

• NFS service layer – bottom layer of the architecture; implements the NFS protocol.

Page 96: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.96

Schematic View of NFS Architecture

Page 97: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.97

NFS Path-Name Translation• Performed by breaking the path into component names and

performing a separate NFS lookup call for every pair of component name and directory vnode.

• To make lookup faster, a directory name lookup cache on the client’s side holds the vnodes for remote directory names.

Page 98: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.98

NFS Remote Operations• Nearly one-to-one correspondence between regular UNIX system

calls and the NFS protocol RPCs (except opening and closing files).

• NFS adheres to the remote-service paradigm, but employs buffering and caching techniques for the sake of performance.

• File-blocks cache – when a file is opened, the kernel checks with the remote server whether to fetch or revalidate the cached attributes. Cached file blocks are used only if the corresponding cached attributes are up to date.

• File-attribute cache – the attribute cache is updated whenever new attributes arrive from the server.

• Clients do not free delayed-write blocks until the server confirms that the data have been written to disk.

Page 99: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.99

Conclusion

In this section we have looked at how the file is put together. What are the components that must be present in the file and implicitly, what procedures must be in the Operating System in order to act on these files.We’ve also examined the internal structure of files.This gives a file system knowledge about how to get around in the file – especially how to find the required data block.

Page 100: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.100

Summary

• Three common strategies for primary memory management are Best fit, Worst fit, and First fit.

• The file manager is responsible for maintaining secondary storage.

• Storage blocks in secondary storage can be managed using one of at least three methods: Contiguous Allocation, Linked Allocation, and Indexed Allocation.

Page 101: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.101

Review Questions (OBJ)1. Which directory implementation is used in most Operating

System?a) Single level directory structureb) Two level directory structurec) Tree directory structured) Acyclic directory structure

2. _________ allocates the largest hole (free fragmant) available in the memory.

a) Best Fitb) Worst Fitc) First Fitd) None of the above

Page 102: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.102

Review Questions (OBJ)3. What is a shell ?

a) It is a hardware componentb) It is a command interpreterc) It is a part in compilerd) It is a tool in CPU scheduling

4. Which of the following file name extension suggests that the file is Backup copy of another file ?

a) TXTb) COMc) BASd) BAK

Page 103: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.103

Review Questions (OBJ)5. Which technique was introduced because a single job could

not keep both the CPU and the I/O devices busy?a) Time-sharingb) SPOOLingc) Preemptive schedulingd) Multiprogramming

6. Which directory implementation is used in most Operating System?

a) Single level directory structureb) Two level directory structurec) Tree directory structured) Acyclic directory structure

Page 104: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.104

Review Questions (OBJ)7. A tree sturctured file directory systema) allows easy storage and retrieval of file namesb) is a much debated unecessary featurec) is not essential when we have millions of filesd) none of the above

8. Which is not an Operating System ?a) Windows 95b) MS-DOSc) Windows 3.1d) Windows 2000

Page 105: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.105

Review Questions (OBJ)9. Which file system does DOS typically use ?a) FAT16b) FAT32c) NTFSd) WNFS

10. Which file system does Windows 95 typically use ?a) FAT16b) FAT32c) NTFSd) LMFS

Page 106: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.106

Review Questions (Short)

1. Explain the purpose of the open and close operations2. What is a file?3. What is a sequential file?4. List disadvantages of using a single directory5. List operations to be performed on directories.6. What is the MFD? UFD? How are they related?7. What advantages are there to this two-level directory?8. What disadvantages are there to this two-level directory?9. How do we overcome the disadvantages of the two-level

directory?10. What is a file path name? 11. Why would we want a subdirectory in our account?

Page 107: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.107

Review Questions (Short)12. List three ways of allocating storage, and give advantages of

each.13. What is contiguous allocation?14. .What main difficulty occurs with contiguous allocation?15. What is a “hole” in contiguous allocation method?16. Explain first-fit, best-fit, and worst-fit methods of allocating

space for contiguous files .17. Can linked allocation be used for direct-access fies? 18. What is indexed allocation?.19. Rank the allocation methods on speed. 20. List four ways a system could use to determine which sectors

are free. Give advantages of each way.

Page 108: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.108

Review Questions (Long)1. Consider a file system where a file can be deleted and its disk space

reclaimed while links to that file still exist. What problems may occur if a new file is created in the same storage area or with the same absolute path name? How can these problems be avoided?

2. Give an example of an application in which data in a ?le should be accessed in the following order:SequentiallyRandomly

3. Consider a ?le system on a disk that has both logical and physical block sizes of 512 bytes. Assume that the information about each?le is already in memory. For each of the three allocation strategies (contiguous, linked, and indexed), answer these questions:a.) How is the logical-to-physical address mapping accomplished in this system? (For the indexed allocation, assume that a file is always less than 512 blocks long.)b.) If we are currently at logical block 10 (the last block accessed was block 10) and want to access logical block 4, how many physical blocks must be read from the disk?

Page 109: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.109

Review Questions (Long)2. The Cigarette-Smokers Problem. Consider a system with three

smoker processes and one agent process. Each smoker continuouslyrolls a cigarette and then smokes it. But to roll and smoke a cigarette, the smoker needs three ingredients: tobacco, paper, and matches. One of the smoker processes has paper, another has tobacco, and the third has matches. The agent has an in?nite supply of all three materials. The agent places two of the ingredients on the table. The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredients, and the cycle repeats. Write a program to synchronize the agent and the smokers.

3. Explain the differences in the degree to which the following scheduling algorithms discriminate in favor of short processes:a. FCFSb. RRc. Multilevel feedback queues

4. What are the advantages and disadvantages of using implementation to compare various scheduling algorithms?

Page 110: OPERATING SYSTEMS UNIT IVbvicam.in/sites/default/files/subject/LearningMannuals/os4.pdf · ©Bharati Vidyapeeth’s Institute of Computer Applications and Management , New Delhi-63,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management,, New Delhi-63, by Parul Arora. U1.110

Recommended reading

• Silbersachatz and Galvin, “Operating System Concepts” Peason,6th Ed.,2001

• Madnick E., Donovan J., ”Operating System”: TMH, 2001

• "Operating Systems” Tannenbaum PHI, 4th Edition, 2000