Download presentation
1
4.0 : File Management
2
Learning Outcomes 4.0 Understand File Management in Operating System 4.1 Describe three type of file structure / directory structure a. Single - Level Directory b. Two level directory c. Tree – structured directory 4.2 Various method of storing files a. Contiguous allocation b. Link list allocation (disk blocks) c. Link list allocation using index (table in main memory)
3
File Management Is software responsible for creating, deleting, modifying and controlling access to files(as well as for managing the resources used by files)
4
Primary Activities Perform in File Management
Keep track of where each file is stored –in computer system FM keep track of its files using directories that contain fail name, physical location and other important information about each file Use a policy that will determine where and how the files will be stored, making sure to efficiently use the available storage space and provide efficient access to the files Allocate each file when a user has been cleared for access to it, then record its use Deallocate the file when the file is to be returned to storage, and communicate its availability to others who may be waiting for it.
5
Primary Functions perform by File System
1) Access method 2) Directory Structure 3) File Sharing 4) Protection
6
File System(1)Access Method
File is used to stored information When it used, this information must be accessed and read into computer memory. Information in the file can be accessed in several way : (i) Capaian secara berjujukan/Sequential access (ii) Capaian secara Random Access
7
Access Method(i)Sequential Access
Refer to reading or writing data consecutively (one after the other). Example : Music tape You must forward or rewind the tape to a specific piece of data. To access item W requires passing through points A through V sequantially
8
Access Method (ii)Direct Access
Also called random access Means that the device can locate a particular data item or file immediately, without having to move consecutively through item stored in front of the desired data item or file Example: Floppy disk, Zip disk, hard disk, CDs and DVDs When writing or reading specific data, direct access is much faster than sequential access.
9
File System(2)Directory Structure
Directory records information such as name, location, size and type for all file on that partition. Directory = files containing the names & locations of other files in the file system but it doesn’t store user data Operation performed on a directory : Create a file, delete a file, list directory, rename file, traverse the file system Eg: (i) Single-level directory (ii) Two-level directory (iii)Tree-structured directory
10
Directory Structure (i) Single- Level Directory
A single directory for all users Naming problem
11
Directory Structure (ii) Two Level Directory
Separate directory for each user Path name Can have the same file name for different user Efficient searching No grouping capability
12
Directory Structure(iii)Tree-Structured Directory
Efficient searching Grouping Capability
13
File System (3) File Sharing
Sharing of files on multi-user systems is desirable User oriented O/S must accommodate the need to share file for facing difficulties. Sharing may be done through a protection scheme On distributed systems, files may be shared across a network FTP – transfer file between machine Network File System (NFS) is a common distributed file-sharing method NFS is standard UNIX client-server file sharing protocol
14
File System (4) Protection
When information is kept in a computer system : want to keep information safe from physical damage and improper access . Protection can be provided in many way Eg: 1. Small single-user system might provide protection by physically removing the floppy disk and locking them in a desk drawer or file cabinet Eg: 2. In multiuser system, others mechanisms are needed.
15
Method of Storing File Many files will be stored on the same disk
The main issue is how to allocate space to these file so that file disk space is utilized effectively and file can be accessed quickly 3 allocation methods : Contiguous Allocation Best –fit allocation = The allocation policy that always allocates from the smallest suitable free block. Suitable allocation mechanisms include sequential fit searching for a perfect fit, first fit on a size-ordered free block chain, segregated fits, and indexed fits. First fit = a sequential fit allocation mechanism. First fit simply searches the free list from the beginning, and uses the first free block large enough to satisfy the request. If the block is larger than necessary, it is split and the remainder is put on the free list. (ii) Link List Noncontiguous Allocation (iii)Link List Using Index/Index node Allocation
16
Method of Storing File : (i) Contiguous Allocation
This scheme used in early systems. Allocation using first fit/ best fit A need for compaction It is very simple to manage and implement. Any record can be found and read once its starting address and size are known. Advantage is its ease of direct access because every part of the file is stored in the same compact area.
17
Method of Storing File : (i) Contiguous Allocation …cont
Advantages Simple – only starting location (block #) and length (number of blocks) are required Advantage is its ease of direct access because every part of the file is stored in the same compact area.
18
Method of Storing File : (i) Contiguous Allocation…cont
Disadvantages Difficulty in finding space for a new file Wasteful of space Suffer from the problem of external fragmentation Size declaration problem 2 possibilities; if allocated too little space to filemay file cannot be extended User normally overestimate the amount of space needed occur wasted space
19
Method of Storing File : (i) Contiguous Allocation …cont
20
Method of Storing File : (ii) Link- List Noncontigous Allocation
Simple – need only starting address Free-space management system implemented– no waste of space Free –space – management system: keep track free disk space called free-space list and record all free disk block Each file consists of a list of disk blocks that linked : the disk block may be scattered anywhere on the disk The directory contains a pointer to the first and last block of the file Each block contains pointer to the next block .
21
Method of Storing File : (ii) Link- List Noncontigous Allocation…cont
Advantages Solves problem of contiguous allocation, No external fragmentation Size declaration problem (the size of a file does not need to be declared when the file is created) Simply to create a new file by implementation of free- space – management system
22
Method of Storing File : (ii) Link- List Noncontigous Allocation…cont
Disadvantages Space is required for the pointer. (Eg: If pointer requires 4bytes out of 512-byte block, so 0.78% is being used for pointer rather than infomation) Cannot support efficient direct access because the pointer to block are scattered anywhere on the disk(Eg: To find ith block of a file, we must start at the beginning of the file and follow the pointers until we get to the ith block)
23
Method of Storing File : (ii) Link- List Noncontigous Allocation…cont
10 16 25 1 A file of 5 blocks might start at block 9, continue at block 16, then block 1, block 10 and finally block 25.
24
Bringing all pointers together into one location
Method of Storing File : (iii) Link List Using Index/Index Node Allocation Bringing all pointers together into one location Each file has its own index block
25
Solves the Link List Allocation problem:
Method of Storing File : (iii) Link List Using Index/Index Node Allocation…cont Advantages Solves the Link List Allocation problem: Cannot support efficient direct access because the pointer to block are scattered anywhere on the disk Solution : by bringing all pointer together into one location (index block)
26
Method of Storing File : (iii) Link List Using Index/Index Node Allocation…cont
27
Free Space Management System
Free –space – management system: keep track free disk space. The system maintain a free – space list. The free – space list records all free disk block(those not allocated to some file or directory) To create a file, we search a free – space list for required amount of space and allocate that space to the new file. If space is allocated, it will removed from free- space list. When a file is deleted, its disk space is added to the free – space list. Free – space allocation method influence: Efficiency of use of disk space Performance of file system Reliability of secondary storage
28
Free Space Management System
Free – space list is implemented as bit map or bit vector If block is free it represent in bit 1 If block is allocated it represent in bit 0 Eg: Consider a disk has 30 blocks Where blocks 2,3,4,5,8,9,10,11,12,13,17,18,25,26 and 27 are free, and the rest of the blocks are allocated. What is bit vector for disk above ? Bit vector :
29
Free Space Management System
A disk has 35 blocks in which no. blocks 5, 7, 9, 12, 13, 24, 28, 29, 31, and 34 have been allocated to specific files. a) Define the bit vectors to disk above. b) By using the method of First Fit and Contiguous Fit , Draw the position of the TEST file size 45K who wish to be included in the disk. Assume a block size = 20K. c) Define the bit vectors for the new disk after test file allocated
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.