IO Systems Streams: Subject: Operating System Ibrar Afzal Lecturer IT Department
IO Systems Streams: Subject: Operating System Ibrar Afzal Lecturer IT Department
STREAMS
Lecture -3
Ibrar Afzal
Lecturer IT Department
1
STREAMS
It consists
Stream head
That interfaces with the user process
A driver end
That controls the device, and zero or more
Stream modules between the stream
Head and the driver end.
Each of these components contains a pair of queues
A read queue
A write queue
Message passing is used to transfer data between queues.
2
STREAMS
A process can open a serial-port device via a stream and can push on a module to
3
STREAMS
A queue accepts all messages and immediately sends them on to the queue in the
adjacent module without buffering them
A queue that supports flow control buffers messages and does not accept messages without
modules
4
STREAMS
5
STREAMS
User process reads data from the stream head using either the read() or getmsg() system call.
If read() is used
If getmsg() is used
6
STREAMS
STREAMS I/O is asynchronous (or nonblocking)
except when the user process communicates with the stream head.
The user process will block, until there is room to copy the message
Assuming the next queue uses flow control
The user process will block
7
STREAMS
Unlike the stream head, which may block if it is unable to copy a message to the next queue in
8
STREAMS
9
STREAMS
System V UNIX and Solaris implement the socket mechanism using STREAMS
10
IO Performance
It places heavy demands on the CPU to execute device-driver code and to schedule processes
I/O also exposes any inefficiencies in the interrupt-handling mechanisms in the kernel
Coping gracefully with all these demands is one of the major concerns of a computer architect
11
IO Performance
interrupt handling
12
IO Performance
Network traffic
Cause a high context-switch rate.
A remote login from one machine to another.
Each character typed on the local machine must be transported to the remote machine.
The user process issues a network I/O system call to send the character to the remote machine.
13
IO Performance
Network traffic
Through the network layers that construct a network packet into the network device driver.
The network device driver transfers the packet to the network controller,
The interrupt is passed back up through the kernel to cause the network I/O system call to complete.
14
IO Performance
Now, the remote system’s network hardware receives the packet
an interrupt is generated.
passes the packet to the appropriate sub daemon for that session.
Throughout this flow, there are context switches and state switches
To eliminate the context switches involved in moving each character between daemons and the kernel,
the Solaris developers re implemented the telnet daemon using in-kernel threads.
Improvement increased the maximum number of network logins from a few hundred to a few thousand on a
large server.
15
IO Performance
Other systems use separate front-end processors for terminal I/O to reduce the interrupt burden
systems.
The job of a channel is to offload I/O work from the main CPU.
The idea is that the channels keep the data flowing smoothly, while the main CPU remains free to
process the data. Like the device controllers and DMA controllers found in smaller computers,
a channel can process more general and sophisticated programs,
16
IO Performance
I/O devices vary greatly in complexity.
By contrast, the functionality provided by the Windows disk device driver is complex.
It not only manages individual disks but also implements RAID arrays
To do so, it converts an application’s read or write request into a coordinated set of disk I/O
17
IO Performance
Where should the I/O functionality be implemented
Or in application software?
18
IO Performance
Initially, we implement experimental I/O algorithms at the application level, because
By developing code at the application level, we avoid the need to reboot or reload device drivers after every change to the
code.
An application-level implementation can be inefficient, because
application cannot take advantage of internal kernel data structures and kernel functionality (such as efficient in-kernel
19
IO Performance
Initially, we implement experimental I/O algorithms at the application level, because
By developing code at the application level, we avoid the need to reboot or reload device
application cannot take advantage of internal kernel data structures and kernel
20
IO Performance
We may Re implement it in the kernel.
21
Performance
The highest performance may be obtained through a specialized implementation in hardware,
For instance, a hardware RAID controller may not provide any means for the kernel to
22
Improving the efficiency of I/O
We can utilize several principles to improve the efficiency of I/O:
• Reduce the number of times that data must be copied in memory while passing between
device and application.
• Reduce the frequency of interrupts by using large transfers, smart controllers and
polling (if busy waiting can be minimized).
23
Summary
STREAMS
Performance
Efficiency
24
THANKS
25