Module 5 Complete
Module 5 Complete
MODULE 5
INTRODUCTION TO FILE CONCEPTS
• File is a contiguous logical address space
• Basic Types:
• data
• numeric
• character
• binary
• Program
• Other types such as text file, source file, executable file, etc
FILE ATTRIBUTES
• Name – only information kept in human-readable form
• Identifier – unique tag (number) identifies file within file system
• Type – needed for systems that support different types
• Location – pointer to file location on device
• Size – current file size
• Protection – controls who can do reading, writing, executing
• Time, Date, and User Identification – data for protection, security, and
usage monitoring
• Information about files are kept in the directory structure, which is
maintained on the disk.
• File control Block(FCB) stores all the information about a file in a
directory structure.
FILE OPERATIONS
• CREATE: make a new file • APPEND: like write, but only at
the end of the file
• DELETE: remove an existing file
• SEEK: move the “current”
• OPEN: prepare a file to be
pointer elsewhere in the file
accessed
• GET ATTRIBUTES: retrieve
• CLOSE: indicate that a file is no
attribute information
longer being accessed
• SET ATTRIBUTES: modify
• READ: get data from a file
attribute information
• WRITE: put data to a file
• RENAME: change a file’s name
4
FILE TYPES – NAME, EXTENSION
FILE-SYSTEM STRUCTURE
• File structure
• logical storage unit
• collection of related information
• File system resides on secondary storage (disks)
• provided user interface to storage, mapping logical to physical
• provides efficient and convenient access to disk by allowing data to be
stored, located retrieved easily
• disk provides in-place rewrite and random access
• i/o transfers performed in blocks of sectors (usually 512 bytes)
• File control block – storage structure consisting of information about a file
• Device driver controls the physical device
FILE SHARING
• TYPES OF ACCESS
• READ
• WRITE
• EXECUTE
• APPEND
• DELETE
• LIST
FILE ACCESS METHODS
• This is the simplest access method where file is processed in order, one
record after the other.
• A read operation read next reads the next record of the file and
advances the file pointer.
• The write operation write next appends the record to the end of the file.
• These files can only be reset to the beginning of the file.
• It is used in batch processing applications.
read next
write next
reset
no read after last write
(rewrite)
SEQUENTIAL ACCESS
3. INDEXED ALLOCATION
• Each file has its own INDEX BLOCK(S) of pointers to its
data blocks
• Indexed allocation solves the problem of scattered blocks by
bringing all the pointers together in one location called index
block.
• ith entry in the index block points to the ith block of the file.
• When a new file is created, all pointers in the index block are
set to nil.
• Size of the index block is determined by Linked scheme,
Multilevel Index scheme or combined scheme.
EXAMPLE OF INDEXED ALLOCATION
MULTILEVEL INDEX
COMBINED SCHEME
4K bytes per block, 32-bit addresses
More index blocks than can be addressed with 32-bit file pointer
PERFORMANCE
1 block[i] free
bit[i] =
0 block[i] occupied
Block number calculation
(number of bits per word) *(number of 0-value words) + offset of first 1 bit
CPUs have instructions to return offset within word of first “1” bit
FREE-SPACE MANAGEMENT (CONT.)
• BIT MAP REQUIRES EXTRA SPACE
• EXAMPLE:
BLOCK SIZE = 4KB = 212 BYTES
DISK SIZE = 240 BYTES (1 TERABYTE)
N = 240/212 = 228 BITS (OR 256 MB)
IF CLUSTERS OF 4 BLOCKS -> 64MB OF MEMORY
• Grouping
• Modify linked list to store address of next n-1 free blocks
in first free block, plus a pointer to next block that contains
free-block-pointers (like this one)
• Counting
• Because space is frequently contiguously used and freed,
with contiguous-allocation allocation, extents, or clustering
• Keep address of first free block and count of
following free blocks
• Free space list then has entries containing addresses
and counts
PROTECTION
A. Frank - P. Weisberg
RECOVERY
• Seek time: it is the time taken for the disk arm to move
the heads to the cylinder containing the desired sector.
• Rotational latency: it is the time spent waiting for the
disk to rotate the desired sector to the disk head.
• Disk bandwidth =
total no. Of bytes transferred .
Total time b/w first request and completion
• Maximize the throughput
• Minimize the response time
FCFS
FIRST COME FIRST SERVE
The DISK starts from 0 and ends at 199.
98
53 183
37 122
14
124
65
67
EFFICIENCY OF THE SCHEDULING
Total head movement =
(53 to 98) + (98 to 183) + (183 to 37) + (37 to 122) +
(122 to 14) + (14 to 124) + (124 to 65) + (65 to 67)
= 45+85+146+85+108+110+59+2
=640 cylinders
Average head movement=
= Total / no. of requests
= 640/8
= 80 head movements per request.
SSTF
SHORTEST SEEK TIME FIRST
Total head
movement =
12+2+30+23+
53 84+24+2+59
65 =236
67 Average head
37
14 movement=
98 =29.5
122
124
183
SCAN
Total head
movement =
53
16+23+14+65
+2+ 31 + 24+
14 37 +2+59
=236
65
Average
67 head
movement=
98 122
=29.5
124 183
Total head
movement =
53 146+37
65 =183
67
98
122
Average head
124 183 movement=
=22.875
14
37
Total head
53
movement
65 = 130+169
67 =305
98
122 Average
head
124 movement=
37 183 =38.125
14
Total head
movement =
53
65
67 =153
98 122 Average head
movement=
124 =19.125
14 183
37