1 of 16

1

CS644 week 9:

Advanced I/O

2 of 16

Problem – I want to do lots of I/O at once

2

3 of 16

Problem – I want to do lots of I/O at once

(not disk I/O)

3

4 of 16

Example: Web server with many clients

4

Problem – I want to do lots of I/O at once

5 of 16

Example: SSH client

(reading/writing from terminal and network socket)

5

Problem – I want to do lots of I/O at once

6 of 16

Solution: multithreading

6

Problem – I want to do lots of I/O at once

7 of 16

Solution: multithreading

…but that complicates your program

7

Problem – I want to do lots of I/O at once

8 of 16

O_NONBLOCK – non-blocking reads/writes

8

Problem – I want to do lots of I/O at once

9 of 16

O_NONBLOCK – non-blocking reads/writes

…but leads to busy polling, wastes CPU

9

Problem – I want to do lots of I/O at once

10 of 16

epoll – I/O multiplexing

10

Problem – I want to do lots of I/O at once

11 of 16

epoll – I/O multiplexing

Tell the OS you want to read fd1, fd2, …, then block until one is ready

11

Problem – I want to do lots of I/O at once

12 of 16

io_uring – modern I/O multiplexing

12

Problem – I want to do lots of I/O at once

13 of 16

io_uring – modern I/O multiplexing

  • Can do ops with fewer (or no!) syscalls

13

Problem – I want to do lots of I/O at once

14 of 16

io_uring – modern I/O multiplexing

  • Can do ops with fewer (or no!) syscalls
  • OS will do the I/O instead of just notifying

14

Problem – I want to do lots of I/O at once

15 of 16

io_uring – modern I/O multiplexing

  • Can do ops with fewer (or no!) syscalls
  • OS will do the I/O instead of just notifying
  • Operations can be chained

15

Problem – I want to do lots of I/O at once

16 of 16

Office hours

16