0% found this document useful (0 votes)
6 views41 pages

Chapter 7

computer organization and architecture

Uploaded by

Hana Yaregal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views41 pages

Chapter 7

computer organization and architecture

Uploaded by

Hana Yaregal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 41

Files Organization

Computers can store the information on different storage media.


The storage is for long term and large amount of data is stored
The physical storage is converted into a logical storage unit by
operating system.
Files are mapped by the OS onto physical devices.
Files Organization
A file is a collection of similar records, with a common name.
A common name includes filename dot extension
Eg student.doc, student.txt, student.c, student.xls
The file name in Unix can include special characters and case
sensitive (myname.c != Myname.c)
The file name in window uses 8 characters before dot and 3
characters after dot ,and case
insensitive(myname.doc,Myname.doc,MYNAME.DOC)
Files Types
Regular Files:- this file store any kind of data.
•This data can be stored as plain text, an application- specific format,
or a special binary format that the system can execute.
Directories:-are system files for maintaining the structure of the
file system.
Character special Files:- It provide a mechanism for
communicating with a device one character at a
time.
 Usually character devices represent a "raw" device.
Files Types
The output of ls on a character special file looks
like the following:
crw------- 1 chalachew users 4, 0 Feb 7 13:47 /dev/tty0
 The first letter in the output is c, therefore you know that this
particular file is a character special file
Block Special Files:-provide a mechanism for communicating
with device drivers via the file system. These files are called block
devices because they transfer large blocks of data at a time.
This type of file typically represents hard drives and removable
media.
Files Types
Look at the ls -l output for a typical block device. For example,
/dev/sda:
brw-rw---- 1 root disk 8, 0 Feb 7 13:47 /dev/sda
Here the first character is b, indicating that this file is a block
special file. Just like the character special files,
File Accessing Methods
Files stores information, this information must be accessed and
read in to computer memory.
The method of accessing files are:
1. Sequential file access:- Information in a file is processed in
order, one record after the other.
Magnetic tapes are supporting this type of file accessing
Eg: a file consisting of 100 records , the current read/write head is
45th record, suppose we want to read 75th record then it access
sequentially from 45,46…,74,75.
File Accessing Methods
Sequential files are typically used in batch application and payroll
applications
2. Direct Access:-It is also called relative access.
In this method records can read/write randomly with out any
order
The direct access method is based on a disk model of a file ,b/c
disk allows random access to any file block
A direct access file allows an arbitrary blocks to be read or write
File Accessing Methods
Eg:- a disk consists 256blocks , the current position of read/write
head is at 95th block. The block to be read/write is 250th block . then
we can access the 250th block directly with out any restriction.
Best example for direct access is a CD consisting of 10 songs ,
currently song 3 is playing if we want we can shift from 3 to song 9
with out any restriction
3. Indexed sequential file access:-the main disadvantage in the
sequential file is ,it takes more time to access a record, this method
overcome this problem
0 -1000 .
0
1000-2000 .
2000-3000 .
3000-4000 .
4000-5000 .
5000-6000 .
6000-7000 .
Secondary index 7000-8000 .
0-10,000 .
50,000-51,000 . 8000-9000 .
10,000-20,000 .
51,000-52,000 . 9000-10000 .
20,000-30,000 .
30,000-40,000 . 52,000-53,000 .
40,000-50,000 . 53,000-54,000 .
50,000-60,000 . 54,000-55,000 .
55,000-56,000 .
Master index
56,000-57,000 .
57,000-58,000 .
58,000-59,000 . 60,000
59,000-60,000 . Physical Location
File Accessing Methods
A file consisting 60,000 records
The master index divided into 6 blocks each of which points to
secondary index.
The secondary index divided the 10,000 records in to 10 indexes
each index points to the physical location.
if we need to access 55,550th record ,the FMS access the index i.e
50,000-60000, the pointer of this block points the 6th index of the
secondary index
The secondary index pointer points from 55,000-56,000 records of
orginal location.
Files Attributes
•Operating systems associate other information with each file
-date and time the file was created, the file’s size
•These extra items are the file’s attributes.
•The first four attributes relate to the file’s protection and tell who
may access it and who may not
•The flags are bits or short fields that control or enable some specific
property.
•The record length, key position, and key length fields are only
present in files whose records can be looked up using a key
•The various times keep track of when the file was created, most
recently accessed and most recently modified
Files Attributes
Files Operations
Each operation has associated system calls related to files

• Create • Append
• Delete • Seek
• Open • Get attributes
• Close • Set Attributes
• Read • Rename
• Write • Lock
Directories
The directories contains information about the files, including
attributes, locations and ownerships
The directory is itself a file owned by the operating system and it
consisting of sub directories
 A file system that contain millions of files are hard to manage
To manage these files grouped them and load one group into one
directory
The directory structure provides a mechanism for organizing many
files in the file system
Directory Structure
1. Single Level Directory System
 In this directory system having only one directory ,it consisting of the all
files
 Sometimes it is said to be root directory

Root Directory

A D
B C

 The advantage of this scheme are its simplicity and ability to locate files
quickly
Directory Structure
2. Two Level Directory Structure
The problem in a single level directory is defferent users may be accidentally use
the same names for their files
To avoid the problem each user need a private directory

Root Directory

User1 User2 User3

B A C
A B B
Directory Structure
3. Hierarchical Directory System
The two level directory eliminates name conflicts among users
but it is not satisfactory for users with a large number of files.
Hierarchical directory system solve the problem

Root
directory

User1 User2 User3

Sub-dir Sub-dir
A B
Sub-sub Sub-sub Sub-sub Sub-sub
directory directory directory directory
A
B C D
Directory Structure
4. General graph directory structure
The primary advantage of this structure is traversing is easy and file sharing also
possible

