Lecture 19-20: Asynchronous I/O

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/27

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering key terms from Lecture 19-20 on synchronous vs asynchronous I/O, signals, fcntl, POSIX AIO, and diagnostic tools.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

28 Terms

1
New cards

Synchronous I/O

Input/Output operations that block program execution until the operation completes, e.g., reading from stdin with scanf or cin.

2
New cards

Asynchronous I/O

I/O operations that allow a program to continue executing while the operation is in progress, enabling non-blocking interaction with users or devices.

3
New cards

stdin (Standard Input)

Default file descriptor 0; a synchronous input stream that blocks when a program waits for user input.

4
New cards

stdout (Standard Output)

Default file descriptor 1; a synchronous output stream that can block if the terminal cannot accept more data.

5
New cards

Blocking

Program execution is halted until an I/O operation finishes; characteristic of synchronous I/O.

6
New cards

Non-blocking

Program execution continues while an I/O request is handled in the background; characteristic of asynchronous I/O.

7
New cards

Level Tracking

Monitoring the state of every possible item in a fixed list, even when few change; potentially expensive in memory and time.

8
New cards

Edge Tracking

Monitoring only when state changes occur, making it efficient for large sets where few elements change, e.g., active web-server connections.

9
New cards

Thread-based I/O Solution

Using separate threads to perform I/O and computation concurrently, synchronized with mutexes, waits, or signals.

10
New cards

SIGIO

A POSIX signal sent to a process when a file descriptor becomes ready for input or output; disabled by default.

11
New cards

fcntl()

System call that manipulates file-descriptor flags and properties: int fcntl(int fd, int cmd, …).

12
New cards

F_SETFL

fcntl command used to set file-descriptor flags such as O_ASYNC.

13
New cards

O_ASYNC

File-descriptor flag that enables delivery of SIGIO signals when the descriptor is ready.

14
New cards

F_SETOWN

fcntl command that designates which process (by PID) receives SIGIO for a given file descriptor.

15
New cards

F_GETFL

fcntl command that retrieves current file-descriptor flags before modification.

16
New cards

File Descriptor (fd)

Integer handle used by the kernel to access files, sockets, or pipes; 0, 1, 2 correspond to stdin, stdout, stderr.

17
New cards

stty raw

Terminal setting that disables line buffering and character echo, giving programs unprocessed input.

18
New cards

stty cooked

Default terminal mode that processes special characters (e.g., backspace, arrow keys) and echoes user input.

19
New cards

POSIX AIO

Library interface providing asynchronous I/O operations (aioread, aiowrite) with configurable notifications.

20
New cards

aiocb

Control block struct used by POSIX AIO to describe an asynchronous I/O request (file descriptor, buffer, size, sigevent, etc.).

21
New cards

aio_read()

POSIX function that queues an asynchronous read request defined by an aiocb structure.

22
New cards

aio_error()

Function that queries the status of a pending asynchronous I/O request, returning 0 on success or an error code.

23
New cards

aio_return()

Function that retrieves the result of a completed asynchronous I/O request, e.g., number of bytes read.

24
New cards

struct sigevent

Structure inside aiocb that specifies how a process is notified when an AIO operation completes (e.g., SIGEV_SIGNAL with SIGIO).

25
New cards

SIGEV_SIGNAL

sigevent notification type indicating completion is reported by sending a specified signal to the process.

26
New cards

Threads vs Signals

Two paradigms for asynchronous I/O: threads create concurrent execution contexts; signals deliver asynchronous notifications within one thread.

27
New cards

strace

Linux tool that intercepts and logs system calls and signals made by a process; invoked with strace ./program (use -f to trace forked children).

28
New cards

-lrt

Linker flag that links the real-time library (librt) containing POSIX AIO functions.