Chapter 3.

Secondary Storage and System Software
Ki-Joon Han School of Computer Science & Engineering Konkuk University

kjhan@db.konkuk.ac.kr

Chapter Outline (1/2)
3.1 Disk 3.2 Magnetic Tape 3.3 Disk versus Tape 3.4 Introduction to CD-ROM 3.5 Physical Organization of CD-ROM 3.6 CD-ROM Strengths and Weakness 3.7 Storage as a Hierarchy 3.8 A Journey of a Byte 3.9 Buffer Management 3.10 I/O in Unix
File Processing (3) Konkuk University (DB Lab.) 2

Chapter Outline (2/2)
Secondary storage devices (v.s. memory)
accesses take much more time than do accesses to memory all accesses are not equal

Good file structure design
use knowledge of disk and tape performance to arrange data in ways that minimize access costs

This chapter
the characteristics of secondary storage devices the journey of a byte buffering
File Processing (3) Konkuk University (DB Lab.) 3

) 4 .1 Disks (1/2) DASD magnetic disk direct (random) access and serial access Serial device magnetic tape only serial access File Processing (3) Konkuk University (DB Lab.3.

… become increasingly important for secondary storage (Appendix A) File Processing (3) Konkuk University (DB Lab.1 Disks (2/2) Magnetic disk 1. hard disks (exterior HDD) high capacity and low cost per bit removable disk pack 2.) 5 . CD-RW. DVD-RW. disk cartridge Zip (750 megabytes) and Jaz (1~2 gigabytes) disks Optical disks: CD-ROM. but slow with relatively little data 3. floppy disks inexpensive. DVD-ROM.3.

1 The Organization of Disks (1/4) Disk pack consists of a number of platters Spindle Platters Read/write heads File Processing (3) Konkuk University (DB Lab.) Boom 6 .3.1.

1.3.) 7 .1 The Organization of Disks (2/4) Track divided into a number of sectors File Processing (3) Konkuk University (DB Lab.

S. track.1 The Organization of Disks (3/4) Sector the smallest addressable portion of a disk read() : a particular byte from a disk file O. (i) find the correct surface.1.) 8 . and sector (ii) read the entire sector into a buffer in RAM (iii) find the requested byte within the buffer File Processing (3) Konkuk University (DB Lab.3.

3.1.) 9 .1 The Organization of Disks (4/4) Cylinder no seeking (same radius) File Processing (3) Konkuk University (DB Lab.

000rpm.2 Estimating Capacities and Space Needs (1/3) Disk capacity: 20GB~750GB.3.1.) 10 . buffer: 2MB~16MB File Processing (3) Konkuk University (DB Lab. spindle speed: 4.200 rpm~ 15.

1.2 Estimating Capacities and Space Needs (2/3) Cylinder -> Track -> Sector -> Byte Capacity 1.3. drive capacity = # of cylinders * cylinder capacity File Processing (3) Konkuk University (DB Lab. cylinder capacity = # of tracks / cylinder * track capacity 3.) 11 . track capacity = # of sectors / track * bytes/sector 2.

000 / 2 = 25.000 / 1008 = 24.1GB disk # # # # of of of of bytes / sector sectors / track tracks / cylinder cylinders = 512 = 63 = 16 = 4096 => How many cylinders for 256 byte records ? 50.000 sectors / file 63 * 16 = 1008 sectors / cylinder 25.000 fixed-length records on 2.8 cylinders / file File Processing (3) Konkuk University (DB Lab.) 12 .2 Estimating Capacities and Space Needs (3/3) Ex) a file with 50.1.3.

) 13 .4 (b) interleaving factor : 5 5 revolutions for 32 sectors File Processing (3) Konkuk University (DB Lab.3 Organizing Tracks by Sector (1/7) Data organization method 1.1. by user-defined block Physical placement of sectors (controller) 1.3.3.3. adjacent sectors : Fig.4 (a) [recent] can't [can] read adjacent sectors 32 [1] revolutions for 32 sectors 2. by sector 2. interleaved sectors : Fig.

3.4(b) File Processing (3) Konkuk University (DB Lab. 2 .) 14 .1. Disk 27 2 1 32 31 30 29 28 . Fig.3. .4(a) . . 5 4 3 .3 Organizing Tracks by Sector (2/7) Two views . Fig.3. 21 Disk 19 8 27 14 1 20 7 26 13 32 .

small cluster size for small files or files with random access => Cluster size is set when the disk is initialized File Processing (3) Konkuk University (DB Lab.3 Organizing Tracks by Sector (3/7) File a series of clusters of sectors Cluster a fixed # of contiguous sectors (not always physically) that can be accessed without requiring an additional seek the smallest allocation unit (default size: 3 512-bytes sectors) size : 1 ~ 65.3.535 sectors (in VAX system) Trade-offs of cluster size 1. large cluster size for large files with sequential access 2.) 15 .1.

ordered according to the logical order of their sectors cluster entry --> physical location of the cluster Cluster number 1 2 3 . . 1 3 File Processing (3) Konkuk University (DB Lab.1. . Cluster location The part of the FAT pertaining to our file 2 .) 16 . .3.3 Organizing Tracks by Sector (4/7) FAT (File Allocation Table) contains a list of all the clusters in a file. .

) 17 .1.3.3 Organizing Tracks by Sector (5/7) Extent adjacent clusters allocated as part (or all) of a file to minimize seeking file : one extent or several extents file extents extent extent extent File Processing (3) Konkuk University (DB Lab.

1535 bytes are wasted large cluster size : for large or sequential files small cluster size : for small files or random access File Processing (3) Konkuk University (DB Lab.) 18 .7(b) adv. : retrieving one sector for any record disadv. : retrieving two sectors for some records 2.7(a) adv. use of sectors 512-byte sector and 300-byte record 1) within sectors: Fig. use of clusters cluster with three 512-byte sectors and 1537-byte file --. 3.1. 3. : unused space within each sector ( -> internal fragmentation ) 2) span sectors: Fig. : no unused space disadv.3 Organizing Tracks by Sector (6/7) Fragmentation 1.3.

