Sie sind auf Seite 1von 13

Lecture 27

Input/Output Devices

Disk
Each platter is a magnetic surface. For each platter, there must an associated read/write head. A platter is divided into tracks and tracks are divided into sectors. Tracks on the outside of a platter may have more sectors than those further inside. (A band is a group of adjacent tracks all with the same number of sectors.)
Platter Sectors Platters

Tracks

A disk is a block device.


Track

Taking the same track across all surfaces, you have what is called a cylinder.

Disk Access
Seek: time to move head from current position to desired track. Industry standard: average seek time is given by

all possible seek times possible seeks

Rotational latency (delay): average time for the sector you want to access to come under the head. This is given by half the time for one full rotation.

arm

head

Disk Access
The access heads for all surfaces moves together as one. This leads one to want to store a single file in the same cylinder (spanning multiple surfaces) using a spiral scheme. When youre reading data that spans multiple surfaces, you must activate heads one at a time. It takes time to switch off one head and turn on another (head switching latency). This time however, is much smaller than the time to move the assembly with the heads.

Disk Performance
Disk devices are manipulated by a bit of extra hardware that interface them with the CPU. These disk controllers shield the CPU from specific details of the disks providing it with a series of standard commands. Disk access time is the sum of seek, rotational latency, head switching latency, data transfer and overheads added by the disk controller.

Disk Performance Optimizations


Disks have internal memory to buffer data transferred in and out. They may also have internal caches to exploit the locality of accesses. Disk requests (read and writes) can be reordered to improve access performance. This reordering is also called scheduling and may be implemented by the disk system or left to the Operating System. Different algorithms are possible for disk access scheduling: FCFS, Shortest Seek First (may cause starvation), Elevator, etc.

Disk/CPU Communication
The CPU can execute many instructions in the time it takes to complete one disk access. It would be very inefficient to make the CPU issue disk commands and wait idle until the access is completed. Once an disk access is started, the CPU needs to learn when the access is completed. It can either discover completion by polling or by receiving an interrupt.

Disk/CPU Communication
The CPU can be involved in the transfer of data from disk to memory or just let someone else take care of it. Enter Direct Memory Access (DMA), a 3-step process handled by a specialized controller: 1. 2. 3. The CPU passes the DMA controller the id of the I/O device, a memory address and the number of bytes to transfer. The DMA controller performs the transfer byte-by-byte from the I/O device to the memory buffer. The DMA signals the end of the operation via some interrupt.

Note: Now we must provide this DMA controller with a direct path to memory

Connecting CPU, I/O and Memory


Processor Interrupts

Cache

MemoryI/O bus Memory-I/O BUS I/O controller I/O controller I/O controller

Main memory

Disk

Disk

Graphics output

Network

Mechanical Mouse
Whenever the mouse moves or the user clicks a button, the mouse sends 3 bytes of data to the CPU. The first byte's 8 bits contain left and right button states, X direction,Y direction, X overflow and Y overflow (if moved too fast). The 2nd and 3rd bytes contain the X movement value, and the Y movement value. This data is sent to the CPU serially. Onboard processor

10

Serial Mechanical Mouse


The values are sent serially on the data line, with the clock line pulsing to tell the computer where each bit starts and stops. Eleven bits are sent for each byte (1 start bit, 8 data bits, 1 parity bit and 1 stop bit). The PS/2 mouse sends on the order of 1,200 bits per second. That allows it to report mouse position to the computer at a maximum rate of about 40 reports per second. If you are moving the mouse very rapidly, the mouse may travel an inch or more in onefortieth of a second. This is why there is a byte allocated for X and Y motion in the data protocol. From http://www.howstuffworks.com

11

More Mouse Guts

Ball

Rollers

Light emitters and sensors

12

Optical Mouse

Take periodic snapshots of the working surface and compare successive pictures to estimate the distance the mouse has moved.

A little light to illuminate the surface. A sensor to capture an image of the surface.

13

Das könnte Ihnen auch gefallen