Multithreading Flashcards
what does a thread comprise of
id, counter, register and stack
Threads within a process share what
code, data+files, signals etc
User threads
supported above the kernel and managed without kernel support, primarily by user-level threads library
Kernel threads
supported and managed directly by the OS
many to one mapping
many user threads to one kernel thread
Pure used level thread implementation
If one thread blocks then all block
one-to-one mapping
creating a user level thread creates a kernel thread - more concurrency no. threads per process is usually restricted
Many to many mapping
many user level threads to be mapped to equal no. or smaller no. of kernel threads
Allows OS to create a sufficient number of kernel threads.
PThreads
Threads that may either be provided as user-level or kernel level threads
Specifications not implementations
POSIX standard API thread creation and synchronization
Implicit threading
creating and management of threads are done by a compiler
- create tasks that gets mapped onto a framework -e.g. java fork() join()
Name and explain the 2 approaches to thread cancellation
Asynch - terminates thread immediately
Deferred - allows target thread to periodically check if it should be cancelled, allows the thread to terminate in an orderly fashion.
Why could asynchronous cancellation of threads be dangerous
when resources allocated to a cancelled thread are either not released or are in an unsafe state