代写 algorithm socket operating system security Operating Systems Lecture 10b

Operating Systems Lecture 10b
Dr Ronald Grau School of Engineering and Informatics Spring term 2018

Previously 1
The I/O System
Interaction protocols Blocking vs. non-blocking I/O

Recap questions 2 1. Which general factors make the I/O system of an operating system complex?
2. How do OS designers cope with this complexity?
3. What can we do with a block device that we cannot with a character device?
4. What are the advantages/disadvantages of  Polling?
 Interrupt-driven I/O?  DMA?
5. What is the difference between blocking and non-blocking I/O?

Example: Programmed I/O 3

Example: Interrupt-Driven I/O 4

I/O Request Flow 5

I/O Queue 6

I/O Performance Optimisation 7 Disk operations in disk I/O queue
 Reorder requests to optimise access times?
 scheduling
Example: Disk scheduling  First Come First Served (FCFS)
Head moves 640 cylinders minimise head movement

I/O Performance Optimisation 8 Example: Disk scheduling
 Shortest Seek Time First (SSTF)
Head moves 236 cylinders

I/O Performance Optimisation 9 SCAN (elevator) algorithm:
 Move head back and forth in one direction moves head only 208 cylinders
 Variants: C-SCAN, LOOK, . . .
NOOP
 FCFS, but looks for adjacent requests and merges them  Low overhead
 Works well for SSD
 Used in Linux

Memory-Mapped Files 10
 Shared file access through shared memory  Synchronisation: copy-on-write
 Use paging system

Memory-Mapped Files 11

Memory-Mapped I/O 12 Problem: Page replacement
 Cannot evict page during an I/O request locking / pinning
Page caching:
 Physical memory written by DMA or I/O controller:
stale page  disable caching of page
HW support
 e.g. by page attributes

Direct I/O and Memory-Mapped I/O 13 Double buffering Unified buffer cache

I/O System Design 14
Efficiency
 I/O is often bottleneck of the system, i.e. CPU has to wait, processes are blocked, . . .  But: I/O devices types have different properties
 require specific solutions, i.e. disk scheduling for hard disks vs SSD Flexibility
 Many different devices with different properties, new devices must be easily supported, . . .
 But: uniform programming interface required, e.g. files uniform interface and device-specific behaviour

I/O System Design 15
I/O system call interface
 Provides uniform API (e.g. POSIX system calls)  Hardware-independent
Scheduling and control
 I/O queues, buffering, caching, . . .  (Mostly) hardware-independent
Device drivers
 Translate operations into device-specific commands  (Mostly) hardware-dependent

I/O System in the Linux Kernel 16

I/O System in the Linux Kernel 17
Uses loadable modules to install device drivers

Files vs Sockets 18

Summary
19
System call interface
 Uniform abstraction of I/O operations  Blocking vs non-blocking calls
I/O System
 Layered structure:
Hardware Abstraction Layer separating HW-dependent /-independent
 Device driver
 I/O controller
Interaction protocols  Polling, interrupts, DMA
I/O Scheduling and Optimisations
 Reduce blocking times by
reordering requests, e.g. disk scheduling
 Buffering, caching, memory-mapped I/O

Read 20  Tanenbaum & Bos., Modern Operating Systems
 Chapter 5
 Silberschatz et al., Operating System Concepts  Chapter 10 & 13

Next Lecture
21
 Introduction
 Operating System Architectures  Processes
 Threads – Programming
 Process Scheduling – Evaluation  Process Synchronisation
 Deadlocks
 Memory Management
 File Systems
 Input / Output
 Security and Virtualisation