I/O Flashcards

1
Q

What are some ways a computer can do I/O?

A
  • Interrupt-driven I/O
  • Memory-mapped I/O
  • Port I/O
  • System I/O

Only system I/O is available because our ARM servers are running a Linux OS

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

How do user-level programs communicate with external devices?

A

through OS to prevent malicious or accidental interactions

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

OS/program communication diagram

A

check notes

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

How does a program running in EL0 do I/O and describe the process

A

Does a system call
- generates an exception using svc instruction
- like a subroutine call:
- control transferred to a predefined system function. address for this is stored in the OS
- system code executes @ EL1 (able to interact directly w/I/O devices)

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

How is the type of system call determined?

A

By the number put into x8 before svc

56: openat
57: close
63: read
64: write

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

Where do system call args go?

A

x0-x5 and return values in x0

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

In UNIX, how are all peripheral devices represented?

A

as files

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

What is the typical I/O pattern?

A
  1. open file (connect to device, get fd)
  2. read/write to file
  3. close file (disconnect from device)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Difference btw file & standard I/O

A

File: interact w/ secondary mem
Standard: keyboard & screen devices

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

How do you ensure that the fd is relative to the cwd?

A

AT_FDCWD (the value -100)

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

What are flags?

A

A combination of constants (using |) indicating what will be done to the files

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

Read-only flag
Write-only flag
read/write flag

A

O_RDONLY 00
O_WRONLY 01
O_RDWR 02

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

Optional flags:
Create file
Fail if file exists
Truncate file
Append access

A

O_CREAT: 0100
O_EXCL: 0200
O_TRUNC: 01000
O_APPEND: 02000

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

What is the mode?

A

An optional argument that specifies UNIX file permissions

  • only required when creating a file
  • specified in octal
  • eg: 0700 specifies r/w/execute permission for ONLY the file owner
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the fd return on error?

A

-1

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

What is the buffer?

A

Usually a local variable where bytes read will be stored

17
Q

What is standard I/O

A

keyboard/screen I/O
- I/O streams predefined by OS
- Always available (not open or closed)

18
Q

What is standard input (stdin) and its file descriptor?

A

input from the keyboard with fd 0

19
Q

What is standard output (stdout) and its file descriptor?

A

output to the monitor screen with fd 1

20
Q

What is standard error (stderr) and its file descriptor?

A

Also represents output to monitor screen with file descriptor 2

21
Q

Why is the svc instruction used?

A

To request a service or resource from the OS or higher privileged mode