78
1 Input/Output

Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

1

Input/Output

Page 2: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

2

I/O Hardwares

Some typical device, network, and data base rates

Page 3: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

3

Device Controllers

• I/O devices have components:

– mechanical component

– electronic component

• The electronic component is the device

controller

– may be able to handle multiple devices

• Controller's tasks

– convert serial bit stream to block of bytes

– perform error correction as necessary

Page 4: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

4

Device Driver Interface

Device Interface

Printer

Driver

Disk

Driver

Printer

Controller

Disk

Controller

•Device interface is standard for all the I/O devices and in POSIX compliant systems it consists of

Open(), Close(), Read(), Write(), Seek(), and Control() functions.

•Drivers implement the device interface functions specific to a device

Page 5: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

5

Device Management

• Device manager is responsible to provide services to the

file manager and application software.

• It has a device independent infrastructure and a collection

of device-dependent drivers

Page 6: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

6

I/O Strategies

• I/O with polling

• I/O with interrupts

• DMA I/O

Page 7: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

7

I/O With Polling

• CPU is responsible for

– determining if the I/O operation has completed

– Transferring the data between the main memory and the device

controller data registers

• Steps for performing direct I/O with polling (for read operation)

1. Application process requests a read operation

2. The device driver queries the status register to determine if the device is

idle. If the device is busy, the driver waits for it to become idle.

3. The driver stores an input command into the controllers command

register, starting the device

4. The driver repeatedly reads the status register while waiting for the

device to complete the operation

5. The driver copies the contents of the controller’s data registers into the

user’s process space.

Page 8: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

8

I/O With Interrupts

• Polling wastes CPU cycles. Interrupts eliminate the need for the

device driver to constantly poll the controller status register

• Instead of polling, the device controller automatically notifies the

device manager when the operation is complete.

• Device manager should have the following parts

– The driver part that initiates the operation

– Device status table

– Interrupt handler

– Device handler

Page 9: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

9

I/O With Interrupts

An input operation using interrupts

1. The application process requests a read operation

2. The device driver queries the status register to determine if the

device is idle. If the device is busy, the driver waits for the device to

become idle

3. The device driver stores an input command into the controllers

command register starting the device

4. The device driver saves information regarding the operation that it

began in the device status table. This table contains an entry for

each device in the system. The information saved is the return

address of the original call, and any special parameters for the I/O

operation.

5. The device manager invokes the scheduler (so that some other

process can use the CPU) and terminates

Page 10: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

10

I/O With Interrupts

5. When the device completes the operation, it interrupts the CPU, and

causes the interrupt handler to run

6. The interrupt handler determines which device caused the interrupt,

and branches to the device handler for that device

7. The device handler retrieves the pending I/O status information

from the device status table

8. The device handler copies the contents of the controller’s data

registers into the user process’s space

9. The device handler returns control to the application process

Page 11: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

11

I/O with DMA

• Used when the hardware has a DMA controller

• DMA controller has access to the system bus independent of the CPU.

• Contains several registers that can be written and read by the CPU

– The control registers specify the I/O port to use, the direction of transfer,

and the unit of transfer

– Memory address register specifies where to write or read

– Byte count register specifies the amount read or written

Page 12: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

12

Memory-Mapped I/O (1)

• Separate I/O and memory space

• Memory-mapped I/O

• Hybrid

Page 13: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

13

Memory-Mapped I/O (2)

(a) A single-bus architecture

(b) A dual-bus memory architecture

Page 14: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

14

Interrupts Revisited

How interrupts happens. Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires

Page 15: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

15

Disks Disk Hardware (1)

Disk parameters for the original IBM PC floppy disk and a Western Digital WD 18300 hard disk

Page 16: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

16

Disk Hardware (2)

• Physical geometry of a disk with two zones

• A possible virtual geometry for this disk

Page 17: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

17

Disk Hardware (5)

Recording structure of a CD or CD-ROM

Page 18: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

18

Disk Hardware (6)

Logical data layout on a CD-ROM

Page 19: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

19

Disk Hardware (7)

• Cross section of a CD-R disk and laser

– not to scale

• Silver CD-ROM has similar structure

– without dye layer

– with pitted aluminum layer instead of gold

Page 20: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

20

Disk Hardware (8)

A double sided, dual layer DVD disk

Page 21: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

21

Disk Formatting (1)

A disk sector

Page 22: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

22

Disk Formatting (2)

An illustration of cylinder skew

Page 23: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

23

Disk Formatting (3)

• No interleaving

• Single interleaving

• Double interleaving

Page 24: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

24

Disk Arm Scheduling Algorithms (1)

• Time required to read or write a disk

block determined by 3 factors

1. Seek time

2. Rotational delay

3. Actual transfer time

• Seek time dominates

• Error checking is done by controllers

Page 25: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

25

Disk Arm Scheduling Algorithms

• FCFS: First Come First Served

– Assume that the initial disk arm position is on cylinder 11

(cylinders are numbered starting from 0)

– If the new requests are 1, 36, 16, 34, 9, 12 (these are cylinder

numbers)

– Then total of 10 + 35 + 20 + 18 + 25 +3 = 111 cylinders will be

traversed

• SSF : Shortest Seek First

– What is the total number of cylinders traversed for the same

requests, 1, 36, 16, 34, 9, 12 ?

• The arm motions of SSF is depicted in the next slide

Page 26: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

26

Disk Arm Scheduling Algorithms (2)

Shortest Seek First (SSF) disk scheduling algorithm

Initial

position

Pending

requests

Page 27: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

27

SSF

• What could be the disadvantage of SSF?

• Elevator algorithm is proposed to overcome the

disadvantages:

– The direction of the disk arm is important for scheduling decisions

– Disk arm direction going towards higher cylinder numbers is

called UP, and the reverse is called DOWN

– After the current request was processed the next request that is

closest in the direction of the disk arm is processed

– Assuming the disk arm direction is UP, and the requests are :

1,36,16, 34, 9, 12 then what would be the total number of cylinders

traversed?

Page 28: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

28

Disk Arm Scheduling Algorithms (3)

The elevator algorithm for scheduling disk requests

Page 29: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

29

Error Handling

• Metal oxide coating

• The linear recording density has limits (ex

5000bits/mm)

• High recording density means higher

manufacturing errors

Page 30: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

30

Error Handling

• Bad sectors result from manufacturing

defects

• ECC can be used to handle a few defected

bits

• Bigger errors can be handled by

– Controller

– OS

Page 31: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

31

Error Handling

• A disk track with a bad sector

• Substituting a spare for the bad sector

• Shifting all the sectors to bypass the bad one

Page 32: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

32

Error Handling

• Errors may occur during the normal operation of

the disk which may be

– Transient (dust etc)

– Can be fixed by the ECC

– Repeated errors: spare sectors should be used before the

sector dies completely

Page 33: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

33

Error Handling

• OS can handle bad sectors by re-mapping tables

– Read the entire disk to construct a list of bad sectors

– Both allocated and free blocks need to be tested

– Backup system should also consider bad sectors

• Seek errors may also occur if the disk head can not

be positioned in the right track

• The disk dead needs to be recalibrated when such

an error occurs

Page 34: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

34

RAID

• SLED : Single Large Expensive Disk

• The speed of Mechanic v.s. Electronic components

• Parallelism in CPU proved to be effective

• Why not parallelism in I/O? (by Patterson et.al. 1988)

– RAID (Redundant Array of Inexpensive Disks)

• Adopted by the industry as Redundant Array of

Independent Disks

Page 35: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

35

RAID

• RAID is a set of disks with a single RAID controller

• Its aim is to improve the fault tolerance and performance with a reasonable cost

• The disks in RAID appear as a single disk to the OS

• There are six different RAID organizations (0…5)

– RAID level 0 : Data striping is employed, i.e., the whole disk consists of strips of size “k-sectors” partitioned into individual disks in round robin fashion

– There is no redundant data storage in this approach

– Is this better for requests of larger or smaller chunks of read requests?

– No performance gain if the requests are one sector at a time!

