17-22 Flashcards

1
Q

CPU is attached to the main memory of the system via a __.

Some devices are connected to the system via a __.

A

memory bus;

general I/O bus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

I/O Architecture:

Buses

A

Data paths provided to enable information between CPU(s), RAM, and I/O devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

I/O bus:

(2)…

A

• Data path that connects a CPU to an I/O device
• I/O bus is connected to I/O device by three hardware components:
- I/O ports
- Interfaces
- Device controllers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Canonical Devices have two important components:

(2)…

A
  1. Hardware interface allows the system software to control its operation
  2. Internals which is implementation specific
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Canonical Device:
Registers:
(3)…

A

By reading and writing these registers, the OS can control device behavior
1. status register
• See the current status of the device
2. command register
• Tell the device to perform a certain task
3. data register
• Pass data to the device, or get data from the device

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The Canonical Protocol:
Example of programmed I/O (PIO):
CPU is involved with the __.

A

data

movement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The Canonical Protocol:

Operating system waits until…

A

• Simple and correct
• Wastes CPU time just waiting for the device
- Switching to another ready process would utilize the CPU more

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Interrupts:

(2)…

A

• Put the I/O request process to sleep and context switch to another
• When the device is finished, wake the process waiting for the I/O by interrupt
- Allows for the CPU and the disk to be properly utilized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Polling vs. interrupts:

(3)…

A
  1. Interrupts are not always the best solution
    • If a device performs very quickly interrupts slow down the system
    - Context switches are expensive
  2. If a device is fast, polling is preferred
  3. If the device is slow, interrupts are better
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

More efficient data movement with DMA (Direct Memory Access)

A

CPU wastes a lot of time to copy a large chunk of data from memory to the device
• Copy one word at a time to the device
• After data is copied then it can be written to disk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Device interaction:
Two main ways to communicate with devices:
(2)…

A
  1. I/O instructions: a way for the OS to send data to specific device registers
  2. Memory-mapped I/O
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Device interaction:

  1. I/O instructions: a way for the OS to send data to specific device registers
    (2) …
  2. Memory-mapped I/O
    (3) …
A
  1. • E.g., in and out instructions on x86
    • Typically a privileged instruction – why?
  2. • Device registers available as if they were memory locations
    • The OS loads (to read) or stores (to write) to the device instead of main memory
    • No new instructions, same as a memory read or write
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The OS interface: the device driver:
Abstraction encapsulates any specifics of device interaction:
(3)…

A
  • At the lowest level, the OS must know how the hardware works
  • We call this software a device driver
  • Provides a higher-level interface to the rest of the system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Example Driver: File system Abstraction

(3)…

A

• Application is unaware of the type of file system
• File system is unaware of which type of disk it is using
- Issues block read/write requests to a generic block layer
• Many drivers expose a raw interface to allow for special applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Problems With Device Driver Abstraction:

• If there is a device with special capabilities, these capabilities will go unused in the __.

A

generic interface layer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Basic IDE Protocol:

(6)…

A
  1. Wait for drive to be ready
    • Read Status Register (0x1F7) until drive is not busy and READY
  2. Write parameters to command registers
    • Write the sector count, logical block address (LBA) of the sectors to be accessed, and drive number to command registers (0x1F2-0x1F6)
  3. Start the I/O
    • Write the READ/WRITE command to command register (0x1F7)
  4. Data transfer (for writes)
    • Wait until drive status is READY and DRQ (drive request for data)
    • Write data to data port
  5. Handle interrupts
    • In the simplest case, handle an interrupt for each sector transferred
    • DMA allows for batching and a final interrupt when the entire transfer is complete
  6. Error handling
    • After each operation, read the status register
    • If the ERROR bit is on, read the error register for details
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Basic IDE Protocol:
Wait for drive to be ready
(1)…

A

• Read Status Register (0x1F7) until drive is not busy and READY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Basic IDE Protocol:
Write parameters to command registers
(1)…

A

• Write the sector count, logical block address (LBA) of the sectors to be accessed, and drive number to command registers (0x1F2-0x1F6)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Basic IDE Protocol:

