Midterm 2 Flashcards
deadlock
A set of processes or threads are waiting and need something to make progress, but the thing they need is in another waiting process or thread
request (on a server)
When a process wants to use a resource
use (on a resource)
When a resource is in use by a process and usually cannot be used by any other processes
release (on a resource)
When a process is done using a resource. Allows another process to use the resource
livelock
A condition in which a thread continuously attempts an action that fails.
necessary conditions (for deadlock)
Mutual exclusion (some resources can only be used by one process at a time), hold and wait (processes can have some resources and ask for more), no preemption (OS gets a resource back only once a process is done using it), circular wait (its possible to build a cycle of processes P1..Pn such that each resource is held by the next process)
mutual exclusion (as a necessary condition for deadlock)
some resources can only be used by one process at a time
hold and wait (as a necessary condition for deadlock)
processes can have some resources and ask for more
no preemption (as a necessary condition for deadlock)
OS gets a resource back only once a process is done using it
circular wait (as a necessary condition for deadlock)
its possible to build a cycle of processes P1..Pn such that each resource is held by the next process
resource allocation graph
Shows which processes have which resources and which processes are requesting which resources
request edge
directed edge from a process to a resource in a resource allocation graph
assignment edge
directed edge from a resource instance to a process in a resource allocation graph
deadlock prevention
Building a system where deadlock can’t happen by preventing the deadlock conditions by happening
deadlock detection
The strategy of letting deadlocks happen and deal with them when they occur
deadlock avoidance
Deal with deadlock by staying on safe path by never letting a process do something that couldn’t cause deadlock in the future
claim edge
dashed arrow from process to resource in the resource allocation graph when the process might request the resource
safe state (in deadlock avoidance)
A state where processes could not create deadlock
unsafe state (in deadlock avoidance)
A state where processes could get into deadlock and the OS would not stop them
banker’s algorithm
Before a resource is granted, check if granted request would lead to unsafe state. If the request would lead to an unsafe state, the OS does not give the process the resource
wait-for graph
In deadlock detection, a variant of the resource-allocation graph with resource nodes removed; indicates a deadlock if the graph contains a cycle
recovery (from deadlock)
Usually have to terminate one or more processes
victim selection (in deadlock recovery)
Choose the best process to terminate
rollback (in deadlock recovery)
Terminating a process and restarting later
stall (in memory access)
A CPU state occurring when the CPU is waiting for data from main memory and must delay execution.
cache
Small amount of very fast memory, usually in CPU. Reduces delay of going to main memory for every instruction
base register
marks the start of a process in memory
limit register
marks the end of a process’ memory
address binding
choosing a physical memory address where a program will run
compile-time address binding
Compiler chooses an address when it builds the program. Builds absolute code, must be run in a particular location and rebuild if its going to run elsewhere
load-time address binding
Choose memory address when program starts running
execution-time address binding
Can move after it starts running. Needs more help from hardware.
absolute code
Code that cannot easily be relocated
relocatable code
Position independent code that can be relocated
logical address space
Address space that the user program sees. The address space can be the same, no matter where the program is running.
logical address
An address that the user program sees that might differ from the physical address
address translation
runtime conversion between logical and physical addresses
physical address space
The physical addresses on the computer hardware
physical address
The actual address where something is stored
memory-management unit
Hardware device that handles mapping of logical to physical addresses. Usually a part of the CPU
relocation register
A CPU register whose value is added to every logical address to create a physical address (for primitive memory management).
dynamic loading
Bring in needed libraries at runtime. Loads parts of the program when they are first needed
static linking
Do all linking at build time. Application code and libraries linked into a single load image. Ready to execute after its copied into memory. Executable includes a copy of needed libraries, but just the parts it needs. Sometimes needs a lot of unnecessary space
dynamic linking
Linking at load time (startup). Gets the latest version of every library with smaller executable size. Can be done by writing code with a stub, which is a small piece of code that gets called instead of the subroutine. On the first call, the stub finds and replaces itself with the actual function. Programs share common code, but not necessarily in memory. Code is usually copied into an individual program’s memory
dynamically linked library
Just one copy of the library on the disk that is copied into shared memory and used by multiple programs
shared library
A dynamically linked library that can be used by multiple programs
contiguous memory allocation
all memory for a process must be in a big block
variable partitioning
Put into memory one after another with no gaps. A process exits and a new one can fill space. OS clears memory before giving it to another process. Might get external fragmentation- pieces of memory that are too small to store a process
dynamic storage allocation
OS needs to find space for processes as they start and exit. Just like malloc has to find space
hole (in memory allocation)
Pieces of memory not currently in use
first-fit
Choose first block that is big enough. Sometimes wastes space. Can be done quickly
next-fit
Get the first sufficiently large block after the one allocated. Might promote locality