A computer system consists of hardware, system programs, and application programs figs 6

40 324 0
A computer system consists of hardware, system programs, and application programs figs 6

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

INTRODUCTION TO MULTIMEDIA 7.2 MULTIMEDIA FILES 7.3 VIDEO COMPRESSION 7.4 MULTIMEDIA PROCESS SCHEDULING 7.5 MULTIMEDIA FILE SYSTEM PARADIGMS 7.6 FILE PLACEMENT 7.7 CACHING 7.8 DISK SCHEDULING FOR MULTIMEDIA 7.9 RESEARCH ON MULTIMEDIA 7.10 SUMMARY

6 FILE SYSTEMS 6.1 FILES 6.2 DIRECTORIES 6.3 FILE SYSTEM IMPLEMENTATION 6.4 EXAMPLE FILE SYSTEMS 6.5 RESEARCH ON FILE SYSTEMS 6.6 SUMMARY Extension Meaning file.bak Backup file file.c C source program file.gif Compuserve Graphical Interchange Format image file.hlp Help file file.html World Wide Web HyperText Markup Language document file.jpg Still picture encoded with the JPEG standard file.mp3 Music encoded in MPEG layer 3 audio format file.mpg Movie encoded with the MPEG standard file.o Object file (compiler output, not yet linked) file.pdf Portable Document Format file file.ps PostScript file file.tex Input for the TEX formatting program file.txt General text file file.zip Compressed archive Fig. 6-1. Some typical file extensions. (a) (b) (c) 1 Record Ant Fox Pig Cat Cow Dog Goat Lion Owl Pony Rat Worm Hen Ibis Lamb 1 Byte Fig. 6-2. Three kinds of files. (a) Byte sequence. (b) Record sequence. (c) Tree. (a) (b) Header Header Header Magic number Text size Data size BSS size Symbol table size Entry point Flags Text Data Relocation bits Symbol table Object module Object module Object module Module name Date Owner Protection Size Header Fig. 6-3. (a) An executable file. (b) An archive. Attribute Meaning Protection Who can access the file and in what way Password Password needed to access the file Creator ID of the person who created the file Owner Current owner Read-only flag 0 for read/write; 1 for read only Hidden flag 0 for normal; 1 for do not display in listings System flag 0 for normal files; 1 for system file Archive flag 0 for has been backed up; 1 for needs to be backed up ASCII/binary flag 0 for ASCII file; 1 for binary file Random access flag 0 for sequential access only; 1 for random access Temporary flag 0 for normal; 1 for delete file on process exit Lock flags 0 for unlocked; nonzero for locked Record length Number of bytes in a record Key position Offset of the key within each record Key length Number of bytes in the key field Creation time Date and time the file was created Time of last access Date and time the file was last accessed Time of last change Date and time the file has last changed Current size Number of bytes in the file Maximum size Number of bytes the file may grow to Fig. 6-4. Some possible file attributes. / * File copy program. Error checking and reporting is minimal. * / #include <sys/types.h> / * include necessary header files * / #include <fcntl.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char * argv[]); / * ANSI prototype * / #define BUF SIZE 4096 / * use a buffer size of 4096 bytes * / #define OUTPUT MODE 0700 / * protection bits for output file * / int main(int argc, char * argv[]) { int in fd, out fd, rd count, wt count; char buffer[BUF SIZE]; if (argc != 3) exit(1); / * syntax error if argc is not 3 * / / * Open the input file and create the output file * / in fd = open(argv[1], O RDONLY); / * open the source file * / if (in fd < 0) exit(2); / * if it cannot be opened, exit * / out fd = creat(argv[2], OUTPUT MODE); / * create the destination file * / if (out fd < 0) exit(3); / * if it cannot be created, exit * / / * Copy loop * / while (TRUE) { rd count = read(in fd, buffer, BUF SIZE); / * read a block of data * / if (rd count <= 0) break; / * if end of file or error, exit loop * / wt count = write(out fd, buffer, rd count); / * write data * / if (wt count <= 0) exit(4); / * wt count <= 0 is an error * / } / * Close the files * / close(in fd); close(out fd); if (rd count == 0) / * no error on last read * / exit(0); else exit(5); / * error on last read * / } Fig. 6-5. A simple program to copy a file. Data (a) Program text Program text abc xyz Data (b) Fig. 6-6. (a) A segmented process before mapping files into its address space. (b) The process after mapping an existing file abc into one segment and creating a new segment for file xyz. Root directory A A B C Fig. 6-7. A single-level directory system containing four files, owned by three different people, A, B, and C. Files User directory A A AB B C CCC Root directory Fig. 6-8. A two-level directory system. The letters indicate the owners of the directories and files. User directory User subdirectories C C C C C C B B A A B B C C C B Root directory User file Fig. 6-9. A hierarchical directory system. [...]... 1000 800 80 60 0 60 400 40 20 200 Disk space utilization (percent) Data rate (KB/sec) Disk space utilization Data rate 0 0 0 128 2 56 512 1K 2K Block size (bytes) 4K 8K 16K 0 Fig 6- 20 The solid curve (left-hand scale) gives the data rate of a disk The dashed curve (right-hand scale) gives the disk space efficiency All files are 2 KB Free disk blocks: 16, 17, 18 42 230 86 1001101101101100 1 36 162 234 0110110111110111... File A starts here 6 3 File B starts here 7 2 5 8 9 10 12 11 14 12 -1 13 14 15 -1 Unused block Fig 6- 14 Linked list allocation using a file allocation table in main memory File Attributes Address of disk block 0 Address of disk block 1 Address of disk block 2 Address of disk block 3 Address of disk block 4 Address of disk block 5 Address of disk block 6 Address of disk block 7 Address of block of pointers... Disk block containing additional disk addresses Fig 6- 15 An example i-node games attributes games mail attributes mail news attributes news work attributes work (a) (b) Data structure containing the attributes Fig 6- 16 (a) A simple directory containing fixed-size entries with the disk addresses and attributes in the directory entry (b) A directory in which each entry just refers to an i-node File... # of blocks # Block warnings left Soft file limit Quota record for user 8 Hard file limit Current # of files # File warnings left Fig 6- 23 Quotas are kept track of on a per-user basis in a quota table 1 5 4 Directory that has not changed 16 17 19 7 8 27 18 6 2 3 Root directory 10 9 12 13 20 21 23 15 File that has changed 30 22 14 11 29 28 24 25 31 26 32 File that has not changed Fig 6- 24 A file system. .. (LRU) Fig 6- 27 The buffer cache data structures Rear (MRU) I-nodes are located near the start of the disk Disk is divided into cylinder groups, each with its own i-nodes Cylinder group (a) (b) Fig 6- 28 (a) I-nodes placed at the start of the disk (b) Disk divided into cylinder groups, each with its own blocks and i-nodes Padding Bytes 1 1 8 8 7 Location of file File Size Date and time Extended attribute... Main memory (a) (b) (c) Fig 6- 22 (a) An almost-full block of pointers to free disk blocks in memory and three blocks of pointers on disk (b) Result of freeing a three-block file (c) An alternative strategy for handling the three free blocks The shaded entries represent pointers to free disk blocks Open file table Attributes disk addresses User = 8 Quota pointer Quota table Soft block limit Hard block... blocks 6 Free blocks (b) Fig 6- 12 (a) Contiguous allocation of disk space for seven files (b) The state of the disk after files D and F have been removed File A 0 File block 0 Physical block File block 1 File block 2 File block 3 File block 4 4 7 2 10 12 File B 0 File block 0 Physical block File block 1 File block 2 File block 3 6 3 11 14 Fig 6- 13 Storing a file as a linked list of disk blocks Physical... 210 61 2 897 1010110110110110 97 342 422 0110110110111011 41 214 140 1110111011101111 63 160 223 1101101010001111 21 66 4 223 0000111011010111 48 2 16 160 1011101101101111 262 320 1 26 1100100011101111 310 180 142 0111011101110111 5 16 482 141 1101111101110111 A 1-KB disk block can hold 2 56 32-bit disk block numbers A bitmap (a) (b) Fig 6- 21 (a) Storing the free list on a linked list (b) A bitmap Disk Main... handling long file names in a directory (a) In-line (b) In a heap Heap Root directory A A B B C B B C C C B ? C C Shared file Fig 6- 18 File system containing a shared file C C C's directory B's directory C's directory B's directory Owner = C Count = 1 Owner = C Count = 2 Owner = C Count = 1 (a) (b) (c) Fig 6- 19 (a) Situation prior to linking (b) After the link is created (c) After the original owner removes... Time Date First block number Block size 0.5 KB 1 KB 2 KB 4 KB 8 KB 16 KB 32 KB FAT-12 2 MB 4 MB 8 MB 16 MB FAT- 16 FAT-32 128 MB 2 56 MB 512 MB 1024 MB 2048 MB 1 TB 2 TB 2 TB 2 TB Fig 6- 33 Maximum partition size for different block sizes The empty boxes represent forbidden combinations 8 3 Base name Bytes Ext Attributes 1 1 1 N T Sec 4 Creation date/time 2 Last access 2 4 Last write date/time Upper 16 bits . Number of bytes in a record Key position Offset of the key within each record Key length Number of bytes in the key field Creation time Date and time the file was created Time of last access Date and. on last read * / } Fig. 6-5. A simple program to copy a file. Data (a) Program text Program text abc xyz Data (b) Fig. 6-6. (a) A segmented process before mapping files into its address space Linked list allocation using a file allocation table in main memory. File Attributes Address of disk block 0 Address of disk block 1 Address of disk block 2 Address of disk block 3 Address of disk

Ngày đăng: 28/04/2014, 16:35

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan