ecs 150 quiz 3
kernel level thread - - a thread the OS knows about
- every process is composed of at least one kernel level thread
- kernel manages and schedules threads
- can also have internal threads : "kernel thread"
- switching between kernel level threads requires a context switch
user level threads - - a thread the OS does not know about
- OS only schedules processes, not potential threads within processes
- programmer uses a thread library to manage threads
- user level code can define scheduling policy
- switching between user level threads does not involve a kernel context switch
what happens if thread blocks on an I/O? - the entire process gets blocked
kernel level thread pros: - - blocking system calls suspend the calling thread only
- can take advantage of multiple CPUs
- signals can be delivered more precisely
- used by existing systems (linux)
kernel level thread cons: - - can be heavy, not as flexible
sys calls = big overhead
user level thread pros: - - really fast to create and switch between threads ( no sys calls or context switch
necessary)
- customizable scheduler
user level thread cons: - - all threads of process are blocked on sys call
- customizable scheduler
, cooperative thread - thread runs until it yields control to another thread
- better scheduling control
- simpler shared resources
- leads to potential starvations
preemptive - threads are frequently interrupted and forced to yield
- certain guarantee of fairness
- resource sharing needs to be resistant to preemption
- scheduling is not deterministic
what happens on a fork? - we only copy the thread that calls fork()
what happens with shared data structures and files? - they require synchronization
what about signal delivery? - - some signals can be delivered to one particular thread
- other signals can be delivered to threads that have not blocked it
what about global variables in libraries? - they are shared between threads and may be overwritten
thread memory sharing: - - private processor registers
- private stack
- shared global memory
concurrency issues: indeterministic interleavings - - thread scheduling
- compiler instruction reordering
- hardware instruction reordering
kernel level thread - - a thread the OS knows about
- every process is composed of at least one kernel level thread
- kernel manages and schedules threads
- can also have internal threads : "kernel thread"
- switching between kernel level threads requires a context switch
user level threads - - a thread the OS does not know about
- OS only schedules processes, not potential threads within processes
- programmer uses a thread library to manage threads
- user level code can define scheduling policy
- switching between user level threads does not involve a kernel context switch
what happens if thread blocks on an I/O? - the entire process gets blocked
kernel level thread pros: - - blocking system calls suspend the calling thread only
- can take advantage of multiple CPUs
- signals can be delivered more precisely
- used by existing systems (linux)
kernel level thread cons: - - can be heavy, not as flexible
sys calls = big overhead
user level thread pros: - - really fast to create and switch between threads ( no sys calls or context switch
necessary)
- customizable scheduler
user level thread cons: - - all threads of process are blocked on sys call
- customizable scheduler
, cooperative thread - thread runs until it yields control to another thread
- better scheduling control
- simpler shared resources
- leads to potential starvations
preemptive - threads are frequently interrupted and forced to yield
- certain guarantee of fairness
- resource sharing needs to be resistant to preemption
- scheduling is not deterministic
what happens on a fork? - we only copy the thread that calls fork()
what happens with shared data structures and files? - they require synchronization
what about signal delivery? - - some signals can be delivered to one particular thread
- other signals can be delivered to threads that have not blocked it
what about global variables in libraries? - they are shared between threads and may be overwritten
thread memory sharing: - - private processor registers
- private stack
- shared global memory
concurrency issues: indeterministic interleavings - - thread scheduling
- compiler instruction reordering
- hardware instruction reordering