Concurrency Flashcards
independent processes
can’t be affected by others and vice versa
cooperating processes
can be affected and can affect other processes
reasons for communication
- information sharing
- computational speedup (e.g. breaking down a big task to multiple small tasks)
- modularity (system is divided into modules that need to communicate)
- convenience (multitasking by the user, e.g. listening to music while writing a document)
Ctrl+Z
suspends a process, doesn’t terminate
signal types
Hardware-induced (e.g., SIGILL)
Software-induced (e.g., SIGQUIT or SIGPIPE)
actions
term
ign
core
stop
cont
catching signals
- Process registers signal handler
- OS delivers signal and allows process to run handler
- Current execution context needs to be saved/restored
kernel delivers the signal
→ Stops code currently executing (after saving contacts- states of registers- of the current program)
→ Saves context
→Executes signal handling code
→Restores original context
signal info pushed onto the stack
floating point state
ucontext: SP and IP
siginfo - info about the signal
sigreturn - SP; address to where to return after the signal handler finishes
upon sigreturn, the kernel
- can simply take all the state on top of stack
- and restore:RIP = …
RSP = …
RAX = …
RBX = …
etc. - vulnerability: not stored in the kernel so it can be modified by an user
reasons for synchronisation
- To account for dependencies
- To avoid processes getting in each other’s way
- Also applies to multithreaded execution
fork()
- creates a separate, duplicate process
- new PID
- continues after
exec()
- the program specified in the parameter will replace the entire process - including all threads
- same PID
- doesn’t continue after
race conditions
a situation in which several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place
spooler directory
a designated area where files are temporarily stored while they are being processed by a program or service, typically related to printing or job management