Operating Systems (Threads) Flashcards
Benefits of Single and Multi-treaded processes
1) Responsiveness
2) Resource sharing
3) Economy
4) Utilization of MP architectures
Parallel and concurrent systems, and modern CPUs
Parallel system - Performs more than one task simultaneously
Concurrent - Supports more than one task by allowing all tasks to make progress.
Modern CPUs support two or more threads per core
User threads are managed by thread libraries, like?
POSIX Pthreads, Win32 threads, and Java threads
Kernel Threads are supported and managed directly by?
The OS kernel
e.g., • Windows XP/2000 • Solaris • Linux • Tru64 UNIX • Mac OS X
Types of multi-threading models? (3)
1) Many-to-one
2) One-to-one
3) Many-to-many
Refers to the number of kernel threads : user threads
Examples of OS kernels classified by multi-threading model
- Many-to-One
- Solaris Green Threads
- GNU Portable Threads
- One-to-One
- Windows NT/XP/2000
- Linux
- Solaris 9 and later
• Many-to-Many
• Solaris prior to version 9
• Windows NT/2000 with the ThreadFiber
package
Two-level • IRIX • HP-UX • Tru64 UNIX • Solaris 8 and earlier
Two-level multi-threading model?
1st level: Many-to-many
2nd level: one-to-one
Function of thread libraries
Provide programmer with an API for library in user space or a kernel library.
Java thread API generally
implemented using a thread library
available on the host system
Threading Issues (6)
- fork() and exec() system calls
- Thread cancellation
- Signal handling
- Thread pools
- Thread specific data
- Scheduler activations
Thread Pools
• Create a number of threads in a pool where they await work • Advantages: • Slightly faster • Can bound number of threads in app
Signal Handling 1) Purpose, 2) Types, 3) Options
Signals are used in UNIX systems to notify a process
that a particular event has occurred
• Synchronous signal - delivered to process that
executed the event that caused the signal e.g.,
illegal memory access / division by 0
• Asynchronous signal - generated by an event
external to the running process
• Options:
• Deliver the signal to the thread to which the signal applies
• Deliver the signal to every thread in the process
• Deliver the signal to certain threads in the process
• Assign a specific thread to receive all signals for the process
Thread Cancellation 1) Meaning, 2) Types
Terminating a thread before it has finished
• Two general approaches:
• Asynchronous cancellation
• Deferred cancellation
Thread Specific Data: 1) What is it and why?
Each thread can have its own copy of
data, which is useful when you do not have control
over the thread creation process
Scheduler Activations and upcalls
• Both M:M and Two-level models • require communication to maintain the appropriate number of kernel threads allocated to the application • Scheduler activations provide upcalls • a communication mechanism from the kernel to the thread library
Examples: (Could just by multi-thread model) • Pthreads • Windows XP • Linux • Java
Java Thread States
New, then can alternate between Runnable and Blocked (I/O sleep or I/O is available) , then Dead after termination.