1 / 25

SUBJECT:- Operating System TOPICS:- File Management

SUBJECT:- Operating System TOPICS:- File Management. From the user’s point of view, one of the most important parts of an operating system is the file system. The file system permits users to create data collections, called files, with desirable properties, such as…

kerryn
Download Presentation

SUBJECT:- Operating System TOPICS:- File Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SUBJECT:- Operating System TOPICS:- File Management

  2. From the user’s point of view, one of the most important parts of an operating system is the file system. • The file system permits users to create data collections, called files, with desirable properties, such as… • Long-term existence: Files are stored on disk or other secondary storage and do not disappear when a user logs off. • Sharable between processes:-Files have names and can have associated access permission that permit controlled sharing. • Structure: Depending on the file system, a file can have an internal structure that is convenient for particular applications. In addition, files can be organized into hierarchical or more complex structure to reflect the relationship among file

  3. Name:- User can refer file by its name. A name is usually a string of characters such as “a.cpp • Identifier: This unique item usually in the form of number identifies the file within the file system. It is non-human-readable name for the file.  • Type:-This attributes gives the types of file. File can of different types such as bmp file, text file, word file, excel file, etc. • Location:-This information stores the pointer to location of file on particular device. It generally located the first byte of file. • Size:- The current size of the file either in bytes words, or blocks. • Protection:- Access control information gives the permission for reading, writing, and executing file for different user.  • Time, date and user identification:- This attributes stores the information about the file creation date and time, last modification date and time, user name that has created file, and so on.

  4. Creating a file:- Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, an entry for the new file must be made in the directory. The directory entry records the name of the file, the location in the file system, and other information such as length, date and time. • Writing a file: - To write a file we have to make system call. System call specifies name of the file on which we want to write and the information to be written to the file. After giving the name, system searches the directory to find the location of the file. System must keep a writepointer to location where the next write is to take place. The write pointer must point to next location when one write operation has been completed.

  5. Reading a file:-Reading from file operation is generally similar to the write operation. To read from a file, we have to make system call. System call specifies name of the file that we want to read. After giving the name, system searches the directory to find the location of the file. System must keep the read pointer to location where the next read is to take place. The read pointer must point to the next location when one read operation has been completed. In some computer system for read and write operation only one pointer is used that is current-file-position pointer. This saves the space and complexity.

  6. Repositioning with in file:-This operation repositions current-file-position pointer in same file system. It doesn’t involve any I/O operation. • Deleting a file:-To delete a file, we search the directory for the particular file. After finding desired file, all file space is release so that can be reused by other files. Also the entry for that file is erased from the directory structure. • Truncating a file:-Sometimes user doesn’t want to delete the file but he erases all the content of the file so the file entry remains as it is in the file system. There is no any change in file attributes except the length of the file. File length becomes zero and the space used by file is released.

  7. File Structure • Four terms are in common use when discussing files: 1.Field 2.Record 3.File 4.Database • A field is the basic element of data. • A record is a collection of related fields. • A file is collection of similar records. • The database itself consists of one or more types of files.

  8. Files-Naming • The exact rules depends based on the OS • However most of them allows files to be : • 1-8 characters • Digits & several selected symbols • Modern ones support up to 255 characters Example Osslide,osslide-1 etc. Some file systems are case sensitive • Dos, Windows : -case insensitive • UNIX, Linux : -case sensitive • ManyOsssupport two-part filesystems Parts are separated by a period(.) Example:<filename>.<extension> Test.txt,1.pdf,nature.jpeg

  9. We know that disk surface is divided into the tracks, tracks are divided into sector. On the sector data is stored in fixed sized block. This one block is known as the physical record. Here all the blocks are same sized. • Operating system writes the file on the disk that is known as logical record. Logical record size should be match with the physical record size. But logical records may even vary in length. Packing a number of logical records into physical blocks is a common solution to this problem. This packing can be done by user application program or by operating system.

  10. File stores information. When it is used, this information must be accessed and read into computer memory. The information in the file can be accessed in several ways. • Sequential access • Direct access • The Pile • Indexing access method:

  11. Current Position End Beginning Read or write Rewind Sequential Access of File • It is the simplest access method. Information in the file is processed in order, one record after the other. It is most common access method • Sequential access is based on tape model of file. • In sequential access read operations reads the next portion of the file and automatically increment the file pointer to the next position. Similarly, a write operation appends to the end of the file and set the end-of-file pointer to the next position.

  12. File is made up of fixed length logical records. File consist sequence of blocks or records. • In direct access method any block to be read or write. Thus first we can read block 14, then block 53, then block 7, and so on. • There is no restriction on the order of reading or writing for a direct access file. • This method is based on disk model of file.

  13. The Least complicated form of file organization may be termed as pile. • Data are collected in the order in which they arrive. Each record consists of one burst of data. • The purpose of pile is simply to accumulate the mass of data and save it. • Record may have different fields, or similar fields in different orders, each fields should self-describing, including a field name as well as value

  14. In this method operating system create index for the file. • This index is like the index given in back of book. • Index contains the pointer to the various blocks. To find the particular record in the file, first search the index, and then use that index pointer to access the record from file.

  15. For example student records file stores the roll number as index for particular student record. • Each student record has roll number having 5 digits maximum (5 bytes), name having maximum 30 characters (30 bytes), address having maximum 200 characters (200 bytes), and course having maximum 30 characters (30 bytes). • So total size of one student record is 265 bytes. • If our disk contains record for the 2000 students then total bytes occupied by the student records are 5,30,000 bytes. • To find the particular record we search for the index (that means roll number). • From this index we would know exactly which block contains the desired record and access that block. • These index files are generally sorted on the basis of index so we can search particular index key by binary search algorithm.

  16. Logical record number Roll Number (Index) 102 Mahesh Ahmedabad BCA 101 102 ………….. Data file Index File Indexing a file

  17. Some system stores millions of files on terabytes of disk. To manage all these files we have to organize the files. This organization is usually performed in two parts. First disk is divided into the multiple parts known as partition, minidisk, volume, or virtual disk. Each partition contains information about files within it. This information is kept in entries in device directory or volume table of contents or directory. It stores name, location, size, and type for all files on that partition.

  18. Search for the file:- To find the entry for the particular file we have to search the directory. All files have symbolic name for searching we have to find out the particular symbol name. • Add the file into directory:- New file is created and that file is added to directory. • Delete the file from directory:- When the file is no longer needed, we want to remove it from the directory. • Copying a file from one directory to another directory:-When we want the multiple copy of the file, we have to copy the file. We can copy the file into the same directory with different name while we can copy the one file into the different directory with the same name or different name.

  19. Move file from one directory to another directory:-We can transfer the file from one directory to another directory. • Display the list of file and other information about file in particular directory:-In directory the different information about the file is stored. Such information is file name, file size, file creation date, file type, etc. When we list a directory the list of all files with its information is displayed on the screen. • Back the file of the directory:-We have to make the backup of the files of directory when there is failure of disk. This backup is generally made on magnetic tape or on any other storage device such as floppy, zip floppy, optical disk. When we take backup of directory we are getting the backup of all files within that directory structure.

  20. Single-level directory structure • Two-level directory structure • Tree-structured (Hierarchical) directory structure • Acyclic graph directory structure • Cyclic graph directory structure

  21. Root Directory A B C D Different file under root directory Single-level directory structure

  22. MFD User-1 directory User-2 directory User-3 directory A B A C D Files Two-level directory structure Master File Directory

  23. Root Directory User-1 directory User-2 directory User-3 directory Subdirectory A Subdirectory-1 Subdirectory-2 D A A C Tree-level directory structure

  24. Root Directory User-1 directory User-2 directory User-3 directory Sharing Sharing Subdirectory A Subdirectory-1 Subdirectory-2 D A Sharing A C Acyclic graph directory structure

  25. FY Cycle C PCS Cyclic graph structure

More Related