chapter 6.pptx

44
CHAPTER SIX 1 FILES MANAGEMENT Files Directories Secondary storage management

Upload: muhammedyeshaw

Post on 18-Sep-2015

311 views

Category:

Documents


1 download

TRANSCRIPT

PowerPoint Presentation

CHAPTER SIX1FILES MANAGEMENTFilesDirectoriesSecondary storage management1File 2A file is a collection of similar records. The file is treated as a single entity by users and applications and may be referred by name. Files have unique file names and may be created and deleted. Restrictions on access control usually apply at the file level. A file is a container for a collection of information. The related files can be stored in a directory.A directory is a means of organizing and grouping the files.Directory can store both files and subdirectory.A subdirectory refers to a directory that is within another directory The directory that is at the topmost level on your disk is called the root directory.File management 3The way in which an operating system organizes , structures , names, accesses, uses, protects, and implements is called a file management system.The file manager provides a protection mechanism to allow users administrator how processes executing on behalf of different users can access the information in a file. File protection is a fundamental property of files because it allows different people to store their information on a shared computer.

File Management 4All computer applications need to store and retrieve information. While a process is running, it can store a limited amount of information within its own address space.However the storage capacity is restricted to the size of the virtual address space. (1st problem)A 2nd problem with keeping information with in a process address space is that when the process terminates, the information is lost.A 3rd problem is that it is frequently necessary for multiple processes to access (parts of)the information at the same time.FILE SYSTEM5Long term file storageMust store large amounts of dataInformation stored must survive the termination of the process using itMultiple processes must be able to access the information concurrentlyFiles are managed by the operating system. How they are structured, named, accessed, used, protected, and implemented are major topics in operating system design. 5File Names6Files are an abstraction mechanism.Many operating systems support two-part file namesfile extension usually indicates something about the file. E.g. prog.c is C source codeUnixlong file names (255 bytes)include special characterscase sensitive (myshell.c != Myshell.c)MS-DOSfile name = 8 chars, ., 3-char extensioncase insensitive (Grades.txt, grades.txt, GRADES.txt, all the same file)6File Structure7

Unstructured:The os does not know or care what is in the fileAll it sees are bytes. Any meaning must be imposed by user-level programs.Both UNIX and Windows use this approach

7File Types8Regular files are the ones that contain user information. Directories are system files for maintaining the structure of the file system. Character special files are related to input/output and used to model serial I/O devices such as terminals, printers, and networks. Block special files are used to model disks. 8Regular Files9ASCII filesASCII files consist of lines of text They can be displayed and printed as isThey can be edited with any text editor Easy to connect the output of one program to the input of another

binary files They are not ASCII filesExecutable, archive, etc They have some internal structure known to programs that use them9Regular Files10

ExecutableArchive10File Access11Sequential accessread all bytes/records from the beginningcannot jump around, could rewind or back upconvenient when medium was magnetic tapeRandom accessbytes/records read in any orderessential for data base systemsread can be move file marker (seek), then read or read and search11

File Operations 12Any file system provides not only a means to store data organized as files, but a collection of functions that can be performed on files.Typical operations include the following: Create: A new file is defined and positioned within the structure of files. Delete: A file is removed from the file structure and destroyed. Open: An existing file is declared to be "opened" by a process, allowing the process to perform functions on the file. Close: The file is closed with respect to a process, so that the process no longer may perform functions on the file, until the process opens the file again. Read: A process reads all or a portion of the data in a file. Write: A process updates a file, either by adding new data that expands the size of the file or by changing the values of existing data items in the file. Some other operations Append, Seek, Get attributes, Set Attributes, Rename, Lock

File Attributes13File attributes :- name ,type, location, size, protection, time, data, user identification these are the attributes of a file.Name: a file is named for the convenience of the user and is referred to by its nameType: files are so many types, the type is depending on the extension of the file Eg: .exe executable file . .obj object file .src source file Location: this information is a pointer to a devices and to the location of the file on that devices.Size : the current size of the file (in bytes, blocks)Protection : tell who may access it and who may notTime: it specifies time of creation Date: it specifies the file created date User identification: this is useful for protection security and usage monitoring 13File Attributes14

14CHAPTER SIX15FILES MANAGEMENTFilesDirectoriesSecondary storage management15Directories

16Each directory is a collection of entries, one entry per file. Among attributes: the address on disk where the file starts. Opening a file: search directory for the corresponding file entryRead attributes and disk addresses into the main memory

Directory system 17

Single level Two level Hierarchical 17Path Names18Absolute path name:Unix: /usr/home/desu/teaching/lec22.pptWindows: C:\Users\tedo\Desktop\Chapter6 newRelative path nameuse the current directory as a starting point. (dot) for this directory.. (dotdot) for parent of this directoryif current directory is /usr/home/desu/research:../teaching/lec22.ppt.txt is the same file as 18A Unix Directory Tree19

