0% found this document useful (0 votes)
40 views

Operating Systems: Syed Mansoor Sarwar

Uploaded by

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

Operating Systems: Syed Mansoor Sarwar

Uploaded by

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

Operating

Systems
Lecture 42
Syed Mansoor Sarwar
Agenda for Today
 Review of the previous lecture
 File Concept
 File Types
 File Operations
 Access Methods
 Directories
 Directory Operations
 Directory Structure
14 September 2019 © Copyright Virtual University of
Pakistan
Review of Lecture 41
 Thrashing
 The Working Set Model
 Page Fault Frequency Model
 Other Considerations
 Prepaging
 Page size
 Program structure
 Examples
14 September 2019 © Copyright Virtual University of
Pakistan
The File Concept
 Contiguous logical address
space
 Types:
 Data
Numeric
Character
Binary
 Program
14 September 2019 © Copyright Virtual University of
Pakistan
File Structure
 None - sequence of words, bytes
 Simple record structure
 Lines
 Fixed length
 Variable length

 Complex Structures
 Formatted document
 Relocatable load file
14 September 2019 © Copyright Virtual University of
Pakistan
File Structure
 Who decides?
Operating system
DOS/Windows
.exe, .com, .bat, …
Program
UNIX/Linux

14 September 2019 © Copyright Virtual University of


Pakistan
File Attributes
 Name
 Type
 Location
 Size
 Protection
 Owner
 Time and date created
 Time and date last updated
 Read/write pointer value
14 September 2019 © Copyright Virtual University of
Pakistan
Where are Attributes
Stored
 In the directory structure, as
part of the directory entry for
the file—DOS, Windows
 In a separate data structure;
in UNIX/Linux this structure is
known as the inode for the
file
14 September 2019 © Copyright Virtual University of
Pakistan
Directory Entry
 DOS/Windows: File name and
attributes
 UNIX/Linux: File name and inode
number.
 Name can be up to 255 characters in
BSD UNIX compliant systems
 Inode number—used to access file’s
inode
14 September 2019 © Copyright Virtual University of
Pakistan
Directory Entry
 DOS/Windows

File Date … FAT


Name Pointer

 UNIX/Linux

File Name Inode


Number
14 September 2019 © Copyright Virtual University of
Pakistan
File Operations
 Create — creat
 Open — open
 Write — write
 Read — read
 Reposition within file — lseek
 Delete — unlink
 Truncate — creat with a special flag
 Close — close
14 September 2019 © Copyright Virtual University of
Pakistan
File Types: Extensions

14 September 2019 © Copyright Virtual University of


Pakistan
File Types in UNIX
 Ordinary file
 Directory
 Block-special file
 Character-special file
 Link file (ln –s)
 FIFO (mkfifo or mknod)
 Socket (in BSD-compliant
systems—socket)
14 September 2019 © Copyright Virtual University of
Pakistan
File Operations
 Sequential Access
 read next
 write next
 reset
 Direct Access
 read n (n = relative block number)
 write n
 position to n
read next
write
14 September 2019
next
© Copyright Virtual University of
Pakistan
Sequential Access
File

14 September 2019 © Copyright Virtual University of


Pakistan
Sequential Access on
a Direct Access File

14 September 2019 © Copyright Virtual University of


Pakistan
Directory Structure
 A collection of directory entries

Directory

Files and F1 F2 F4 Fn
F3
Directories
14 September 2019 © Copyright Virtual University of
Pakistan
Directory Operations
 Create — mkdir
 Open — opendir
 Read — readdir
 Rewind — rewinddir
 Close — closedir
 Delete — rmdir
 Change Directory — cd
 List — ls
 Search
14 September 2019 © Copyright Virtual University of
Pakistan
Directory Structure
 Efficient
Searching
 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, …)
14 September 2019 © Copyright Virtual University of
Pakistan
Single-Level Directory
 A single directory for all users.

 Naming problem
 Grouping problem
14 September 2019 © Copyright Virtual University of
Pakistan
Two-Level Directory
 Separate directory for each user

 Path name
 Can have the same file name for different user
 Efficient searching
 No grouping
14 September 2019 capability
© Copyright Virtual University of
Pakistan
Tree Directory

14 September 2019 © Copyright Virtual University of


Pakistan
Tree Directory
 Efficient searching
 Grouping Capability
 Root directory
 Home directory
 Current/working directory
14 September 2019 © Copyright Virtual University of
Pakistan
Tree Directory
 UNIX / Linux
 Root directory (/)
 Home directory
 ~, $HOME, $home
 cd ~
 cd
 Current/working directory (.)
 pwd
 Parent of Current Directory (..)
14 September 2019 © Copyright Virtual University of
Pakistan
Tree Directory
 Absolute Pathname
 Starts with the root directory
 /etc, /bin, /usr/bin,
/etc/passwd,
/home/students/ibraheem
 Relative Pathname
 Starts with the current directory or a
user’s home directory
 ~/courses/cs604, ./a.out
14 September 2019 © Copyright Virtual University of
Pakistan
Recap of Lecture
 File Concept
 File Types
 File Operations
 Access Methods
 Directories
 Directory Operations
 Directory Structure
14 September 2019 © Copyright Virtual University of
Pakistan
Operating
Systems
Lecture 42
Syed Mansoor Sarwar

14 September 2019 © Copyright Virtual University of


Pakistan

You might also like