– What about reliability?

Page 36: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

36

Page 37: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

37

RAID

• There are six different RAID organizations (0…5)

– RAID level 1: Data striping is used. It also duplicates all the disks.

Page 38: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

38

•In the above case we have 4 primary disks and 4 backup disks

•Every strip is written twice!

•Either of the two copies could be read!

Page 39: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

39

–How do you think the read and write performance is in RAID level 1?

–Is it fault tolerant?

Page 40: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

40

–How do you think the read and write performance is in RAID level 1?

–Is it fault tolerant?

•Write performance is the same

•Read performance can be twice as good

•Fault tolerance is excellent

•Recovery is easy, buy a new drive, and replace it with the one that crashed

Page 41: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

41

RAID

• There are six different RAID organizations (0…5)

– RAID level 2: Works in very small granularity striping with hamming code for error detection and correction. For example a byte is divided into 4bit chunks, and 3 parity bits are added to form a 7 bit word which is partitioned bit by bit to 7 disks. Disk drives must be synchronized for read and write.

Page 42: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

42

–RAID level 2: Works in very small granularity striping with

hamming code for error detection and correction.

–For example a byte is divided into 4bit chunks, and 3 parity bits

are added to form a 7 bit word which is partitioned bit by bit to 7 disks.

Disk drives must be synchronized for read and write.

Page 43: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

43

RAID

• RAID organizations cont’d (0…5)

– RAID level 3 : simplified version of level 2, where only checksum

is stored. It can do error detection but not error correction in case

there are random bit errors. What would be the effect of a single

disk crash?

– RAID level 4: use data striping. With a strip of k bytes, an extra

disk drive stores k-byte long parities constructed by performing an

exclusive or on the strips in each disk.

– RAID level 5: It is like RAID level 4, but parity bits are distributed

over the RAID disks to reduce the risk induced by parity disk

crash.

Page 44: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

44

RAID

• RAID organizations cont’d (0…5)

– RAID level 3 : simplified version of level 2, where only checksum

is stored. It can do error detection but not error correction in case

there are random bit errors. What would be the effect of a single

disk crash?

•Assume that one of the drives crashes, can we do •Error detection

•Error correction!

Page 45: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

45

Disk Hardware (4)

• Raid levels 3 through 5

• Backup and parity drives are shaded

Page 46: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

46

Stable Storage

• RAID deals with correct reads and fault tolerance

against crashes

• How about writes?

• Desired Property:

– When a write is issued, the disk either correctly writes

the data or it does nothing at all (Called Stable Storage)

Page 47: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

47

Stable Storage

• Following can be handled:

– A written sector can suddenly become unreadable

– CPU can fail leading to incorrect data

• Following can not be handled:

– Student drops the computer out of the window of a

skyscraper

– Student sets the computer room on fire

– Natural disasters

Page 48: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

48

Stable Storage • Stable storage uses a pair of identical disks with the

corresponding blocks form an error-free block

• Stable write:

– Write the block on drive 1

– Read it back and verify it, if not correct repeat the operation

– After n consecutive failures the block is remapped to a spare one

and the operation continues

– After the write to drive 1 succeeds, the corresponding block on

drive 2 is written and re-read until it succeeds

– After the stable write completes, the block is successfully written

to both drives

Page 49: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

49

Stable Storage • Stable storage uses a pair of identical disks with the

corresponding blocks form an error-free block

• Stable read:

– First read from drive 1

– If the ECC indicates and error, then reread

– If after n iterations, the error occurs, then the corresponding block

is read from drive 2

• Assumption: probability that the same block in both drives

will go bad is practically 0

Page 50: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

50

Stable Storage • Crash recovery

– Scan both disks and compare the corresponding blocks

– If one of the has ECC error, then the good one is written over the

bad one

– If both have ECC good, but they are different, then the block in

drive 1 is overwritten to drive 2.

Page 51: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

51

Stable Storage

Analysis of the influence of crashes on stable writes

Page 52: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

52

Clock Hardware

A programmable clock – Generates a CPU interrupt when the counter is 0