19Directory Operations20CreateDeleteOpendirClosedirReaddirRenameLinkUnlink

20CHAPTER SIX21FILES MANAGEMENTFilesDirectoriesSecondary storage management21Secondary Storage Management22Most disks can be divided up into one or more partitions, with independent file systems on each partition. Sector 0 of the disk is called the MBR (Master Boot Record) and is used to boot the computerWhen the computer is booted, the BIOS reads in and executes the MBRMBR program:locate the active partitionread in its first block called the boot blockexecute it Every partition starts with a boot block, even if it does not contain a bootable operating systemit might contain one in the future 22Secondary Storage Management23

23Contiguous Allocation24

24Contiguous Allocation25Advantages:it is simple to implement the read performance is excellent because the entire file can be read from the disk in a single operation High performanceDisadvantages:Disk fragmentationwidely used on CD-R, DVD-R and other write-once medias 25Linked List Allocation26

26Linked List Allocation27Advantage:No disk fragmentationProbably few internal fragmentation in the last blockSufficient to store address of the first blockEfficient for sequential file readingDisadvantagesamount of data storage in a block is no longer a power of two the pointer to the next block takes up a few bytes random access is extremely slowRead and search for a block27Linked List Allocation Using a Table in Memory28Both disadvantages of the linked list allocation can be eliminated:taking the pointer word from each disk block and putting it in a table in memorySuch a table in main memory is called a FAT (File Allocation Table).

28Linked List Allocation29Advantages:entire block is available for datarandom access is much easierthe chain is entirely in memoryit can be followed without making any disk referencessufficient for the directory entry to keep the starting block numberDisadvantages:the entire table must be in memory all the time to make it workoccupy a great deal of virtual memory 29i-nodes30keeping track of which blocks belong to which file is to associate with each file a data structure called an i-node (index-node)Advantage:i-node need only be in memory when the corresponding file is open Disadvantages:Difficult to accommodate growing files30i-nodesTeowdos A31

3132READING ASSIGNMENTDirectory disk allocationInode file structure 32Disk Space Management 33Two general strategies are used in storing n-byte file:n consecutive bytes of disk space are allocated the file is split up into a number of (not necessarily) contiguous blocksThe same tradeoff is present just like in memory management systems between pure segmentation and pagingNearly all file systems chop files up into fixed-size blocks that need not be adjacent 33Block Size34Having a large allocation unit, such as a cylinderevery file, even a 1-byte file, ties up an entire cylinderusing a small allocation unit each file will consist of many blocks reading each block normally requires a seek and a rotational delayreading a file consisting of many small blocks will be slow34Block Size35Small blocks are bad for performance but good for disk space utilization. A compromise size is needed

35Keeping Track of Free Blocks 36Once a block size has been chosen, the next issue is how to keep track of free blocksTwo methods are widely usedusing a linked list of disk blocks, with each block holding as many free disk block numbers as will fitbitmap - a disk with n blocks requires a bitmap with n bitsFree blocks are represented by 1s in the map, allocated blocks by 0s (or vice versa) 36The MS-DOS file system37File names 8+3 (UPPERCASE)No ownership: all files accessible to userMaintained via a File Allocation Table (FAT)Attributes:read-onlyhiddensystemarchive37The MS-DOS directory entry38

Time is inaccurate: 2 bytes = 65536, but 86400 seconds per day Date uses 7-bit for year, starting 1/1/1980. Runs out in 2107 First-block-number: index into FAT, with 64K entries 10 bytes (of 32) unused!38FAT-12/1639Block (also called cluster), multiple of 512 bytesFAT-12: 12-bit block addresses, 512-byte blockslargest partition: 4096 x 512 = 2MB. OK for floppyFor disks, MS allowed blocks of 1KB, 2KB, 4KB. Largest partition: 16MBFAT-16: switch to 16-bit addresses, block size up to 32KB.Largest partition 2GB39FAT-3240Win95 2nd Edition / Win98 / Win MEReally FAT-28: 28-bit block addressesPotentially 228 x 215 per partition, but in reality only 241 = 2TB FAT itself now occupies a large RAM:for 2GB disk, 4KB blocks 512K blocks FAT uses 2MB RAM.

40NTFS41Designed from scratchNot compatible with Win95 / Win98Usually 4KB blocks (clusters)Blocks referred to by 64-bit numbersMain data structure: Master File Table (MFT)Each MFT entry describes a file or directoryMFT entry = 1KBMFT is a file, can be anywhere on disk41Block runs42Idea: blocks of a file often sequential on diskA run is a set of consecutive blocks that belong to the same fileNo need to keep pointer to each block:Enough to keep start/length of each run 42An MFT record for a 3-run, 9-block file43

MFT43The End 44The End 44