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
Trang 3(a) (b) (c)
1 Record
Ant Fox Pig
Hen Ibis Lamb
1 Byte
Fig 6-2 Three kinds of files (a) Byte sequence (b) Record
sequence (c) Tree.
Trang 4Object module
Object module
Module name
Date Owner Protection Size
Trang 6/*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 3 SIZE 4096 /*use a buffer size of 4096 bytes*/
#define OUTPUT 3 MODE 0700 /*protection bits for output file*/ int main(int argc, char*argv[])
{
int in 3 fd, out 3 fd, rd 3 count, wt 3 count;
char buffer[BUF 3 SIZE];
if (argc != 3) exit(1); /*syntax error if argc is not 3*/ /*Open the input file and create the output file*/
in 3 fd = open(argv[1], O 3 RDONLY); /*open the source file*/
if (in 3 fd < 0) exit(2); /*if it cannot be opened, exit*/ out 3 fd = creat(argv[2], OUTPUT 3 MODE); /*create the destination file*/
if (out 3 fd < 0) exit(3); /*if it cannot be created, exit*/ /*Copy loop*/
while (TRUE) {
rd 3 count = read(in 3 fd, buffer, BUF 3 SIZE); /*read a block of data */
if (rd 3 count <= 0) break; /*if end of file or error, exit loop*/
wt 3 count = write(out 3 fd, buffer, rd 3 count); /*write data*/
if (wt 3 count <= 0) exit(4); /*wt 3 count <= 0 is an error*/ }
/*Close the files*/
Trang 7Data (a)
Program text
Program
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.
Trang 8Root directory
Fig 6-7 A single-level directory system containing four files,
owned by three different people, A, B, and C.
Trang 9User directory
Trang 10directory
User subdirectories
C C C
B B
C C C B
Root directory
User file
Fig 6-9 A hierarchical directory system.
Trang 11Root directory
bin etc lib usr
astjim
tmp
jim
binetclibusrtmp/
ast
/usr/jimlib
lib
dict
Fig 6-10 A UNIX directory tree.
Trang 12Entire disk
Disk partition Partition table
Files and directories Root dir
I-nodes Super block Free space mgmt
Boot block
MBR
Fig 6-11 A possible file system layout.
Trang 13File A
(4 blocks)
File C (6 blocks)
File B
(3 blocks)
File D (5 blocks)
File F (6 blocks)
File E (12 blocks)
File G (3 blocks)
(a)
… (File A) (File C)
(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.
Trang 14File block 1
File block 2
File block 3
File block 4
File B
0
File block 0
File block 1
File block 2
File block 3
Fig 6-13 Storing a file as a linked list of disk blocks.
Trang 15block
File A starts here
File B starts here
Unused block
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
10 11 7
3 2
12 14 -1
-1
Fig 6-14 Linked list allocation using a file allocation table in main memory.
Trang 16File 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.
Trang 17games mail news work
Fig 6-16 (a) A simple directory containing fixed-size entries with the disk addresses and attributes in the directory entry (b) A direc- tory in which each entry just refers to an i-node.
Trang 18File 1 entry length File 1 attributes
Pointer to file 1's name File 1 attributes Pointer to file 2's name File 2 attributes Pointer to file 3's name File 2 entry length
o t d
j - g
p e b e
r c u t
o t d
j - g p
r n
s e
Entry for one file
Trang 20C'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 the file.
Trang 21Block size (bytes)
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.
Trang 22(a) (b)
Free disk blocks: 16, 17, 18
A bitmap
A 1-KB disk block can hold 256
32-bit disk block numbers
86 234 897 422 140 223 223 160 126
142 141
1001101101101100 0110110111110111 1010110110110110 0110110110111011 1110111011101111 1101101010001111 0000111011010111 1011101101101111 1100100011101111
0111011101110111 1101111101110111
230 162 612 342 214 160 664 216 320
180 482
Trang 23Disk Main
memory
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 ing a three-block file (c) An alternative strategy for handling the three free blocks The shaded entries represent pointers to free disk blocks.
Trang 24free-Open file table Quota table
Soft block limitHard block limitCurrent # of blocks
# Block warnings leftSoft file limitHard file limitCurrent # of files
# File warnings left
Fig 6-23 Quotas are kept track of on a per-user basis in a quota table.
Trang 261 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 (d)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 (c)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 (b)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 (a)
Fig 6-25 Bit maps used by the logical dumping algorithm.
Trang 28Rear (MRU) Hash table Front (LRU)
Fig 6-27 The buffer cache data structures.
Trang 29I-nodes are located near the start
of the disk
Disk is divided into cylinder groups, each with its own i-nodes
Cylinder group
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.
Trang 301 1 8 8 7 1 2 4
Location of file
Extended attribute record length
Directory entry length
File Size Date and time CD # L File name Sys
Padding
Flags Interleave Base name • Ext ; VerBytes
Fig 6-29 The ISO 9660 directory enty.
Trang 31BIOS CP/M Shell
User program
Zero page
Address 0xFFFF
0x100 0
Fig 6-30 Memory layout of CP/M
Trang 358 3 1 1 1 4 2 2 Base name
Last write date/time
Last access
Attributes
of starting block
Lower 16 bits
of starting block
Fig 6-34 The extended MOS-DOS directory entry used in
Windows 98.
Trang 3768 d o g A
A A A
0 CKC K C K C K
0 0 0
0 0 0 0 N
z x
Trang 38Bytes 2 14
File name
I-node number
Fig 6-37 A UNIX V7 directory entry.
Trang 39Attributes
Single indirect block
Double indirect block
Triple indirect block
Addresses of data blocks
Fig 6-38 A UNIX i-node.
Trang 40I-node 26
is for /usr/ast
Block 406
is /usr/ast directory
Looking up
usr yields
i-node 6
I-node 6 says that /usr is in block 132
/usr/ast
is i-node 26
/usr/ast/mbox
is i-node 60
I-node 26 says that /usr/ast is in block 406
dick erik jim ast bal
26 6 64 92 60 81 17
grants books mbox minix src
Mode size times 132
Mode size times 406
Fig 6-39 The steps in looking up /usr/ast/mbox.