Final Review Flashcards
Explain the behind the scene steps behind “gcc” command
- The C preprocessor processed macros (#define and #include) in
the source code (“.c” file) and produced a new source code file
(unnamed)
2. The **C compiler** processed the output of the C preprocessor into assembly language code (“.s” file).
- The assembler processed the assembly language file and produced a
binary object file (“.o” file). - The linker combined the object file with necessary libraries and produced
the executable file (“a.out”).
What does it mean that C is “weakly typed”?
This means the compiler assumes the programmer knows what she/he is doing and allows casting of anything to anything else.
Explain the two types of C conversions: Explicit vs. Implicit.
What is a variable?
Memory that can hold the value. *Note: the deault value is mostly undefined, so treat it as random idea before initilization
List the components that everyta variable in C has.
When and where is the size of variable determined when a global variable is created? A local variable? A dynamic data varaible?
- Global data variables at compile time (.data)
- local data vairable at run-time (stack)
- dynamic data variables by the programmer (heap)
What is a pointer?
a variable continaing the address of another variable
(when initiated without a value, points to a random location in memory)
If we have the 2D array
int weekends[52][2];
What is the equivalent of weekends[3][1] in pointer arithmetic?
*(weekends + (3*2) + 1)
NOTE: “*” surrounds everything
General formula:
arr[r][c] = *(arr + (r*num_cols) + c)
All data objects of type FILE *…
- can be connected to file system files for reading and writing
- represent a buffered systemf chars (bytes) to be written or read
What do processors do?
From startup to shut down, CPU simply readsnd executes (intereprets) a sequence of instructions, one at a time… this sequenece is called the CPU’s control flow (of flow of control)
Define exception
An execpetion is a transfer of control to the OS kernel in response to some event (i.e. change in processor state)
What are asynchronous events/ interrupts?
What are synchonous exepctions?
Exceptions caused by events that occur as a result of executing an instruction. This includes:
- Traps
- Faults
- Aborts
Explain a Trap Exception and provide examples.
- Intentional, returns control to “next” instruction
- EX. system calls, breakpoint traps, special instructions
Explain Fault Exception and give an example.
- Unintential but possibly recoverable, either re-exectues faulting/current instruction or aborts
- EX: page fualts (recoverable), rotection faults (unrecoverable), floating point exceptions
Explain abort exceptions and provide an example.
- Unintentional and unreciverable, aborts the current program
- EX: llegal instruction, party error, machine check
What are exception tables?
What is a process?
A process is in an instance of a running programnd provides each program with two key abstractions
Explain the three states a process could be in.
What is the kernel?
The kernel is a shared chunk memory-resident OS code that manages processes
What is context switching?
Context switching is when control flow passes from one process to another.
Some examples of causes could be
- OS scheduling processs
- Kernel executing a system for user
- interrupts
Explain fork()
What are the three reasons a process becomes terminated?
1) Recieving a signal whose default action is to terminate
2) Returning from the main routine
3) Calling the exit function
Explain exit()
Explain reaping child processes.
Explain wait()
What macros can we use to get information about the exit status of a child process?
WIFEXITED and WEXITSTATUS
explain waitpid()
explain execve()
What is a signal in terms of ECF (Exceptional Control Flow)?