Start the I/O

A

• Write the READ/WRITE command to command register (0x1F7)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Basic IDE Protocol:
Data transfer (for writes)
(2)…

A
  • Wait until drive status is READY and DRQ (drive request for data)
  • Write data to data port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Basic IDE Protocol:
Handle interrupts
(2)…

A
  • In the simplest case, handle an interrupt for each sector transferred
  • DMA allows for batching and a final interrupt when the entire transfer is complete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Basic IDE Protocol:

Error handling

A
  • After each operation, read the status register

* If the ERROR bit is on, read the error register for details

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

I/O Summary:
For efficiency we use:
(2)…

A
  • Interrupts: allow process to sleep while slow I/O takes place
  • DMA: Allow transfer between memory and a device with little CPU intervention
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

I/O Summary:
Accessing Hardware:
(2)…

A
  • Explicit I/O instructions (inb outb)

* Memory mapped I/O (register access looks like a memory read or write)

25
Q

I/O Summary:
Drivers:
(2)…

A
  • Encapsulate low-level details of the hardware

* Makes it easier to build the rest of the OS in a device-neutral fashion

26
Q
Hard Disk Drives: 
Hard disk drives have been the main form of persistent data storage in computer systems for decades: 
1. The drive consists of \_\_.
(2)...
2. Address Space
• We can view the disk with \_\_.
A

a large number of sectors (e.g., 512-byte blocks);
• Arranged in circular tracks around the disk
• The only guarantee is that a single 512-byte write is atomic;

n sectors as an array of sectors, 0 to n-1

27
Q

Hard Disk Drives:
Multi-sector operations are possible:
(2)…

A

• Many file systems will read or write 4KB at a time (common page size)
• Torn write
- If an untimely power loss or error occurs, only a portion of a larger write may complete

28
Q

Hard Disk Drives:
__ is the fastest access mode:
(2)…

A

Accessing blocks in a contiguous chunk;

  • A sequential read or write
  • Much faster than any more random access pattern
29
Q

Basic Geometry:
Platter (Aluminum coated with a thin magnetic layer)
(3)…

A
  • A circular hard surface
  • Data is stored persistently by inducing magnetic changes to it
  • Each platter has 2 sides, each of which is called a surface
30
Q

Basic Geometry:
Spindle:
(2)…

A

• Spindle is connected to a motor that spins the platters around
• The rate of rotations is measured in RPM (Rotations Per Minute)
- Typical modern values : 7,200 RPM to 15,000 RPM
- E.g., 10000 RPM : A single rotation takes about 6 ms

31
Q

Basic Geometry:
Track:
(3)…

A
  • Concentric circles of sectors
  • Data is encoded on each surface in a track
  • A single surface contains many thousands and thousands of tracks
32
Q

A Simple Disk Drive:
Disk head (one head per surface of the drive)
(2)…

A
  • The process of reading and writing is accomplished by the disk head
  • Attached to a single disk arm, which moves across the surface
33
Q

Rotational delay: __

A

Time for the desired sector to rotate
• Read sector 0: Rotational delay = 𝑅/2 (average case)
• Read sector 5: Rotational delay = R (worst case)

34
Q

Multiple Tracks: Seek Time

Seek: __

A

move the disk arm to the correct track

• One of the most costly disk operations

35
Q

Multiple Tracks: Seek Time

Seek time: __.

A

time to move head to the track containing the desired sector

36
Q

Phases of Seek

A

Acceleration → Coasting → Deceleration → Settling

37
Q

Phases of Seek:
Acceleration → Coasting → Deceleration → Settling

  • Acceleration: __
  • Coasting: __
  • Deceleration: __
  • Settling: __
A

• Acceleration: The disk arm gets moving
• Coasting: The arm is moving at full speed
• Deceleration: The arm slows down
• Settling: The head is carefully positioned over the correct track
- The settling time is often quite significant, e.g., 0.5 to 2ms

38
Q

Transfer:
The final phase of I/O
• Data is __.

A

either read from or written to the surface

39
Q