Root
directory

User1 User2 User3

Sub-dir Sub-dir
A B
Sub-sub Sub-sub Sub-sub Sub-sub
directory directory directory directory
A
B C D
Path Names
•Absolutepath name:
-Unix: /usr/home/anda/teaching/lec22.ppt
-Windows: c:\My Documents\teaching\lec22.ppt
•Relative path name
-use the “current directory” as a starting point
-“.” (dot) for “this directory”
-“..” (dot dot) for “parent of this directory”
-if current directory is /usr/home/anda/research:
•../teaching/lec22.ppt.txt is the same file as
•/usr/home/anda/teaching/lec22.ppt
A Unix Directory Tree

Bahir Dar University


School of Computing and Electrical Engineering
Directory Operations
•Create • Readdir
•Delete • Rename
•Opendir • Link
•Closedir • Unlink
Secondary Storage Management
•Most 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 computer
•When the computer is booted, the BIOS reads in and executes the
MBR
•MBR program:
-locate the active partition
-read in its first block called the boot block
-execute it
•Every partition starts with a boot block, even if it does not contain a
bootable operating system
-it might contain one in the future
Secondary Storage Management
File Allocation Methods
Files are normally stor3ed on the disk
How to allocate space to these files so that disk space is utilized effectively and
files can be accessed quickly
Three major methods of allocating disk space are wide use:
1. Contiguous Allocation:-
Each file occupies a set of contiguous blocks on the disk
Eg:- a disk consisting of 1kb blocks, it would be allocated 100 cosecutive
blocks.
File Allocation Methods
With 2kb blocks, it would be allocated 50 consecutive blocks.
Consider the fig. below

File Start name length


name
A 21 5
B 3 10 0 1 2 3 4 5 6

C 35 7 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 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48
File Allocation Methods
This method is best suited for sequential files .
The main problem is: It is difficult to find the contiguous free
blocks in the disk
Another problem is external fragmentation- it means some free
blocks could happen between two files.
2. Linked Allocation:-
External fragmentation can be avoided
It is easy to locate the files, b/c allocation is on an individual
block basis.
File Allocation Methods
Each block contains a pointer to the next free block in the chain.
Here is also the file allocation table consisting of a single entry for
each file
Using this method any free block can be added to a chain very
easily.
There is a link b/n one block to another block
File Allocation Methods

0 1 2 3 4 5 6
File name Start length
name 7 8 9 10 11 12 13
Bubble sort 10 7
14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48
49 50 51 52 53 54 55

56 57 58 59 60 61 62
File Allocation Methods
Advantage
Avoid the external fragmentation
Suited for sequential files
Disadvantage
The pointer itself occupies some memory with in the block
It takes much accessing time
File Allocation Methods
3. Group Allocation or Indexed Allocation
In this method the file allocation table contains a single entry for
each file .
The entry consisting of one index block, the index box having the
pointers to the other blocks which is occupied by the particular file.
File Allocation Methods

0 1 2 3 4 5 6
File name Index
block 7 8 9 10 11 12 13
: :
14 15 16 17 18 19 20
: :
: :
21 22 23 422
24 25 26 27
Bubble sort 42
28 29 30 31 32 33 34
: :
: : 35 36 37 38 39 40 41
: : 42
42 43 44 45 46 47 48
23 38 56 51 24 49 50 51 52 53 54 55

56 57 58 59 60 61 62
File Allocation Methods
Advantage
Indexed allocation supports both sequential and direct access of files
The file indexes are not physically stored as part of the file allocation table
Whenever the file size increases, we can easily add some more blocks to the
index
No external fragmentation
Disk Space Management
•Generally the files are stored on disk, so management of disk space
is a major problem to the designer
•To allocate the space to file, what space on the disk available must
be known
•So in addition to file allocation table disk allocation table is needed
•To keep track of free disk space, the file system maintains a free
space list
•The free space list records all the disk blocks which are free
Disk Space Management
•To create a file we search a free space list for the required amount
of space and allocate it to the new file
•This space then removed from the list
•When the file is deleted, its disk space is added to the free space list
•A number of techniques have been implemented here
Disk Space Management
1. Bit vector or Bit table
• It is a collection of bits, in which each block is represented by
one bit.
• If the block is free, the bit is 0
• If the bit is allocated, the bit is 1
• For example consider the a disk where blocks
5,8,16,35,40,43,48,51 are free, the free space bit vector would be

111101101111111011111111111111111101111011011110110
5 8 16 35 40 43 48
51
Disk Space Management
2. Chain free points or Linked free space list
•This approach is to link all the free space blocks together,
keeping a pointer to the first free block
•This block contains a pointer to the next free disk block and so
on
•Example: keep a pointer to block 5,it contains a pointer to block
8, which would point to block 16, which would block to point to
35 and so on
Disk Space Management
3. Index block list
•A modification of this approach would store the address of n free
blocks in the first free block.
•The n-1 of these are actually free
•The last one is the disk address of another block containing the
address of another n free blocks
Advantage
•The address of large number of free blocks can be found quickly
Windows 2000 File System
•Windows 2000 supports several file systems, the most important of
which are:
i.FAT -16: it is the old MS-DOS file system. -It uses 16bit
disk addresses, so it supports only 2GB(216)

ii.FAT-32: uses 32 bit disk addresses and supports disk partitions up


to 2TB(1TB=1024GB)
iii.NTFS(NT file system): is a new file system develop specifically
for windows NT and carried over to widows over to windows 2000
Windows 2000 File System
-Ituses 64 bit disk addresses and can support disk partitions up to
2 power of 64 bytes
-Individual filename in NTFS are limited to 255characters

You might also like