Unit 3 COA
Unit 3 COA
INPUT-OUTPUT SUBSYSTEMS
The I/O subsystem of a computer provides an efficient mode of communication between the
central system and the outside environment. It handles all the inputoutput operations of the
computer system.
Input or output devices that are connected to computer are called peripheral devices. These
devices are designed to read information into or out of the memory unit upon command from
the CPU and are considered to be the part of computer system. These devices are also called
peripherals.
For example: Keyboards, display units and printers are common peripheral devices.
There are three types of peripherals:
1. Input peripherals: Allows user input, from the outside world to the computer. Example:
Keyboard, Mouse etc.
2. Output peripherals: Allows information output, from the computer to the outside world.
Example: Printer, Monitor etc.
3. Input-Output peripherals: Allows both input (from outised world to computer) as well as,
output (from computer to the outside world). Example: Touch screen etc
Input and output (I/O) devices allow us to communicate with the computer system. I/O is the
transfer of data between primary memory and various I/O peripherals. Input devices such as
keyboards, mice, card readers, scanners, voice recognition systems, and touch screens enable
us to enter data into the computer. Output devices such as monitors, printers, plotters, and
speakers allow us to get information from the computer.
These devices are not connected directly to the CPU. Instead, there is an interface that handles
the data transfers. This interface converts the system bus signals to and from a format that is
acceptable to the given device. The CPU communicates to these external devices via I/O
registers. ...
I/O DEVICE INTERFACE
Interface is a shared boundary between two separate components of the computer system which
can be used to attach two or more components to the system for communication purposes.
There are two types of interface: -
1. CPU Interface
2. I/O Interface
Let's understand the I/O Interface in details,
The Input/output Interface is required because there are exists many differences between the
central computer and each peripheral while transferring information. Some major differences
are:
1. Peripherals are electromechanical and electromagnetic devices and their manner of operation
is different from the operation of CPU and memory, which are electronic device. Therefore, a
conversion of signal values may be required.
2. The data transfer rate of peripherals is usually slower than the transfer rate of CPU, and
consequently a synchronisation mechanism is needed.
3. Data codes and formats in peripherals differ from the word format in the CPU and Memory.
4. The operating modes of peripherals are differ from each other and each must be controlled
so as not to disturb the operation of other peripherals connected to CPU.
I/O TRANSFERS
The binary information that is received from an external device is usually stored in the
memory unit. The information that is transferred from the CPU to the external device is
originated from the memory unit. CPU merely processes the information but the source and
target is always the memory unit. Data transfer between CPU and the I/O devices may be
done in different modes. Data transfer to and from the peripherals may be done in any of the
three possible ways
1. Programmed I/O.
2. Interrupt- initiated I/O.
3. Direct memory access ( DMA).
1. Programmed I/O: It is due to the result of the I/O instructions that are written in the
computer program. Each data item transfer is initiated by an instruction in the program.
Usually the transfer is from a CPU register and memory. In this case it requires constant
monitoring by the CPU of the peripheral devices.
Example of Programmed I/O: In this case, the I/O device does not have direct access
to the memory unit. A transfer from I/O device to memory requires the execution of
several instructions by the CPU, including an input instruction to transfer the data from
device to the CPU and store instruction to transfer the data from CPU to memory. In
programmed I/O, the CPU stays in the program loop until the I/O unit indicates that it is
ready for data transfer. This is a time-consuming process since it needlessly keeps the
CPU busy. This situation can be avoided by using an interrupt facility. This is discussed
below.
2. Interrupt- initiated I/O: Since in the above case we saw the CPU is kept busy
unnecessarily. This situation can very well be avoided by using an interrupt driven
method for data transfer. By using interrupt facility and special commands to inform the
interface to issue an interrupt request signal whenever data is available from any device.
In the mean time the CPU can proceed for any other program execution. The interface
meanwhile keeps monitoring the device. Whenever it is determined that the device is
ready for data transfer it initiates an interrupt request signal to the computer. Upon
detection of an external interrupt signal the CPU stops momentarily the task that it was
already performing, branches to the service program to process the I/O transfer, and then
return to the task it was originally performing.
a. The I/O transfer rate is limited by the speed with which the processor can test and
service a device.
b. The processor is tied up in managing an I/O transfer; a number of instructions
must be executed for each I/O transfer.
Terms:
Hardware Interrupts: Interrupts present in the hardware pins.
Software Interrupts: These are the instructions used in the program
whenever the required functionality is needed.
Vectored interrupts: These interrupts are associated with the static vector
address.
Non-vectored interrupts: These interrupts are associated with the dynamic
vector address.
Maskable Interrupts: These interrupts can be enabled or disabled explicitly.
Non-maskable interrupts: These are always in the enabled state. we cannot
disable them.
External interrupts: Generated by external devices such as I/O.
Internal interrupts: These devices are generated by the internal components
of the processor such as power failure, error instruction, temperature sensor,
etc.
Synchronous interrupts: These interrupts are controlled by the fixed time
interval. All the interval interrupts are called as synchronous interrupts.
Asynchronous interrupts: These are initiated based on the feedback of
previous instructions. All the external interrupts are called as asynchronous
interrupts.
3. Direct Memory Access: The data transfer between a fast storage media such as magnetic
disk and memory unit is limited by the speed of the CPU. Thus we can allow the
peripherals directly communicate with each other using the memory buses, removing the
intervention of the CPU. This type of data transfer technique is known as DMA or direct
memory access. During DMA the CPU is idle and it has no control over the memory
buses. The DMA controller takes over the buses to manage the transfer directly between
the I/O devices and the memory unit.
a. Bus grant request time.
b. Transfer the entire block of data at transfer rate of device because the device is
usually slow than the speed at which the data can be transferred to CPU.
c. Release the control of the bus back to CPU So, total time taken to transfer the N
bytes = Bus grant request time + (N) * (memory transfer rate) + Bus release
control time.
d. Buffer the byte into the buffer.
e. Inform the CPU that the device has 1 byte to transfer (i.e. bus grant request)
f. Transfer the byte (at system bus speed).
g. Release the control of the bus back to CPU.
ADVANTAGES:
Efficiency: I/O interfaces can transfer data between the computer and the external
devices at high speeds, which allows for faster data transfer and processing times.
DISADVANTAGES:
Compatibility issues: While I/O interfaces are designed to be compatible with a wide
range of devices, there can still be compatibility issues with certain devices. In some
cases, device drivers may need to be installed to ensure proper functionality.
Security risks: I/O interfaces can be a security risk if they are not properly configured
or secured. Hackers can exploit vulnerabilities in I/O interfaces to gain unauthorized
access to a computer system or steal data.
It is hardware
1. It is software control data transfer control data
transfer
Data transfer
2. Data transfer speed is slow
speed is fast.
S.No. I/O Program Controlled Transfer DMA Transfer
CPU is not
3. CPU is involved in the complete transfer. involved in the
complete transfer.
DMA controller is
4. Extra hardware is not required. required for data
transfer.
2. Fault –
Fault exception is used in a client application to catch contractually-specified
SOAP faults. By the simple exception message, you can’t identify the reason of
the exception, that’s why a Fault Exception is useful.
3. Abort –
WHAT IS INTERRUPT ?
The term Interrupt is usually reserved for hardware interrupts. They are program control
interruptions caused by external hardware events. Here, external means external to the CPU.
Hardware interrupts usually come from many different sources such as timer chip, peripheral
devices (keyboards, mouse, etc.), I/O ports (serial, parallel, etc.), disk drives, CMOS clock,
expansion cards (sound card, video card, etc). That means hardware interrupts almost never
occur due to some event related to the executing program.
Example –
An event like a key press on the keyboard by the user, or an internal hardware timer timing
out can raise this kind of interrupt and can inform the CPU that a certain device needs some
attention. In a situation like that the CPU will stop whatever it was doing (i.e. pauses the
current program), provides the service required by the device and will get back to the normal
program. When hardware interrupts occur and the CPU starts the ISR, other hardware
interrupts are disabled (e.g. in 80×86 machines). If you need other hardware interrupts to
occur while the ISR is running, you need to do that explicitly by clearing the interrupt flag
(with sti instruction). In 80×86 machines, clearing the interrupt flag will only affect hardware
interrupts.
A software interrupt is very similar in mechanism, with the main difference being that it
occurs by the execution of a software interrupt instruction, sometimes called a trap. So, these
occur synchronously to the currently executing instruction stream. The same general context
switch from user mode to privileged mode is performed borrowing the same hardware, which
is one reason it is called an interrupt. These traps are typically used for user mode code to
accomplish system calls.
WHAT IS EXCEPTION ?
Exception is a software interrupt, which can be identified as a special handler routine.
Exception can be identified as an automatically occurring trap. Generally, there are no
specific instructions associated with exceptions (traps are generated using a specific
instruction). So, an exception occurs due to an “exceptional” condition that occurs during
program execution.
Example –
Division by zero, execution of an illegal opcode or memory related fault could cause
exceptions. Whenever an exception is raised, the CPU temporarily suspends the program it
was executing and starts the ISR. ISR will contain what to do with the exception. It may
correct the problem or if it is not possible it may abort the program gracefully by printing a
suitable error message. Although a specific instruction does not cause an exception, an
exception will always be caused by an instruction. For example, the division by zero error
can only occur during the execution of the division instruction.
A software exception can refer to the same thing, except rather than being triggered by
software interrupt instruction, it is triggered by an abnormal condition detected by the CPU in
the current instruction stream execution, such as null pointer dereference or integer divide by
zero.
EXCEPTIONS AND INTERRUPTS are unexpected events which will disrupt the normal
flow of execution of instruction (that is currently executing by processor). An exception is
an unexpected event from within the processor. Interrupt is an unexpected event from outside
the process.
Whenever an exception or interrupt occurs, the hardware starts executing the code that
performs an action in response to the exception. This action may involve killing a process,
outputting an error message, communicating with an external device, or horribly crashing the
entire computer system by initiating a “Blue Screen of Death” and halting the CPU. The
instructions responsible for this action reside in the operating system kernel, and the code
that performs this action is called the interrupt handler code. Now, We can think of handler
code as an operating system subroutine. Then, After the handler code is executed, it may be
possible to continue execution after the instruction where the execution or interrupt occurred.
EXCEPTION AND INTERRUPT HANDLING :
Whenever an exception or interrupt occurs, execution transition from user mode to kernel
mode where the exception or interrupt is handled. In detail, the following steps must be taken
to handle an exception or interrupts.
While entering the kernel, the context (values of all CPU registers) of the currently executing
process must first be saved to memory. The kernel is now ready to handle the
exception/interrupt.
1. Determine the cause of the exception/interrupt.
2. Handle the exception/interrupt.
When the exception/interrupt have been handled the kernel performs the following steps:
1. Select a process to restore and resume.
2. Restore the context of the selected process.
3. Resume execution of the selected process.
At any point in time, the values of all the registers in the CPU defines the context of the CPU.
Another name used for CPU context is CPU state.
The exception/interrupt handler uses the same CPU as the currently executing process. When
entering the exception/interrupt handler, the values in all CPU registers to be used by the
exception/interrupt handler must be saved to memory. The saved register values can later be
restored before resuming execution of the process.
The handler may have been invoked for a number of reasons. The handler thus needs to
determine the cause of the exception or interrupt. Information about what caused the
exception or interrupt can be stored in dedicated registers or at predefined addresses in
memory.
Next, the exception or interrupt needs to be serviced. For instance, if it was a keyboard
interrupt, then the key code of the key press is obtained and stored somewhere or some other
appropriate action is taken. If it was an arithmetic overflow exception, an error message may
be printed or the program may be terminated.
The exception/interrupt have now been handled and the kernel. The kernel may choose to
resume the same process that was executing prior to handling the exception/interrupt or
resume execution of any other process currently in memory.
The context of the CPU can now be restored for the chosen process by reading and restoring
all register values from memory.
The process selected to be resumed must be resumed at the same point it was stopped. The
address of this instruction was saved by the machine when the interrupt occurred, so it is
simply a matter of getting this address and make the CPU continue to execute at this address.
PROGRAMS AND PROCESSES
PROGRAM:-
When we execute a program that was just compiled, the OS will generate a process to execute
the program. Execution of the program starts via GUI mouse clicks, command line entry of
its name, etc. A program is a passive entity as it resides in the secondary memory, such as
the contents of a file stored on disk. One program can have several processes.
FEATURES OF A PROGRAM
Multiple programs can be executed by a single user.
All program instructions are stored in main memory, which is provided by the
operating system.
It is an inert thing. All it is is a file with some instructions that need to be executed.
It is devoid of a control block.
The secondary memory of the system houses it.
One program may be linked to multiple processes. For example, a browser may
have multiple tabs active at once.
PROCESS:-
The term process (Job) refers to program code that has been loaded into a computer’s memory
so that it can be executed by the central processing unit (CPU). A process can be described
as an instance of a program running on a computer or as an entity that can be assigned to and
executed on a processor. A program becomes a process when loaded into memory and thus
is an active entity.
FEATURES OF A PROCESS
Every process has a certain collection of data associated with it. For instance, the
name of its parents, the location of the memory space that has been allotted, and
security attributes like ownership rights and credentials.
A process can only exist for the duration that it is being performed.
System resources are assigned to processes. Two instances are file descriptors
and network ports.
Process is an active entity.
It has a lot of resources.
For it to function, it needs resources like memory address, CPU, and I/O.
DIFFERENCE BETWEEN PROGRAM AND PROCESS
Program Process
Program does not have any resource Process has a high resource requirement, it
requirement, it only requires memory space needs resources like CPU, memory
for storing the instructions. address, I/O during its lifetime.
Here is process state diagram from Modern Operating Systems. Transition from running to
ready happens when the scheduler picks another process.
Fig shows: - A Process can be in running, blocked, ready state. Transitions between
these states are as shown.
USB
USB was designed to standardize the connection of peripherals like pointing devices,
keyboards, digital images and video cameras. But some devices such as printers, portable
media players, disk drives, and network adaptors to personal computers used USB to
communicate and to supply electric power. It is commonplace to many devices and has
largely replaced interfaces such as serial ports and parallel ports. USB connectors have
replaced other types of battery chargers for portable devices with themselves.
MICRO USB
A reduced version of the USB (Universal Serial Bus), the micro-USB. It was created
for connecting small and mobile devices including digital
cameras, smartphones, GPS components, MP3 players, and photo printers and was
first announced in 2007 as a replacement for mini USB.
The three different types of Micro-USB are Micro A, Micro B, and Micro USB 3. The
connector size for the type Micro-A and Micro-B is 6.85 x 1.8 mm, while the Micro-
A connector has a larger maximum overmild size. Because it has more pins on the
side for twice as many wires than micro B, USB 3 micro is more comparable to micro
B yet has faster speed. Micro USB and normal USB versions are both plug-and-play
and hot-swappable is still widely used with electronic devices.
USB TYPE-C
A USB Type-C port is a relatively new type of connector that may be found on the
majority of contemporary newer Android smartphones and other USB-connected
devices. Data and power are delivered to computing machines using it. In contrast to
traditional USB connections, USB-C cables can be connected into devices in either
direction, including upside down.
USB TRANSFER SPEEDS:-
Since it is an external bus standard, USB 1.0 can accommodate up to 127 peripheral devices
and data transfer rates of 12 Mbps.
The USB 2.0 standard, commonly referred to as high-speed USB, was created in 2001 by
Philips, Lucent, Microsoft, Hewlett-Packard, Intel, NEC, and Compaq. It can support a
transfer rate of 60 megabytes per second or more up to 480 Mbps.
USB 3.0, generally known as SuperSpeed USB 3.0, was made accessible for the first time by
Buffalo Technology in November 2009. The enhanced functionality and speed of USB 3.0
contributed to advancements in power management, improved bandwidth capacity, and USB
2.0 technology.
Up to 5.0 gigabits per second (Gbps), or 640 megabytes per second, can be supported. After
the release of USB 3.1, its name was changed to USB 3.1 Gen1 for manufacturing
considerations. With the release of their Dell XPS and Inspiron computer series in April 2011,
Dell began to roll out USB 3.0 connections.
The most recent version of the USB protocol commonly known as SuperSpeed, that was
made available until July 31, 2013, is USB 3.1. It can support transfer rates of up to 10 Gbps.
Recently, USB 3.0 and 3.1 revisions are used by different devices to improve speed and
performance.
ADVANTAGES OF USB
The Universal Serial Bus was designed to simplify and improve the interface between
personal computers and peripheral devices when compared with previously existing standard
or ad-hoc proprietary interfaces.
1. The USB interface is self-configuring. This means that the user need not adjust
settings on the device and interface for speed or data format, or
configure interrupts, input/output addresses, or direct memory access channels.
2. USB connectors are standardized at the host, so any peripheral can use any
available receptacle. USB takes full advantage of the additional processing power
that can be economically put into peripheral devices so that they can manage
themselves. USB devices mostly do not have user-adjustable interface settings.
3. The USB interface is hot pluggable or plug and plays, meaning devices can be
exchanged without rebooting the host computer. Small devices can be powered
directly from the USB interface thus removing extra power supply cables.
4. The USB interface defines protocols for improving reliability over previous
interfaces and recovery from common errors.
5. Installation of a device relying on the USB standard minimal operator action is
required.
DISADVANTAGES OF USB
1. USB cables are limited in length.
2. USB has a strict tree topology and master-slave protocol for addressing
peripheral devices. Peripheral devices cannot interact with one another except via
the host, and two hosts cannot communicate over their USB ports directly.
3. Some very high-speed peripheral devices require sustained speeds not available
in the USB standard.
4. For a product developer, the use of USB requires the implementation of a
complex protocol and implies an intelligent controller in the peripheral device.
5. Use of the USB logos on the product requires annual fees and membership in the
organization.
5V, 500mA
5V, 900mA (4.5W)
(2.5W) for USB
5V, 500mA for USB 3.x, 20V,
Power Delivery 2.0, 5V, 900mA
(2.5W) 5A (100W) for USB
(4.5W) for USB
3.1
3.x
Type A, Type B,
Same as USB 1.x,
Connector Types Mini-USB, Micro- Same as USB 2.0
plus Type C
USB
5 meters (16.4
Cable Length Limit Same as USB 1.x Same as USB 2.0
feet)
Backward
Yes Yes Yes
Compatibility