OS Unit 1
OS Unit 1
OS Unit 1
SYSTEM
Presented by:Mr.Vipul Gamit
Unit – 1
Introduction of Operating Systems, File Systems
and Management
What is Operating System ?.
33 Chapter:2
FILE
11/15/2017
Any organized information is a file.
34
FILE SYSTEM
11/15/2017
A file system is that software which allows users
and applications to organize their files.
35
FILE SYSTEM (CONT...)
11/15/2017
36
FILE TYPES
11/15/2017
Files tend to use file type information within a
name.
11/15/2017
In windows, if we create a file suppose using
notepad or word and save it.
11/15/2017
For a user the extension in the name of a file
helps to identify the file type.
39
FILE TYPES (CONT..)
11/15/2017
40
FILE ATTRIBUTES
11/15/2017
In addition to the file types, a file system must
have many other pieces of information that are
important which are termed as File Attributes.
- location at which file available on disk
- size of file
- when created, i.e. date and time of creation
- owner of the file
- access permissions on file(i.e. read, write,
execute)
41
FILE OPERATIONS
11/15/2017
Files are stored in secondary storage(physical
view of a file).
42
FILE OPERATIONS (CONT..)
11/15/2017
From operational point of view, a user should be
able to create a file.
43
CON..
11/15/2017
The owner can save and store the file.
44
FILE OPERATIONS (CONT..)
11/15/2017
OS provides service for operations such as below
45
FILE OPERATIONS (CONT..)
11/15/2017
46
FILE OPERATIONS (CONT..)
11/15/2017
One may need information on file sizes.
47
For e.g. I tend to use prog for my program text files.
FILE OPERATIONS (CONT..)
11/15/2017
A programmer derives considerable support
through use of regular expressions within file
names.
48
FILE OPERATIONS (CONT..)
11/15/2017
49
FILE OPERATIONS (CONT..)
11/15/2017
Makes a copy of file 'debian' and call it 'Debian‘
$ cp -i debian Debian
Rename file 'unix' to 'Unix’
$ mv -i unix Unix
Move file Unix from your home directory to /tmp.
$ mv -i newhw/hw1 oldhw
$ rm –i prgSum.c
$ mkdir foo
$ ls –l
$ cd foobar 50
FILE OPERATIONS (CONT..)
The ls command
11/15/2017
Unix’s ls command which lists files and subdirectories.
11/15/2017
Most OS allow use of regular expression operators in
conjunction with the commands.
This not only saves on typing but also helps you when
you are searching a file after a long time gap and you
do not remember exact file name completely.
C*p*2 or *2*
52
my_prog?
FILE OPERATIONS (CONT..)
Using regular expressions
11/15/2017
Regular Expression is a set of Characters that
specify a pattern.
Used when you want to search for specific lines of
text containing a particular pattern.
53
FILE OPERATIONS (CONT..)
Using regular expressions
11/15/2017
When same file needed in two separate
directories.
11/15/2017
Access permission:-
o Example:-
Consider a file supporting an application of bus schedules.
It shall contain a bus time-table with the following restrictions
- read-only permission for the general public,
- read, write permission for the supervisor,
- read, write and execute permissions for the management. 55
FILE ACCESS RIGHTS (CONT..)
Who all can access a File?
11/15/2017
Unix recognizes three category of users – user/owner,
group and others.
Owner may be a person or a program or an
application or a system based utility.
The notion of a group comes from the software
engineering team operations.
Others has the public usage.
Organization of this information is as 9 bits
rwxrwxrwx
for each owner, group and others where each r w x is
56
an octal number, e.g 100 100 100 gives read
permission for owner, group and others.
FILE ACCESS AND SECURITY
11/15/2017
In Unix, owner of a file can change its
permissions using chmod command which has a
syntax as follows:
11/15/2017
effective form of security measure in a stand alone
single user system.
Some systems provide security by having
passwords for files.
Enhanced security would be to encrypt a file with
some key.
Unix provides crypt command to encrypt files.
Syntax is :
crypt EncryptKey <InputFile> OutputFile
58
INFORMATION REQUIRED FOR FILE
MANAGEMENT
11/15/2017
59
INFORMATION REQUIRED FOR FILE
MANAGEMENT
11/15/2017
60
FILE STORAGE MANAGEMENT
11/15/2017
An OS needs to maintain several pieces of
information for file management, e.g. access and
modification times of a file.
11/15/2017
Unix internally recognizes 4 different file types
(1)ordinary(2) directory(3) special and (4)named.
11/15/2017
63
INODE STRUCTURE IN UNIX
11/15/2017
64
FILE CONTROL BLOCKS
11/15/2017
The Microsoft counterpart of an inode is a File
Control Block (FCB).
65
FILE CONTROL BLOCKS (CONT..)
11/15/2017
66
THE ROOT FILE SYSTEM
11/15/2017
When an OS is installed initially, it creates a root
file system.
The OS not only ensures but also specifies how
the system and user files shall be distributed for
space allocation on the disk storage.
Almost always the root file system has a
directory tree structure.
In OS with unix flavours the root of the root file
system is a directory.
The root is identified by “/”. The root file system
has several subdirectories.
67
THE ROOT FILE SYSTEM (CONT..)
11/15/2017
68
CONVENTIONS FOLLOWED IN UNIX
11/15/2017
Subdirectory usr contains binaries sharable by
system and user - read-only usage mode.
Executable programs are found in subdirectory
bin found at any level.
Subdirectory sbin contains some system
executable files – used during boot time and
power on.
69
CONVENTIONS FOLLOWED IN UNIX
(CONT..)
11/15/2017
Subdirectory lib contains libraries – found at several
places in the file system. Subdirectory etc contains host
related files – has many subdirectories to store
configuration (config), internet (hosts) and device (dev)
information.
Subdirectory mnt contains device mount information (in
Linux).
Subdirectory tmp contains temporary files created during
file operation.
Subdirectory var contains files that have variable data
E.g. mail and system log contain variable data. It may also
have subdirectories for spools.
70
CONVENTIONS FOLLOWED IN UNIX
(CONT..)
11/15/2017
Each user name will find his home directory as
/home/name
Subdirectory include contains all C header files.
71
THE ROOT FILE SYSTEM (CONT..)
The OS creates disk partition to allocate files for
specific usages.
11/15/2017
A certain disk partition may have system files and
some others may have other user files or utilities.
The system files are usually programs that are
executable with .bin in unix and .exe extension in MS
environment.
In unix Subdirectories are like:- /usr, /bin, /sbin , /lib,
/etc/hosts, /etc/config, /mnt, /tmp, /var.
ADVANTAGE:-
o The system knows exactly where to look for some
specific routines.
o Users can customize their operational environment by
providing a definition for an environment variable
PATH which guides the sequence in which the OS
searches for the commands. 72
BLOCK-BASED FILE ORGANISATION
11/15/2017
Data transfer take place from disks in blocks as
large as 512 or 1024 bytes at a time. Any file
which a user generates moves in blocks.
11/15/2017
the size of files before their creation.
11/15/2017
Advantage
Retrieval of information is very fast.
Disadvantages
Requires apriori knowledge.
It leaves no room for changes.
75
CONTIGUOUS ALLOCATION (CONT..)
11/15/2017
76
CHAINED ALLOCATION:- (DYNAMIC BLOCK
ALLOCATION)
Why we need this type of allocation?
11/15/2017
.
11/15/2017
A list of free blocks is maintained. Allocation is made
as need arises. We may allocate a block at a time from
a free space list.
The OS maintains a chain of free blocks and allocates
the next free block in the chain to an incoming file.
This way the finally allocated files may be located at
various positions on the disk.
Advantage:-
Free space management system(no waste space).
Simple because need only starting address.
Disadvantage:-
Random access to blocks is not possible.
Overhead - Maintenance of chained links. 78
CHAINED ALLOCATION (CONT..)
11/15/2017
79
INDEXED ALLOCATION
11/15/2017
We maintain an index table for each file in its
very first block.
80
INDEXED ALLOCATION (CONT..)
11/15/2017
81
INTERNAL & EXTERNAL FRAGMENTATION
Internal Fragmentation
11/15/2017
In mapping byte streams to blocks we assumed a block size
of 1024.
We will fill the first block completely; the second block will
remain mostly empty as only 121 bytes out of 1024 bytes
can be used.
11/15/2017
After a number of file insertions and deletions or
modifications the free-space list becomes smaller in size.
11/15/2017
External Fragmentation
Suppose we now wish to insert a moderately
large-sized file, thinking that adequate space
should be still available.
11/15/2017
A file system therefore, must periodically perform
an operation to rebuild free storage list by
collecting all the unutilized holes and linking
them back to free storage list. This process is
called compaction.
11/15/2017
86
DISK PARTITION
It allows better management of disk space.
11/15/2017
In most cases the disk partitions are created at
the time the disk is formatted.
11/15/2017
Unix ensures that the partition for the system
kernel and the users files are located in the
different partition (or file systems).
11/15/2017
A disk partition, with all it’s essentially a set of organized
information. It has its own directory structure(tree
structure).
11/15/2017
They can be physically ported.
11/15/2017
Files are the entities that users deal with all the
time.
91
FLASH MEMORY
11/15/2017
Flash memory is a type of electrically erasable
programmable read-only memory (EEPROM).
11/15/2017
It was the discovery from TOSHIBA.
93
FLASH MEMORY (CONT..)
11/15/2017
The development of flash memory in last two decades
94
FLASH MEMORY (CONT..)
11/15/2017
Structure of flash memory:-
“cell” is capable of storing one bit(0 or 1) information,
would be the smallest physical as well as logical
structure. Cells are constructed from basic transistor
circuitry.
With cell as a structural unit, it is possible to study
characteristics that impact operational aspects like
access for read, write or execute operations.
There are two kinds of cells:-
NOR logic structure
NAND logic structure
respectively referred as NOR flash and NAND flash.
95
FLASH MEMORY (CONT..)
11/15/2017
NAND flash is more commonly used for storing
program codes and persistent data file, memory
cards, USB flash drives, solid-state drives, and
similar products, for general storage and transfer
of data.
96
ORGANIZATION OF NAND FLASH
Below figure shows how starting with a cell, pages and blocks are defined in
NAND flash
11/15/2017
97
ORGANIZATION OF NAND FLASH.
11/15/2017
1. First see how a group of eight cells form a byte.
2. Register size is same as the page size in the
memory.
3. A block consists of multiple pages. Anywhere up
to 64 pages may form a block.
The flash memory may have capacity of 256 MB
to 32 GB.
4. and 5. the memory controller regulates serial
read/write operations.
98
ORGANIZATION OF NAND FLASH (CONT..)
Bulk read/write is at page level.
11/15/2017
It is possible to maintain a hash-table to identify
the block in which the page is located.
11/15/2017
Flash is extensively used in consumer electronic
appliances.
100
FLASH MEMORY (CONT..)
11/15/2017
Flash is used as an intermediate storage in the
following three ways:-
101
FLASH USED TO STORE FILE SYSTEM
11/15/2017
Some embedded Linux versions may use initrd to
store full-fledged file systems in compressed form in
flash. To operationalize file system, the following
steps come in fore :
11/15/2017
DRAM and hard disk.
103
FLASH USED AS CACHE (CONT..)
11/15/2017
104
FLASH USED AS CACHE (CONT..)
One way of facilitating the access from the cache is to
maintain a hash table in the DRAM.
11/15/2017
The hash table in DRAM holds the tags for each block
of flash.
11/15/2017
Alternatively, flash may itself stores the erase
count.
106
FLASH MEMORY COMMANDS
11/15/2017
Typical commands for flash memory pins are as
follows :-
CE : Chip Enable
WE : Write Enable
OE : Output Enable
ADE : Address Latch Enable
CDE : Command Latch Enable
107
FLASH MEMORY COMMANDS (CONT..)
11/15/2017
With this command structure a write would
require the steps to disable output, enable
address latch, enable write lines followed by chip,
enable to perform the write operation.
11/15/2017
The C language program is ultimately translated
into the low level enable commands which
regulate the voltage levels on respective pins on
the chip.
109
FLASH MEMORY FILE SYSTEM
File systems like ext2 (Linux) use 4 K block size.
11/15/2017
This does not match with the page size in flash.
11/15/2017
writes over the entire media.
By observing this write once & read often
policy we can expect better response times for
NOR flash, which has a higher erase & write
times.
111
DESIGNING FLASH MEMORY FILE SYSTEMS
3) Usually, when the flash is updated one writes
the updated copy in a new block. Once the new
11/15/2017
block has been written the pointers to the file
are updated. This is particularly useful for
NAND memories where the updates are
frequent.
11/15/2017
effect of random access at system level by
“shadowing” data to RAM. But it occupies RAM
storage.
113
FLASH FILE SYSTEM ARCHITECTURE
11/15/2017
114
FLASH FILE SYSTEM ARCHITECTURE
At the top level (hierarchical - tree directory
structure).
11/15/2017
This is uniform view regardless of the device.
11/15/2017
In figure, MTD(memory technology device) flash
is driven by “driver-k”.
116