1/37
These flashcards cover critical concepts related to input and output in systems programming, focusing on Unix I/O and Standard I/O as discussed in the lecture.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
File Descriptor
A small integer representing an open file in a particular process.
Kernel System Calls
Low-level functions that provide access to operating system services.
Standard Input
The file descriptor that refers to standard input (usually keyboard input).
Standard Output
The file descriptor that refers to standard output (usually display screen output).
Standard Error
The file descriptor that refers to standard error output.
Open Flags
Parameters that control the behavior of the open() function.
O_RDONLY
Open file for reading only.
O_WRONLY
Open file for writing only.
O_RDWR
Open file for reading and writing.
O_CREAT
Create a file if it doesn’t exist when opening.
O_EXCL
fail if the file already exists when creating a file.
O_APPEND
Start writing at the end of the file.
O_TRUNC
Truncate the file to zero length when opening.
O_CLOEXEC
Close this file descriptor on exec.
/dev/null
A special file that discards all data written to it.
/dev/urandom
A special file that provides cryptographically secure random data.
read()
A system call that reads data from an open file, returning the number of bytes read.
write()
A system call that writes data to an open file, returning the number of bytes written.
close()
A system call that closes an open file descriptor.
fopen()
A standard I/O function that opens a file stream.
fdopen()
Associates a file descriptor with a stream.
fread()
Reads binary data from a stream.
fwrite()
Writes binary data to a stream.
feof()
Checks if the end of file has been reached, returning non-zero if true.
ferror()
Checks if an error has occurred on a stream, returning non-zero if an error exists.
clearerr()
Resets the error and EOF indicators for a stream.
Buffering
A method used to improve performance by temporarily storing data in memory.
fflush()
Flushes the output buffer of a stream, ensuring all data is outputted.
Buffer Flushing
Process of writing data from the buffer to the file.
errno
A global variable set to indicate the error state for system calls.
perror()
Produces a human-readable error message based on errno.
strerror()
Returns a pointer to the textual representation of the current errno.
POSIX
A family of standards specified by the IEEE for maintaining compatibility between operating systems.
C Standard
A standard that describes the programming language C.
Atomic Action
An operation that completes in a single step relative to other operations.
Buffer Example
A method of reading data where larger chunks are read into memory for future access.
System Call Overhead
The time and resources consumed when making a system call.
Unix I/O vs Standard I/O
Unix I/O is low-level and uses file descriptors, while Standard I/O is higher-level and uses streams.