1/24
Looks like no tags are added yet.
System calls
used to request a server from an OS kernel
a core component of both linux and windows
are made with a special machine instruction
File descriptors
an index of type int for a table of open files
Short count
the read() or write() system calls are unable to read or write the number of bytes requested
const
the function will not modify the data pointed to by the pointer x
pipe (the | symbol)
redirects a program’s standard out to another program’s standard in
Do C i/o fucntion fread() and fwrite() use system calls? If so, when?
They primarily use system calls when a buffer needs to be filled or emptied
When is write() used with unbuffered C file streams to copy data to the underlying file?
Any time the file stream is written to
What is false about erno?
It is a kernel variable that can only be read and written using system calls
What features does GNU Debugger have?
It allows you to pause and resume execution of a program and inspect variables to locate bugs.
What is false virtual memory?
It can never be larger than physical RAM
What is a process’s stack memory segment used for? What data does it store?
Function parameters, local vars and CPU state
What is a process’s environment?
A set of name=value strings
How does malloc work?
It fills memory requests from unused heap space; or expands the heap with brk() if needed
Signals may be generated due to
processes terminating
in response to hardware exceptions
in response to user activity
system calls
A signal’s disposition may be set to
default action, ifgore, or a handler function
What is the purpose of the signal mask?
signal numbers set in the mask are blocked and will remain pending rather than be delivered
The smallest unit of code that can’t be interrupted by a signal handler is?
a single machine instruction
SIGKILL and SIGTERM are both intended to terminate a process. What’s the difference between them?
SIGKILL can’t be caught/handled or blocked
exit handlers
never interrupt normal program flow the way a signal handler does
int main(void) {
int f = fork();
if (f == 0) { //child
printf("1");
} else if (f > 0) { //parent
printf("2");
}
printf("B"); }
21BB, 12BB, 2B1B, 1B2B
The wait family of functions
allows a process to collect a status from a terminated child process
What is considered abnormal termination of a process?
When a signal is delivered with default disposition requiring termination
What happens to orphaned processes?
They are adopted by the system init process
What is a race condition?
When two processes, or a signal handler and other parts of a program access the same resource, and program output depends on which runs first
What does execve() do?
It executes a new program by overwriting the code and data of the process that called it