3 Organizing Tracks by Sector (7/7) Record organization within sectors File Processing (3) Konkuk University (DB Lab.3.1.) 19 .

) 20 .3.1.4 Organizing Tracks by Block (1/3) Disk tracks divided into integral numbers of user-defined blocks whose size can vary (not into sectors) Block unit of I/O operation : vary fixed or variable in length an integral number of logical records (blocking factor) different meaning in the context of the Unix I/O system Block organization remove the sector-spanning and fragmentation problems of sectors (no wasted space) no loss due to internal fragmentation ex) for 300 byte records => block : n * 300 bytes File Processing (3) Konkuk University (DB Lab.

blocked tracks Sector 1 111111 Sector 2 111111 Sector 3 Sector 4 Sector 5 111 222 22 333 4 444 555 (a) Sector organization 111111 111111 111 222 22 333 4 444 555 (b) Block organization (more desirable) File Processing (3) Konkuk University (DB Lab.) 21 .3.4 Organizing Tracks by Block (2/3) Sectored tracks vs.1.

data subblock : data Count subblock Data subblock Count subblock Data subblock Count subblock Key subblock Data subblock Count subblock Key subblock Data subblock File Processing (3) Konkuk University (DB Lab. key subblock : key for the last record in the data subblock 3. count subblock : # of bytes in the data subblock 2.4 Organizing Tracks by Block (3/3) Block-addressing schemes block : one or more subblocks 1.1.) 22 .3.

track address.1. block-organized disk subblocks and interblock gabs more nondata overhead File Processing (3) Konkuk University (DB Lab. sector address. and condition gaps and synchronization marks between fields of information for the read/write mechanism 2.5 Nondata Overhead (1/2) Nondata overhead (during preformatting) 1.3.) 23 . sector-addressable disk at the beginning of each sector.

the more efficient use of storage the greater the block size.3. and 300 bytes/block for subblocks and interblock gabs (1) bf = 10 10 * 100 bytes + 300 bytes = 1. the greater potential amount of internal track fragmentation File Processing (3) Konkuk University (DB Lab.300 = 15.300 bytes/block 20. blocks/track = 150 records/track (2) bf = 60 60 * 100 bytes + 300 bytes = 6.) 24 .300 = 3.17 = 3.000 / 1. blocks/track = 180 records/track the larger blocking factor.5 Nondata Overhead (2/2) Block-addressable disk drive : How many records ? 100 bytes/record.000 / 6.1.38 = 15. 20.300 bytes/block 20.000 bytes/track .

rotational delay to rotate so the required sector is under the real/write head average rotational delay is 1/2 of a revolution (ex) Hard disk : 5000 rpm (12 msec/revolution) Floppy disk : 360 rpm (166.6 msec/revolution) 3. seek time to move the access arm to the correct cylinder more costly in a multiuser environment average seek traverses 1/3 of the total # of cylinders 2.6 The Cost of a Disk Access (1/4) Disk access time 1.1.19 msec File Processing (3) Konkuk University (DB Lab. transfer time # of bytes transferred / # of bytes on a track * rotation time (ex) 63 sectors per track => Transfer time/sector = 1 / 63 * rotation time = 0.) 25 .3.

704.1.000 (bytes/file) => 8.) 26 .6 The Cost of a Disk Access (2/4) Some timing computations 9 .1 8.040 (bytes/track) /4096 (bytes/cluster) = 21.000 (records/file) / 16 (records/cluster) = 2.000 (bytes/file) / 256 (bytes/record) = 34.704.125 clusters/file [8 sectors/cluster = 16 records/cluster = 4096 bytes/cluster] = 100 tracks/file 87.040 bytes/track => 87.Gbyte fixed disk described in Table 3.3.000 256-byte records/file [512 bytes/sector] = 34.25 clusters/track File Processing (3) Konkuk University (DB Lab.

3.6 The Cost of a Disk Access (3/4) File Processing (3) Konkuk University (DB Lab.1.) 27 .

25 * 6 msec) ---------------------.28 msec = 9.7 sec/file (2) Random access average seek 8 msec (one for every access) rotational delay 3 msec read one cluster 0.1.6 The Cost of a Disk Access (4/4) (1) Sequential access average seek 8 msec rotational delay 3 msec read one track 6 msec -----------------------------------------total 17 msec/track total time = 100 * 17 msec = 1.3.(one cluster= 1/21.) 28 .25 track) total 11.250 msec = 9.700 msec = 1.28 msec (<= 1 / 21.25 sec/file File Processing (3) Konkuk University (DB Lab.000 * 11.28 msec/record total time = 34.

096/512 system) large file : allocate 4. access time) 512-byte block : slowest throughput with small amount of wasted space 1024-byte block : 4 % of the theoretical maximum throughput 4096-byte block : fastest throughput. but large amount of wasted space (45.096-byte blocks small file : divide the large blocks into 512-byte fragments wasted space => about 12 % File Processing (3) Konkuk University (DB Lab.1.6 %) due to internal fragmentation Berkeley Group implementation (4. fragmentation.3.2 trade-offs between block size and performance (block size.7 Effect of Block Size on Performance : A UNIX Example (1/2) Disk storage allocation (BSD Unix ) : Table 3.) 29 .

) 30 .1.7 Effect of Block Size on Performance : A UNIX Example (2/2) File Processing (3) Konkuk University (DB Lab.3.

8 Disk as Bottleneck (1/4) Disk bound process disk : 5 MB/sec network : 100 MB/sec => ? GB/sec CPU : more fast Solutions for disk bound process 1.1. Multiprogramming CPU works on other jobs while waiting for the data to arrive File Processing (3) Konkuk University (DB Lab.) 31 .3.

) 32 . then letting the separate drives deliver parts of the file to the network simultaneously (=> parallelism) (ex) 10 MB file spread across 20 drives (3 MB/sec) that hold 50 KB per track 1 drive 2 drive 3 drive 1st 50KB 2nd 50KB 3rd 50KB 21th 50KB … : : 181th 50KB … … 20 drive 20th 50KB 40th 50KB : : 200th 50KB 20 drives can deliver to the network 1 MB/revolution (combined rate = 60 MB/sec) File Processing (3) Konkuk University (DB Lab.3.1.8 Disk as Bottleneck (2/4) 2. Disk striping involve splitting the parts of a file on several different drivers.

1.) 33 .3. RAID : 8 drives spread individual blocks onto different drives the disk controller breaks each block into 8 pieces 1st piece is stored in the 1st drive 2nd piece is stored in the 2nd drive … 8th pieces is stored in the 8th drive에 저장 read and write speed can be ten times faster the block is reassembled in cache File Processing (3) Konkuk University (DB Lab.8 Disk as Bottleneck (3/4) 3.

3.1.8 Disk as Bottleneck (4/4)
4. Buffering
avoid accessing the disk (1) RAM disk a large part of memory is configured to simulate the behavior of a mechanical disk in every respect except speed and volatility without a seek or rotational delay, but volatile (2) Disk cache a large block of memory is configured to contain pages of data from a disk (256 KB cache) for high degree of locality

File Processing (3)

Konkuk University (DB Lab.)

34

3.3 Disk Versus Tape
Disk
excellent for random access and storage of file for which immediate access was desired for several processes => between accesses : tend to require an extensive seek

Tape
ideal for processing data sequentially and for long-term storage of files for one process

File Processing (3)

Konkuk University (DB Lab.)

35

3.7 Storage as a Hierarchy (1/2)
Hierarchy of storage devices : Fig. 3.17
different access time, capacity, and cost

(1) Primary storage
registers, memory, RAM disk, disk cache : semiconductors

(2) Secondary storage
direct-access : magnetic disks serial : tape, mass storage

(3) Offline storage
archival and backup : removable magnetic disks, optical discs, tapes

File Processing (3)

Konkuk University (DB Lab.)

36

3.) File Processing (3) Konkuk University (DB Lab.7 Storage as a Hierarchy (2/2) Hierarchy of storage devices (Cont.) 37 .

8 A Journey of a Byte (1/2) write(textfile.) 38 . 1) User Program ch : P How the byte is stored on a disk.3. ch. when a program write a byte to a file on a disk ? I/O buffer Operating system File manager I/O processor Disk controller Disk File Processing (3) Konkuk University (DB Lab.

) 39 .8 A Journey of a Byte (2/2) write(textfile.3. ch. 1) ch : P File Processing (3) Konkuk University (DB Lab.

File Processing (3) Konkuk University (DB Lab. The file manager makes sure that the last sector in the file has been stored in a system I/O buffer in RAM. The OS passes the job on to the file manager The file manager looks up textfile in a table containing information about it.3. what types of access are allowed. such as whether the file is open and available for use. The file manager searches a FAT for the physical location of the sector that is to contain the byte.1 The File Manager (1/3) 1 Logical layer The program asks the OS to write the contents of the variable ch to the next available position in textfile.8. then deposits the ‘P’ into its proper position in the buffer.) 40 2 3 4 5 . and what physical file the logical name textfile corresponds to. if any.

The disk controller instructs the drive to move the r/w head to the proper track. waits for the desired sector to come under the r/w head. then sends the byte to the drive to be deposited. The I/O processor sends the data to the disk controller. bit-by-bit.3.1 The File Manager (2/3) 6 The file manager gives instructions to the I/O processor about where the byte is stored in RAM and where it needs to be sent on the disk The I/O processor finds a time when the drive is available to receive the data and puts the data in proper format for the disk. File Processing (3) Konkuk University (DB Lab. It may also buffer the data to send it out in chunks of the proper size for the disk. on the surface of the disk.) 7 8 9 Physical layer 41 .8.

) 42 .1 The File Manager (3/3) File manager v. cylinder. and sector where the byte is to be stored File Processing (3) Konkuk University (DB Lab. programs that deal with file-related matters and I/O devices several layers of procedures : logical ~ physical (i) check the logical characteristics of the file whether the file has been opened what type of file the byte is being sent to (binary. track.S. text file) who the file's owner is whether write access is allowed for the user (ii) determine where in the file textfile the P is to be deposited => physical location of the last sector ( <= FAT ) (iii) locate the drive. O.s.8.3.

) 43 .20 (vii) wait to see if the sector can accumulate more bytes going to the same sector before actually transmitting anything => if closed.2 The I/O Buffer (1/2) (iv) determine whether the sector that is to contain the P is already in RAM or needs to be loaded into RAM (v) if not. find an available system I/O buffer space for it and read it from disk (vi) deposit the P into its proper position in the buffer (Fig.20) 3.8.3. 3. flush all output buffers File Processing (3) Konkuk University (DB Lab.

3.2 The I/O Buffer (2/2) File Processing (3) Konkuk University (DB Lab.8.) 44 .

external data path (disk) : 16 bits in slow speed => bottlenecks caused by differences in speeds & widths I/O Processor from a simple chip capable of taking a byte and passing it along one cue.) 45 . to a powerful.8.3 The Byte Leaves Memory : The I/O Processor and Disk Controller (1/3) Data path the byte traveled along data paths 1. but once it begins processing I/O.3. small computer capable of executing very sophisticated programs and communicating with many devices simultaneously takes its instructions from the OS. it runs independently => I/O processes and internal computing are overlapped File Processing (3) Konkuk University (DB Lab. internal data path (CPU) : 32 bits in fast speed 2.

then sends the byte to the drive to be deposited File Processing (3) Konkuk University (DB Lab.3. how much data there is 3.21 responsible for the job of actually controlling the operation of the disk instruct the disk drive to set the read/write head to the desired sector.) 46 . where it is to go on the disk Disk controller : Fig.8.3 The Byte Leaves Memory : The I/O Processor and Disk Controller (2/3) Information(program) : file manager => I/O Processor 1. data in the buffer that is to be transmitted to the disk 2. 3.

. then sends it to the disk controller. I/O processor Program ….… Invoke I/O processor .) 47 .3. File Processing (3) Konkuk University (DB Lab. ‘p’ ‘p’ Disk controller ‘p’ System buffer ‘p’ I/O processor FIGURE 3.3 The Byte Leaves Memory : The I/O Processor and Disk Controller (3/3) I/O Processor & Disk controller User’s program …. prepares it on the disk. User’s data area: c: ‘P’ File Manager ..21 The file manager sends the I/O processor instructions in the from of an I/O Processor program.. …. deposits it on the surface of the disk.8.… …. …. The I/O processor gets the data from the system buffer. …. ….

but by the operating system File Processing (3) Konkuk University (DB Lab.9 Buffer Management Buffering work with large chunks of data in memory so the number of accesses to secondary storage can be reduced the use of system I/O buffers within programs can substantially affect performance Buffer the part of main memory available for storage of copies of disk blocks not controlled by programmers.3.) 48 .

3..1 Buffer Bottlenecks (1/2) Program for both input and output on one character at a time and only one I/O buffer (i) program asks for its first character I/O buffer is loaded with the sector containing the character the character is transmitted to the program (ii) program decides to output a character I/O buffer is filled with sector that will contain the character (i. destroy its original contents) (iii) program asks for the next character buffer contents have to be written to disk to make room for the (original) sector containing the second input character … => two buffers (one for input and one for output) File Processing (3) Konkuk University (DB Lab.) 49 .e.9.

9. or is I/O bound use multiple buffers CPU : process the current buffer overlapping I/O system : fill the next buffer File Processing (3) Konkuk University (DB Lab.1 Buffer Bottlenecks (2/2) Program transmits data in only one direction.) 50 .3.

it is taken from a pool of available buffers and used buffer selection for replacement : least recently used (LRU) File Processing (3) Konkuk University (DB Lab.9.) 51 .2 Buffering Strategies (1/6) Double buffering the method of swapping the roles of two buffers after each output (or input) operation O.S. : operating on one buffer I/O system : loading or emptying overlapping the other buffer Buffer pooling when a system buffer is needed.3.

9.2 Buffering Strategies (2/6) Double buffering I/O buffer 1 Program data area I/O buffer 2 To disk I/O buffer 1 Program data area I/O buffer 2 File Processing (3) Konkuk University (DB Lab.) To disk 52 .3.

9.) 53 .2 Buffering Strategies (3/6) Buffer handling (by file manager) 1.3. but provide the program with the locations of the system buffers program can operate directly on data in the I/O buffer File Processing (3) Konkuk University (DB Lab. locate mode data : secondary storage <=> program's data area nmap() no extra move use system buffers to handle all I/O. move mode data : system buffer (RAM) <=> program buffer (RAM) (= program's data area) take the amount of time 2.

3.9.) 54 .2 Buffering Strategies (4/6) Move mode & Locate mode Move mode program’s data area system buffer Disk Locate mode user’s program location (pointer) system buffer Disk File Processing (3) Konkuk University (DB Lab.

gather output : writev( ) several buffers can be gathered and written with a single WRITE call File Processing (3) Konkuk University (DB Lab. scatter input : readv( ) a single READ call identifies a collection of buffers into which data from a single block is to be scattered 2... in one buffer data .2 Buffering Strategies (5/6) Block (header + data) headers . in a different buffer two-step process (i) read whole block into a single big buffer (ii) move the different parts to their own buffers Two methods (to reduce the running time) 1.9.3.) 55 ...

) Disk writev() 56 .3.9.2 Buffering Strategies (6/6) Scatter input & Gather output Scatter input buffer 1 readv() Disk buffer 2 Gather output buffer 1 buffer 3 buffer 2 File Processing (3) Konkuk University (DB Lab.

. views all I/O as operating on a sequence of bytes File Processing (3) Konkuk University (DB Lab.10 I/O in UNIX 3.1 The Kernel (1/11) Kernel I/O Structure 1. bottom layers carry out the task of turning the logical object into a collection of bits on a physical device system view on a file UNIX Kernel . topmost layer deal with data in logical. a body of text. library routines (scanf(). or some other logical entity) application view on a file processes . fread()) 2. an image..) 57 . structural terms (e..10.. user programs.. tail).3.g. file name. an array of numbers. shell routines (cat.

10... consoles printers.3. printers...1 The Kernel (2/11) PROCESSES User programs Libraries Shell commands System call interface KERNEL I/O system Block I/O system (normal files) Character I/O system (terminals..) . HARDWARE File Processing (3) Konkuk University (DB Lab... 58 disk..) Network I/O system (sockets) block device drivers disk character device drivers network interface drivers .networks. etc.

) 59 .1 The Kernel (3/11) Journey of a byte write (fd. 1) : (vs.3.10. &ch. fprintf(): library call) (i) the system call instructs the kernel to write a character to a file (ii) the kernel I/O system begins by connecting the file descriptor (fp) to some file or device (scan a series of 4 tables) file descriptor table open file table file allocation table table of index nodes (inode table) File Processing (3) Konkuk University (DB Lab.

10.3. stderr File Processing (3) Konkuk University (DB Lab.1 The Kernel (4/11) File descriptor table owned by the process (your program) associates each of the file descriptors used by a process with an entry in the open file table every process has its own descriptor table includes entries for all opened files. including stdin. stdout.) 60 .

1 The Kernel (5/11) File descriptor table File descriptor 0 (keyboard) 1 (screen) 2 (error) 3 (normal) 4 (normal) 5 (normal) . . File table entry to open file table File Processing (3) Konkuk University (DB Lab.3.) 61 .10. .

offset of next access. pointers to generic functions (i. inode table entry..e.3.) 62 . read and write routines). the number of processes currently using it.1 The Kernel (6/11) Open file table owned by the kernel contains entries (called "file structures") for every open file R/W mode. transitory (during opened) File Processing (3) Konkuk University (DB Lab. etc.10.

..10. to inode table write() routine for this type of file File Processing (3) Konkuk University (DB Lab...3.1 The Kernel (7/11) Open file table R/W mode # of processes using it Offset of next access ptr to write routine ..) 63 .. inode table entry write 1 100 .....

the same file can be opened by two separate open() statements (i..10. several different processes can refer to the same open file table entry two processes : dependent 2.e.3.) 64 . two separate entries) two processes : independent inode : shared File Processing (3) Konkuk University (DB Lab.1 The Kernel (8/11) Two methods 1.

) 65 .like structure.1 The Kernel (9/11) File allocation table (FAT) owned by the kernel a list (index) of the disk blocks that make up the file part of an index node(inode) dynamic tree .10. not a simple linear array inode (index node) table owned by the kernel when a file is opened. a copy of its inode is usually loaded into the inode table in memory for rapid access File Processing (3) Konkuk University (DB Lab.3.

the type of operation.3. and the type of device that is to be written see that your data is moved from its buffer to its proper place on disk File Processing (3) Konkuk University (DB Lab. file size. permissions. owner's id. block count.1 The Kernel (10/11) Index node (inode) permanent (during the existence of files). it invokes an I/O processor program (≡ device driver) Device driver appropriate for the type of data. etc.) 66 . so kept on disk with the file information about file position.10. => once the kernel's I/O system has the inode information.

3. block count file allocation table . . . .1 The Kernel (11/11) inode device permissions owner’s userid file size .10.) 67 File Processing (3) . Konkuk University (DB Lab. .

inode number : 2 byes Shell commands ln file-name1 file-name2 (cf.2 Linking File Names to Files (1/2) Directory a small file that contains. … it removes directory entries & links cp file-name1 file-name2 two file names have different inode numbers mv file-name1 file-name2 file name is changed. for each file. but with the same inode number File Processing (3) Konkuk University (DB Lab.) 68 .3..10. link()) two file names have the same inode number rm file-name. a file name together with a pointer (called "hard link") to the file's inode on disk file name : 14 bytes.

3 BSD (not System V) File Processing (3) Konkuk University (DB Lab.10.e.2 Linking File Names to Files (2/2) Hard link an entry in a directory that connects a file name to the inode of the corresponding file by its inode number several file names can point to the same inode when a file name is deleted. but its hard-link count is decremented by one Soft link (or symbolic link) an entry in a directory that gives the pathname of a file links a file name to another file name rather than to an actual file (i..3.) 69 . an indirect pointer to a file) can refer to a directory or even to a file in a different file system UNIX 4. file itself is not deleted.

Special files represent a stream of characters and control signals that drive some devices (e..) 70 . open() and write() system calls) File Processing (3) Konkuk University (DB Lab.10. line printer or graphic device) 3.g.3. Sockets abstractions that serve as endpoints for interprocess communication => many of the same routines can be used to access any of them (e.. and Sockets Three types of files 1.g.3 Normal Files. Special Files. Normal files files that this text is about 2.

4 Block I/O Three I/O systems 1. not blocks 3.10.3. network I/O system for data communication on the network File Processing (3) Konkuk University (DB Lab.) 71 . character I/O system for character-oriented device like a keyboard or a printer read and write streams of data. block I/O system for block-oriented device like a disk or a tape access blocks randomly sequence of bytes <=> block block size = 512 bytes (common sector size) --> 1024 bytes 2.

) 72 .5 Device Drivers Device driver (≡ I/O processor program) a separate set of routines for each peripheral device performs the actual I/O between the I/O buffer and the device Block I/O device driver take a block from a buffer. destined for one of physical blocks.3.10. and see that it gets deposited in the proper physical place on the device => Block I/O part of kernel need not know anything about the specific device it is writing to File Processing (3) Konkuk University (DB Lab.

10.3. together with secondary information about the files in the system includes the directory structure. the directories. ordinary files.6 The Kernel and File Systems(1/2) UNIX file system ⊂ Kernel's I/O system a collection of files. and the inodes that describes the files File Processing (3) Konkuk University (DB Lab.) 73 .

6 The Kernel and File Systems(2/2) Separation (file system ⊂ kernel) 1.10.3.g. but are accessible by the same kernel (e.) 74 .. all parts of a file system reside on disk some parts are brought into memory by the kernel as needed 2. file system on CD-ROM) File Processing (3) Konkuk University (DB Lab. kernel reside in memory Advantages of separation we can tune a file system to a particular device or usage pattern independently of how the kernel views files we can have separate file systems that are organized differently. perhaps on different devices.

Sign up to vote on this title
UsefulNot useful