Solution2 - Technische Informatik
Solution2 - Technische Informatik
Solution2 - Technische Informatik
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Folie a: Name<br />
Operating Systems and Computer Networks<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
& Data Processing 2<br />
Exercise 2: File Systems<br />
Dipl.-Ing. Bogdan Marin<br />
Universität Duisburg-Essen<br />
Fakultät für Ingenieurwissenschaften<br />
Abteilung Elektro-und Informationstechnik<br />
-<strong>Technische</strong> <strong>Informatik</strong>-<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Objectives<br />
• File System Concept<br />
• File Management<br />
• Mass Storage<br />
• Physical Concept<br />
• File Allocation Table & Unix File System<br />
• Management of Free Blocks<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
File System Concepts<br />
What are Files?<br />
– Named collection of information stored on mass<br />
storage media<br />
– Logical storage units<br />
Two aspects:<br />
– User‘s view – User Interface<br />
– System Designer‘s view – Implementation<br />
User Interface results in two distinct notions:<br />
– Files: storing a collection of data<br />
– Directory Structure: organising & providing info abt<br />
files in system<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
File Management<br />
Administration of mass storage media and the devices<br />
which control them<br />
• Creation and deletion of files<br />
• To map and find files onto the physical media<br />
• File Access: WHO can and HOW to<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Mass Storage<br />
Refers to various techniques and devices for storing<br />
large amounts of data<br />
Three essential requirements are:<br />
• Able to store large amount of information<br />
• Storage must be non-volatile or persistent<br />
• Stored information can be accessed concurrently<br />
Mass Storage vs. Memory<br />
• Memory is volatile<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Mass Storage Media<br />
Magnetic tapes: tape streamer<br />
• + : cheap, large storage capacity, backup purposes<br />
• - : Disadv: slow, sequential access<br />
Magnetic disks type 1: harddisk<br />
• + : fast, higher storage capacity<br />
• - : more expensive, not necessay portable, bulky<br />
Magnetic disks type 2: floppy disks, zip<br />
• + : portable disk, universal, cheap, direct access<br />
• - : slow, small storage capacity<br />
Optical disks: CD, DVD<br />
• + : very large storage capacity, portable disk, read-only disk/drives cheap<br />
• - : slower than harddisk, write disk drives expensive<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Physical Concept (1/3)<br />
Hard-disk drive<br />
Multiple platters<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Example : Inside the Hard Disk<br />
Controller electronic Connection & Vent<br />
hole<br />
Multiple arms & heads<br />
Platters, Arms &<br />
Heads<br />
High-speed linear<br />
motor<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Physical Concept (2/3)<br />
• One or more metal platters rotate at 5400, 7200 or 10<br />
800 rpm<br />
• A mechanical arm pivots over the platters from the<br />
corner<br />
• At any given arm position, each of the heads can<br />
read/write a circular region called a track<br />
• All the tracks for a given arm position form a cylinder<br />
• Each track is divided into sectors (typically 512 bytes<br />
per sector)<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Physical Concept (3/3)<br />
Storing the Data<br />
NoH : Number of heads to read/write<br />
NoT : Number of tracks<br />
NoS : Number of sectors per track<br />
NBS : Number of bytes per sector<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
0<br />
1<br />
NoH-2<br />
NoH-1<br />
Heads 0..NoH-1<br />
Sectors<br />
0... NoS-1<br />
Tracks<br />
0 ... NoT-1<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Storage Capacity<br />
The storage capacity of a mass storage media (BV)<br />
BV = NoH * NoT * NoS * NBS<br />
NOTE : NBS is by default 512 bytes !<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Storage Capacity<br />
Given a standard format 8-inch floppy disk with 2<br />
heads, 80 tracks, 18 sectors per track, four 128byte<br />
units per sector (512 B),<br />
what is ist storage capacity in kilobytes [KB]?<br />
• BV = 2 * 80 * 18 * (4*128) [B]<br />
• BV = 2 * 80 * 18 * 512 [B]<br />
• BV = 1474560 [B]<br />
• BV = 1440 [KB]<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
File Allocation Table (FAT)<br />
•FAT = a table that OS uses to locate files on the disk.<br />
•FAT12 is the oldest type of FAT, which uses a 12-bit binary number<br />
to hold the cluster number.<br />
•cluster number is not the same as the sector number (the system<br />
designer can define the number of physical sectors in a logical<br />
cluster on a disk).<br />
•A cluster = group of sectors on the disk that have information in<br />
them.<br />
•A 4K cluster has 8 physical sectors (NBS) in it (512*8=4096).<br />
•Each Cluster has an entry in the FAT table.<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
File Allocation Table<br />
The FAT file system comes in three versions for MS<br />
DOS: FAT12, FAT16 and FAT32. Calculate the:<br />
• Size of maximum disk partition for each of the FAT version<br />
in Table 1<br />
• Size of FAT12<br />
• Size of FAT16<br />
• Size of FAT32<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
File Allocation Table<br />
Cluster Size [KB]<br />
0.5<br />
1<br />
2<br />
4<br />
8<br />
16<br />
32<br />
FAT12<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
?<br />
?<br />
?<br />
?<br />
FAT16<br />
?<br />
?<br />
?<br />
?<br />
?<br />
FAT32<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2<br />
?<br />
?<br />
?<br />
?
Max Disk Partition (1)<br />
• Given Cluster Size = 0.5 [KB] with FAT12<br />
Max disk partition<br />
= 2 12 * 512 [B]<br />
= 2 [MB]<br />
• Given Cluster Size = 2 [KB] with FAT16<br />
Max disk partition<br />
= 2 16 * 2 [KB]<br />
= 128 [MB]<br />
• Given Cluster Size = 4 [KB] with FAT32<br />
Max disk partition<br />
= 2 28 * 4 [KB]<br />
= 2 10 * 2 10 * 2 8 * 2 2 [KB]<br />
= 1 [TB]<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Max Disk Partition (2)<br />
Cluster FAT12<br />
Size [KB] [MB]<br />
0.5 0.5*212 =2<br />
1 1* 2 12 =4<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
FAT16<br />
[MB]<br />
2 2* 2 12 =8 128<br />
FAT32 [TB]<br />
4 2 2 *2 12 =16 2 2 *2 16 =256 1<br />
8 2 3 *2 16 =512 2<br />
16 2 4 *2 16 =1024 2<br />
32 2 5 *2 16 =2048 2<br />
Partitions are<br />
limited to 2 TB<br />
because internally,<br />
the system keeps<br />
track of the<br />
partition size in<br />
512 Byte sectors<br />
using a 32 bit<br />
number: 512 Bytes<br />
* 2 32 = 2 TB<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Unix File System<br />
i-node<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
A Typical Unix partition<br />
Directory entry<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Unix File System<br />
• Assume disc blocks are 8K bytes and that disc addresses are 32 bits:<br />
– What size can be directly addressed from the information in the i-node?<br />
– What size of file requires a double indirect block?<br />
– What is the largest possible file?<br />
Answer:<br />
a) Disk blocks= 8K bytes<br />
i-node => 10 disk block adress<br />
8K*10= 80K can be accessed directly<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Unix File System<br />
b) Single indirect: (address of disk block which itself contains the disk block addresses)<br />
One 8K block can address : 2 3 *2 8 =2 11 = 2048 addresses of 8K blocks<br />
Can access file size: 2048*8k=16M<br />
Double indirect: (address of disk block with the addresses of single indirect blocks)<br />
2048*2048= 4 194 304 (2 22 ) addresses of 8K blocks<br />
Can access file size: 4194304 *8k=32G<br />
c) Triple indirect: (address of disk block with the addresses of double indirect blocks)<br />
2048*2 22 =2 33 addresses of 8K blocks<br />
Can access file size: 2 33 *8k=64TB<br />
Largest file: 64TB + 32G + 16M + 80K<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Free Space Management<br />
How to keep track of free blocks?<br />
•Method 1: Linked List<br />
•Linked lists of disk blocks, each block has as many free disk<br />
block no. as will fit in<br />
•One slot needed for the pointer to the next block<br />
•Method 2: Bitmap<br />
•A disk with n blocks requires a bitmap with n bits<br />
•Free blocks 1, used blocks 0 (or viceversa)<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Bitmap vs. Linked List<br />
1 bit/block vs. 32bits/block<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Free Space Management<br />
The beginning of a free space bitmap looks like this after the disk<br />
partition is first formatted: 1000 0000 0000 0000 (the first block<br />
is used by the root directory). The system always searches for<br />
free blocks starting at the lowest numbered block, so after<br />
writing file A, which uses 6 blocks the bitmap looks like this:<br />
1111 1110 0000 0000.<br />
Show the bitmap after each of the following additional actions:<br />
File B is written using 5 blocks<br />
File A is deleted<br />
File C is written, using 8 blocks<br />
File B is deleted<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Free Space Management<br />
1000 0000 0000 0000 (begining)<br />
1111 1110 0000 0000 (file A is written )<br />
1111 1111 1111 0000 (file B is written )<br />
1000 0001 1111 0000 (file A is deleted )<br />
1111 1111 1111 1100 (file C is written )<br />
1111 1110 0000 1100 (file B is deleted )<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2
Next Week:<br />
Memory Management ..<br />
Check the webpage for exercises!<br />
http://www.fb9dv.uni-duisburg.de/ti/en/education/ss06/dv2/main.html<br />
Universität Duisburg-Essen<br />
Institut für Medientechnik and Software Engineering<br />
Exercise<br />
Operating Systems and Computer Networks<br />
& Datenverarbeitung 2