topik5.0file management (2)
TRANSCRIPT
-
8/13/2019 Topik5.0file Management (2)
1/27
Pn Nin Hayati Binti Mohd Yusoff
Penyelaras kursus EC503
-
8/13/2019 Topik5.0file Management (2)
2/27
Data collections created byusers
The File System is one of themost important parts of the OSto a user
-
8/13/2019 Topik5.0file Management (2)
3/27
Filing systems provideo A stor ge service clients dont know about the physical
characteristics of the disks or where the files have been stored onthem
The filing systems must make sure that a file is not lost, even if thereare hardware failures or software crashes
o A directory serviceclients can give convenient text names to filesand group them in directories (establish some relationship betweenthem)
Clients should be able to access the sharing of their files with other byspecifying who can access a given file and in what way
-
8/13/2019 Topik5.0file Management (2)
4/27
-
8/13/2019 Topik5.0file Management (2)
5/27
USER PROCESS
LOGICAL FILE ORGANIZATION
LOGICAL I/O METHODS
I/O SUPERVISOR FILESYSTEM
DISK (TAPE, CD) SYSTEM
I/O
-
8/13/2019 Topik5.0file Management (2)
6/27
1
File directory service File storage service
Disk Handler
Client
Operating
System
Text-name
2
User-file id
3 4
Information
requested
from file
Disk
(1) client calls an operation such as open-file with the text name as an argument
o Another argument could be a field specifying the type of access (read-only or read-write)o The directory service will carry out an ccess checkto ensure that the client is uthorizedto
access the file
o The directory service will translate the text name into a form that enables the file storageservice to locate the file on disk (n me resolution)
o In order to do the name resolution, the directory service may call the file storage service, thefile storage service may call the disk handler to access the disk and find the requiredinformation
-
8/13/2019 Topik5.0file Management (2)
7/27
1
File directory service File storage service
Disk Handler
Client
Operating
System
Text-name
2
User-file id
3 4
Information
requested
from file
Disk
(2) The filing systems stores a very large numbers of files, only a few beingused at any time.
The filing system is ready for the client to use the file (It will have set up theinformation about this file in its tables in main memory)
It will return a user-file-identifier (UFID) for the client to use in subsequentrequests to read or write the file
-
8/13/2019 Topik5.0file Management (2)
8/27
1
File directory service File storage service
Disk Handler
Client
Operating
System
Text-name
2
User-file id
3 4
Information
requested
from file
Disk
(3) Request to read the file (4) The storage service returns the portion of the file that was requested
at (3)
-
8/13/2019 Topik5.0file Management (2)
9/27
Three common kinds of file structure:
1. Unstructured sequence of bytes2. Sequence of fixed-length records3. Tree of records, possible of different lengths
*Unix and windows both use unstructured byte sequence
-
8/13/2019 Topik5.0file Management (2)
10/27
1 byte 1 record
(a) Byte
Sequence
(b) Record
Sequence
(c) Tree
-
8/13/2019 Topik5.0file Management (2)
11/27
Most commonly used in modern operating systems is an unstructuredsequence of bytes. The operating system does not know nor care what is inthe file. It only sees bytes. This is used by UNIX and DOS/Windows. The user
can put anything it wants in the file and the OS does not help or get in the way
of the user.
In part b of fig , the file is made up of a series of fixed length records. The unitof access is a record which is may be many bytes. This roots back to early days
when a file represented a sequence of punch cards of 80 columns wide, or for
output a 132 byte record was sent to the printer. Read and write operations
affected a whole record. This organization is not used much anymore.
The 3rdtype of structure depicted in part (c) is a tree of variable size records,
each having a key field in a fixed position in the record for sorting. Can used
randomly by requesting a record having a certain key. Used in large
mainframes for commercial processing.
-
8/13/2019 Topik5.0file Management (2)
12/27
Issues in file allocation
o When a new file is created, do we specify the maximum size? Is thatspace allocated at once?
o
Space is allocated to a file as one or more contiguous units(portions). How big of a unit should we use when allocating spacefor a file?
o How do we keep trackof what space has been allocated to a givenfile (what kind of structure or table is used to keep track for a unit
allocated to a file)?
-
8/13/2019 Topik5.0file Management (2)
13/27
Pre-Allocation
o Declare max size in advance
o May be hard to guess space needed
o Tendency to overestimate space needed
o Ok if the file will never change
Dynamic allocation
o Get space as the file needs it
o Files are often no longer contiguous
-
8/13/2019 Topik5.0file Management (2)
14/27
Method of storing files:
Contiguous allocation
Linked list allocation disk blocks)Linked list allocation using index table in main memory)
Index-node
-
8/13/2019 Topik5.0file Management (2)
15/27
o Each file occupies a set of contiguous blocks on the disk. Simple - only starting location (block #) and length (number of
blocks) are required.
Suits sequential or direct access.
Fast (very little head movement) and easy to recover in the event
of system crash.
Problems
Wasteful of space (dynamic storage-allocation problem). Use firstfit or best fit. Leads to external fragmentation on disk.
Files cannot grow - expanding file requires copying
Users tend to overestimate space - internal fragmentation.
External fragmentation will occur
o Need to perform compaction
-
8/13/2019 Topik5.0file Management (2)
16/27
Contiguous File Allocation
-
8/13/2019 Topik5.0file Management (2)
17/27
Contiguous File Allocation After Compaction)
-
8/13/2019 Topik5.0file Management (2)
18/27
Each file is a linked list of disk blocks
Blocks may be scattered anywhere on the disk.
Each node in list can be a fixed size physical block or a contiguous
collection of blocks.
Allocate as needed and then link together via pointers. Disk space used to store pointers, if disk block is 512 bytes, and pointer
(disk address) requires 4 bytes, user sees 508 bytes of data.
Pointers in list not accessible to user.
pointer
Block =
Data
-
8/13/2019 Topik5.0file Management (2)
19/27
-
8/13/2019 Topik5.0file Management (2)
20/27
o Simple - need only starting address.
o Free-space management system - space efficient.
Can grow in middle and at ends. No estimation of size necessary.
o Suited for sequential access but not random access.
o Directory Table maps files into head of list for a file.
-
8/13/2019 Topik5.0file Management (2)
21/27
o Slow - defies principle of locality.
Need to read through linked list nodes sequentially to find the record of
interest.
o Not very reliable
System crashes can scramble files being updated.
o Important variation on linked allocation method
File-allocation table (FAT) - disk-space allocation used by MS-DOS and
OS/2.
-
8/13/2019 Topik5.0file Management (2)
22/27
Indexed allocation
o File allocation table contains a separate one-level index for each file
o The index has one entry for each portion allocated to the file
o The file allocation table contains block number for the index
-
8/13/2019 Topik5.0file Management (2)
23/27
Indexed Allocation with Block Portions
File allocation table contains onelevel index for each file; the index hasjust one entry for portion (unit)allocated to the file
Typically the file indexes are notstored as part of the allocation table
o The file index for a file is kept in a
separate block and the entry for thefile allocation table points to thatblock
Supports both sequential andrandom access to a file
In the figure above, a fixed sizeblocks allocation schema is
presentedo Eliminates external fragmentation
-
8/13/2019 Topik5.0file Management (2)
24/27
Indexed Allocation with Variable-Length Potrtions
Indexed allocation supportsalso a variable size portions(units) allocation schema
o Improves locality
o It is the most popular form of fileallocation
In both cases, from time to timeconsolidation may be done
o It reduces the size of the index for
the variable sized portionsschema
-
8/13/2019 Topik5.0file Management (2)
25/27
Control structure that contains key information for a particular file
-
8/13/2019 Topik5.0file Management (2)
26/27
Control structure that contains key information for a particular file
-
8/13/2019 Topik5.0file Management (2)
27/27