Transfer:
Complete I/O time:
(3)…

A
  • Seek
  • Waiting for the rotational delay
  • Transfer
40
Q

Track Skew:

Make sure that sequential reads can be __.

A

properly serviced even when crossing track boundaries

41
Q

Track Skew:

Without track skew, __.

A

the head would be moved to the next track but the desired next block would have already rotated under the head

42
Q

Cache (Track Buffer):

(3)…

A
  1. Disk cache holds data read from or written to the disk
    • Allow the drive to quickly respond to requests
    • Small amount of memory (usually around 8 or 16 MB)
  2. Write back (Immediate reporting)
    • Acknowledge a write has completed when it has put the data in its memory
    • Faster but dangerous
  3. Write through
    • Acknowledge a write has completed after the write has actually been written to disk
    • Slower but safer
43
Q

Cache (Track Buffer):
Disk cache holds data read from or written to the disk
(2)…

A
  • Allow the drive to quickly respond to requests

* Small amount of memory (usually around 8 or 16 MB)

44
Q

Cache (Track Buffer):
Write back (Immediate reporting)
(2)…

A
  • Acknowledge a write has completed when it has put the data in its memory
  • Faster but dangerous
45
Q

Cache (Track Buffer):

Write through

A
  • Acknowledge a write has completed after the write has actually been written to disk
  • Slower but safer
46
Q

Disk Scheduler:

decides __.

A

which I/O request to schedule next

47
Q

Disk Scheduling:
SSTF (Shortest Seek Time First):
(2)…

A
  • Order the queue of I/O request by track

* Pick requests on the nearest track to complete first

48
Q

SSTF is not a panacea:

2 problems…

A
  1. Problem 1: The drive geometry is not available to the host OS
    • Solution: OS can simply implement Nearest-block-first (NBF)
  2. Problem 2: Starvation
    • If there were a steady stream of request to the inner track, request to other tracks would then be ignored completely
49
Q

Elevator (a.k.a. SCAN or C-SCAN):

Move across the disk servicing __.

A

requests in order across the tracks

50
Q

Elevator (a.k.a. SCAN or C-SCAN):

Sweep

A

A single pass across the disk
• If a request comes for a block on a track that has already been serviced on this sweep of the disk, it is queued until the next sweep

51
Q

Elevator (a.k.a. SCAN or C-SCAN):
F-SCAN
(2)…

A
  • Freeze the queue to be serviced when it is doing a sweep

* Avoid starvation of far-away requests by nearer by late coming requests

52
Q

Elevator (a.k.a. SCAN or C-SCAN):

C-SCAN (Circular SCAN)

A

• Sweep from outer-to-inner, and then inner-to-outer, etc.

53
Q

How to account for Disk rotation costs?
• If rotation is faster than seek : request 16 → __.
• If seek is faster than rotation : request 8 → __.

A

request 8;

request 16

54
Q

On modern drives, both seek and rotation are roughly equivalent: Thus, __ is useful

A

SPTF (Shortest Positioning Time First)

55
Q

Where is disk scheduling performed?:
Older systems:

A

OS did all the scheduling

56
Q

Where is disk scheduling performed?:
Newer systems:
(3)…

A

• Disks can handle multiple outstanding requests
• Disks have sophisticated internal schedulers
- Exact head position is available
- Can implement SPTF accurately
• OS issues a small number of disk requests (e.g., 16) and issues them all at once
- Disk calculates the best possible SPTF order

57
Q

Scheduling issues:
I/O Merging

A

Reduces the number of request sent to the disk and lowers overhead
• E.g., read blocks 33, then 8, then 34:
- The scheduler merge the request for blocks 33 and 34 into a single two-block request

58
Q

Scheduling issues:
How long to wait before issuing an I/O request?
(2)…

A

• Work-conserving – Issue I/O request right away
- Disk will never be idle if there are requests to serve
• Non-work-conserving – wait a little bit before issuing I/O request
- A new and better request might arrive at the disk, increasing efficiency

59
Q

https://cs334.cs.vassar.edu/slides/19_Files_and_Directories.pdf

A

s