I/O Flashcards
What are some ways a computer can do I/O?
- 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 do user-level programs communicate with external devices?
through OS to prevent malicious or accidental interactions
OS/program communication diagram
check notes
How does a program running in EL0 do I/O and describe the process
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 is the type of system call determined?
By the number put into x8 before svc
56: openat
57: close
63: read
64: write
Where do system call args go?
x0-x5 and return values in x0
In UNIX, how are all peripheral devices represented?
as files
What is the typical I/O pattern?
- open file (connect to device, get fd)
- read/write to file
- close file (disconnect from device)
Difference btw file & standard I/O
File: interact w/ secondary mem
Standard: keyboard & screen devices
How do you ensure that the fd is relative to the cwd?
AT_FDCWD (the value -100)
What are flags?
A combination of constants (using |) indicating what will be done to the files
Read-only flag
Write-only flag
read/write flag
O_RDONLY 00
O_WRONLY 01
O_RDWR 02
Optional flags:
Create file
Fail if file exists
Truncate file
Append access
O_CREAT: 0100
O_EXCL: 0200
O_TRUNC: 01000
O_APPEND: 02000
What is the mode?
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
What does the fd return on error?
-1