– These are called clock ticks

– Can be programmed to occur very 2 nsecs to 8.6 secs

Computers also have battery-powered to recover the current time when the computer is turned on

Original starting time for windows is 12 AM Jan 1, 1980. For Unix, it is 12 AM, Jan 1 1970.

Page 53: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

53

Clock Software

• Clock drivers job:

– Maintain time of day

– Prevent processes from running longer than

they are allowed to

– Accounting CPU usage

– Providing watchdog timers

– etc

Page 54: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

54

Clock Software (1)

Three ways to maintain the time of day

Page 55: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

55

Simulating multiple virtual clocks

• Maintain a table

• The signal times for all pending timers stored in

the table

• Whenever the time of day is updated, the driver

checks to see if the closest signal has occured

Page 56: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

56

Clock Software (2)

Pending signals are for 4203, 4207, 4213, 4215, 4216

Simulating multiple timers with a single clock

Page 57: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

57

ALS

– Assume that the initial disk arm position is on cylinder

11 (cylinders are numbered starting from 0)

– If the new requests are 1, 36, 16, 34, 9, 12 (these are

cylinder numbers)

– Total number of tracks traversed by

• SSF?

• Elevator?

Page 58: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

58

Character Oriented Terminals RS-232 Terminal Hardware

• An RS-232 terminal communicates with computer 1 bit at a time

• Called a serial line – bits go out in series, 1 bit at a time

• Windows uses COM1 and COM2 ports, first to serial lines

• Computer and terminal are completely independent

Page 59: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

59

• Central buffer pool

• Dedicated buffer for each terminal

Input Software (1)

Page 60: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

60

Input Software (2)

Characters handled specially in canonical mode

Page 61: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

61

Output Software

The ANSI escape sequences • accepted by terminal driver on output • ESC is ASCII character (0x1B) • n,m, and s are optional numeric parameters

Page 62: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

62

Display Hardware (1)

Memory-mapped displays

• driver writes directly into display's video RAM

Parallel port

Page 63: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

63

Display Hardware (2)

• A video RAM image

– simple monochrome display

– character mode

• Corresponding screen

– the xs are attribute bytes

Page 64: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

64

Input Software

• Keyboard driver delivers a number

– driver converts to characters

– uses a ASCII table

• Exceptions, adaptations needed for

other languages

– many OS provide for loadable keymaps

or code pages

Page 65: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

65

Output Software for Windows (1)

Sample window located at (200,100) on XGA display

Page 66: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

66

Output Software for Windows (2)

Skeleton of a Windows main program (part 1)

Page 67: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

67

Output Software for Windows (3)

Skeleton of a Windows main program (part 2)

Page 68: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

68

Output Software for Windows (4)

An example rectangle drawn using Rectangle

Page 69: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

69

Output Software for Windows (5)

• Copying bitmaps using BitBlt.

– before

– after

Page 70: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

70

Output Software for Windows (6)

Examples of character outlines at different point sizes

Page 71: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

71

Network Terminals X Windows (1)

Clients and servers in the M.I.T. X Window System

Page 72: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

72

X Windows (2)

Skeleton of an X Windows application program

Page 73: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

73

The SLIM Network Terminal (1)

The architecture of the SLIM terminal system

Page 74: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

74

The SLIM Network Terminal (2)

Messages used in the SLIM protocol from the server to the terminals

Page 75: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

75

Power Management (1)

Power consumption of various parts of a laptop computer

Page 76: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

76

Power management (2)

The use of zones for backlighting the display

Page 77: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

77

Power Management (3)

• Running at full clock speed

• Cutting voltage by two

– cuts clock speed by two,

– cuts power by four

Page 78: Input/Output - Sabancı Üniversitesipeople.sabanciuniv.edu/ysaygin/documents/lectures/CS307... · 2013-12-17 · An input operation using interrupts 1. The application process requests

78

Power Management (4)

• Telling the programs to use less energy

– may mean poorer user experience

• Examples

– change from color output to black and white

– speech recognition reduces vocabulary

– less resolution or detail in an image