Processes and Threads Flashcards
System initialization, execution of creation syscall, user requesting
Process creation
normal exit, program exit, fatal error, or killed by another process
Process termination
blocked, running or ready
Process state
Cannot transition from ready to ______ or blocked to _______
blocked, running
Processes that remain in the background
Daemon
Stores information about the process, including PC, stack pointer, process state
Process table
U=1-p^n
CPU utilization formula
Enable parallelism with blocking syscalls
Threads
Faster to create and destroy
Threads
Natural for multiple cores
Threads
Easier programming model
Threads
Memory is shared
Threads
Better for I-O bound tasks
Threads
Thread table contains information so runtime system can manage. If thread blocks, rts stores thread info in table and finds new thread
Threads in userspace - the good
State save and scheduling are invoked faster than in kernel
Threads in userspace - the good
Cannot execute blocking system calls
Threads in userspace - the bad
Do not voluntarily give up CPU
Threads in userspace - the bad
Kernel keeps same thread table as user table
Threads in kernelspace - the good
If thread blocks, can just choose another
Threads in kernel space - the good
Expensive to manage and takes up valuable space
Threads in kernel space - the bad
Multiplex user level threads onto kernel level threads
Hybrid approach
Kernel aware of kernel threads only
Hybrid approach
User-level threads scheduled, created, destroyed indepedently of kernel thread
Hybrid approach
Programmaer must decide how many user level and kernel level threads
Hybrid approach
Only one process can use a shared variable / file at a time
Mutual exclusion
Shared memory which leads to races
Critical region
Ensure two processes cannot be in the same critical region at the same time
How to avoid races
Mutual Exclusion
Properties of a good solution to avoid race conditions
No assumption about speed or number of CPUs
Properties of a good solution to avoid race conditions
No process outside critical zone will block other processes
Properties of a good solution to avoid race conditions
No starvation
Properties of a good solution to avoid race conditions
How one process can pass information to another
IPC problems
How to deal with process conflicts
IPC problems
How to sequence correctly with dependencies
IPC problems
Integer variable, used to make process sleep / wakeup
semaphore
Down checks semaphore. If > 0 then _____ semaphore. If 0, process _______
decrement semaphore and continue, sleep
Two operations: down and up
semaphore
Up increments semaphore. If more than one process is asleep, _______________
wake a random process
Variable that can be in one of two states, locked or unlocked
mutexes
Good for thread packages in user space
mutexes
Allows threads to block due to some condition not being met
Condition variable
Two functions: wait and signal
Condition variable
wait until condition is set to true
Condition variable wait
sets condition to true, allowing one more to enter block
Condition variable wait
Abstract data type which encapsulates shared resource
monitor
concurrent process executes procedures to access shared resources
monitor
only one process can execute code at a given time
monitor