Final Flashcards
Linking that happens when a program is running or starting to run
Dynamic linking
Where do global constants and variables go?
In the AR for the main block
These are examples of what?
- Ready
- Running
- Waiting
- Suspended
- End
- Abend
Process States
Process state:
On stand by until I/O finishes
Waiting
What are the main sections of an object file?
header, text (code), data, relocation, debugging info
puts the OS in memory and starts running it
Boot(strap) loader
Allows the IR to specify a call target (address) that will be determined later
label
Assemblers relieve the tedium of machine code by:
- translating names to locations
- translating mnemonics to opcodes
- translating decimal to binary
Process state:
Finished execution
End
Why does a PCB contain the BP, SP, and PC?
If we need to stop the process, need this information recorded, so can restart it
+ simple to implement
+ good performance
- complex code and hard to maingain
- any crash crashes entire OS
Monolithic OS
What must an assembler do if a computer architecture has jumps to absolute addresses?
Translate jumps relative to PC to absolute addresses
How many passes would a linker need?
two: one to lay out the code (and build a symbol table), and another to fill in addresses
Records information from static analysis, including attributes of names used.
Intermediate Representation (IR)
- Stores local variables
- gives each recursive call its own locals
Activation Records (ARs)
Pushes the static link (the BP value) on the stack, then it pushes the old value of BP on the stack (the dynamic link), then it pushes the return address (old PC) on the stack
CAL
If some variables were dynamically scoped, how would they be addressed?
Use the old BP as the dynamic link, and look back through the dynamic links
An area of program text where declarations are effective and in which duplicate declarations are prohibited.
Scope
What mode does an interrupt execute in?
kernel (supervisory) mode
code that is called (run) in response to an interrupt occurring
Interrupt handler
In assembly language, names are abstractions of
data locations and addresses in program space
What addresses would need to be relocated and would need to be marked as such?
labels (jump targets), data names (for globals)
What should be the mode when the system is booted?
Start in system (kernel) mode, to initialize the hardware, including trap tables.
OS organization scheme with layers, but with the kernel as small as possible. Non-essential components become (user space) apps
Micro-Kernel OS
must be explicitly programmed with many machine instructions and explicit use of temporary storage
Assembly language expressions
puts together object files, resolving symbolic addresses (of data and subroutines)
linker
OS organization scheme in which the kernel has a set of basic services, other services added as dynamic modules. Each module has defined API, but any module can call any other module.
Modular OS
What type of interrupt cooresponds to these examples?
- division by zero
- arithmetic overflow
Trap
Starts a program at a random offset in memory for security purposes.
Address Space Layout Randomization (ASLR)
An area of memory assigned by the OS to a process
Process Address Space
In C, when the function main returns, what is it returning to?
The OS
- is active (running or waiting to run)
- has its own memory
- has various permissions
Process
Does a programmer of a higher-level language need to know how the machine’s instructions work?
No, but helpful
An array of starting addresses for interrupt handlers
Trap table or interrupt vector
How are interrupts implemented at the hardware level?
- Instructions are added to signal interrupt events
- At the end of each fetch-execute cycle, the CPU checks for interrupt events
A (privileged) register containing:
- interrupt flags
- process mode (user or privileged)
- PC
- condition code(s)
- interrupt masks (which ones are disabled)
Program Status Word (PSW)
During which pass of the assembler does the following happen?
- check that all labels are defined
- generate machine code
Second pass
Ways to organize an OS
- Monolithic
- Layered
- Micro-kernel
- Modular
A unit of parallel execution in a process
thread
- shares address space
- has its own stack and locals
thread
Locking
A locked resource can only be accessed by the lock’s owner
What syntactic features start scopes in C?
files, functions, and curly braces
If we have a computer with virtual memory, do we still need relocating loaders?
Yes, if we want to use address space layout randomization (ASLR) to start the program at a random offset.
puts program’s text and data into specific memory locations
Absolute loader
Process state:
Wating to run on the CPU
Ready
No distinctions, boundaries between user and OS programs, all can directly use the BIOS drivers.
Monolithic OS
Saves the running process’s state and jumps to appropriate code depending on type of encountered interrupt
Interrupt handler
What kind of information is needed from a name’s use in order to generate code?
Its lexical address
Is linking necessary for execution?
No, but it saves coding time!
- Records structure of programs
- provides placeholders for attributes needed for code generation
Parser
An area of code in which a thread (or process) accesses a shared resource (e.g., a variable)
Critical section
A data structure that an OS uses to manage processes
Process Control Block (PCB)
- can share library code among running processes
- can propagate updates to library code quickly
dynamic linking
threads that execute by interleaving instructions (sharing a core, timesharing simulating parallelism)
Apparent concurrency
- is a normal library function call
- saves state
- executes interrupt instruction
System call
In higher-level programming languages, statements correspond to…
Several machine instructions
What does the C code look like for generating code for a PL/0 while statement?
[code to evaluate the condition] JPC 2 JMP [past loop body] [code for loop body] JMP [to start of the condition]
+ easier to maintain, well-defined interface for each layer
+ easier to debug
- designing layers is hard
- passing data through layers can be slow
Layered OS
What starts a scope in PL/0?
Procedure blocks are scopes in PL/0
Why are race conditions a problem?
they make debugging (exponentially) harder due to state space explosion