3. Overview
LINUX follows the philosophy that every thing is
a file. For example: A
keyboard,Monitor,Mouse,Printer.
Disk
LINUX I/O
Application
File SystemFile System
Disk Drive
Keyboard Terminal Tape Audio
4. The Role of Linux I/O
LINUX And UNIX(e.g.SVR4) are very
Similar in I/O Terms.
The Linux kernel associates a special
file with each I/O device driver.
Block, character, and network devices
are
recognized.
7. The Elevator Scheduler
• Maintains a single queue for disk
read and write requests
• Keeps list of requests sorted by
block
number
• Drive moves in a single direction to
satisfy each request
8. Deadline scheduler
1. A far-away block request can be
postponed for considerable time because
the queue is dynamically updated.
2. There are severe problem concerns the
difference between read and write
requests.
There are two problems in elevator scheme.
9. To deal with these problems
the deadline I/O scheduler
makes use elevator queue
as before.
Both read and write queues
keep list of requests in the
sequence in which they were
issued.
The scheduler sends out requests from write
request from sorted queue.
Once the request is satisfied , it taken out from the
sorted queue and also from appropriate FIFO
queue.
10. But, if the head of one of the queue becomes
older
than its expiration time , then the scheduler
after
that send outs from that queue.
As each request is sent out it is also deleted
from sorted queue.
this scheduler removes starvation problem and
also read/ write problem
11. Anticipatory I/O Scheduler
oSometimes it is possible that consecutive reads
from
the same process will be to disk blocks that are
close to one another.
oGenerally performance of the system could be
better improved if scheduler were to holdup a
short period of time after fulfilling a read
request.
12. o In Linux , the anticipatory scheduler is placed
over
the deadline scheduler . When a read request
is
dispatched , the anticipatory scheduler causes
the
scheduling system to delay for up to 6 ms .
o During this small delay , there is a good
chance that
the application that issued the last read
request will
issue another read request to the same region
13. Road Map
- Introduction
- Disk Scheduling
- Types of Scheduling Algorithms
Linux Page Cache
- Linux Devices
14. Linux Page Cache
• Under Linux, the Page Cache accelerates many
accesses to files on non volatile storage.
• If this data is read again later, it can be quickly read
from this cache in memory.
• This article will supply valuable background
information about this page cache.
• Linux 2.2,for read/write for regular file system and
for virtual memory pages kernel had maintained a
page cache.
15. Linux 2.4 and later, a single unified page
cache for all traffic between disk and main
memory.
16. Benefits Of Page Cache
Page Cache provides two benefits:
• Dirty pages can be collected and written out
efficiently
• Pages in the page cache are likely to be
referenced
again due to temporal locality.
17. Dirty Pages are written back
to disk in two situation:
When Free Memory Available ,it is added to
free
memory pool.
When dirty pages grow older than a specified
threshold, a number of dirty pages are written
back to disk.
If we edit the data and not save the data in
to the secondary storage, it is termed as
dirty page.
18. Optimizing Page Cache
When a 500-megabyte log file
is compressed into 10
megabytes by logrotate and
gzip, the original log file
becomes invalid along with its
cache space.
490 megabytes in the Page Cache
will then become available by
doing so. The danger of a
continuously growing log file
displacing more useful file blocks
from the Page Cache is reduced
thereby.
21. Linux Device acts as file
Everything in Linux is a file.
In Linux even hardware devices are
recognized as files.
For Linux, devices can be termed as
special files that represent physical or
virtual devices attached to Linux system.
22. How can a device can be
viewed?
• In Linux, every device needs to have device
driver so that it can be made accessible by the
OS to the users.
• The device driver actually provides the
standard input/output calls to access the
device and interact with it.
All the devices on the Linux can be viewed
through:
Command: cat /proc/devices
23. Block diagram of linux I/O
Linux kernal
spaces
user
space
App2 App3
System calls
Device drivers
Device nodes
Actual device H/W
App1
24. Block devices
• Block Devices are devices, as the name
suggests, deal with blocks of data.
• Block device drivers are implemented to
read/write block data and also supports
random access data.
• Intermediate buffer to store data between
reads and writes.
25. Block devices
• It has block device operations such as
– open()
– release()
– direct_access()
– revalidate_disk()
• Examples: A floppy, hard disks
28. Character devices
Character Devices are devices where data is a
stream of bytes i.e. the input/output happens byte
by byte.
The interactive operations (often called the file
operations) which would be most vital to implement
are:
– open()
– read()
– write()
– close()
Examples: A terminal, Keyboard, etc
30. Network devices
Network device are the ones which are used to
transmit data from one machine to another.
Here, they are exchange data in the form of
data packets with another remote machine,
using a standard protocol.
They also deal with setting up ip addresses,
configurations and modifying transmission
parameters, traffic, etc.
31. Network devices
• Their I/O operations are specific to the data
packet transmission protocol, as in, TCP/UDP.
• Examples: NIC