Threads and Multithreading Flashcards
What is a thread
A thread is a lightweight process that shares a common address space with the owner process
Advantages of using threads
They are easy to create and handle
They achieve concurrency in parallel programming
They can effectively utilize multiprocessor architecture
Thread communication is much faster than process communication because threads share common address space
They increase the overall performance of a system.
What are the classifications of threads?
User level threads: These threads are independent of the kernel
Kernel level threads: These are created by the operating system directly
Advantages of User level threads
They are easy to create
They are platform independent
They don’t depend upon the system hardware
Context switching is very easy for an OS
Disadvantages of User level threads
Multiprocessing is very difficult because it is independent of kernel.
They require non blokcing I/O
Advantages of kernel level threads
Mulitiprocessing is done very easily
They work on the blocking I/O protocol
Disadvantages of kernel
They are slow and inefficeient compared to user level threads
They are very hard to create and manage
Multiple switching is required to transfer control from one thread to another thread.
Threads vs Processes
D C R - T M
Definiton: A thread is a lightweight segment that is part of a process while a process is any program that is executing
Creation Time: Threads usually take very little time to create since its lightweight while Process requires more time to create.
Resource sharing - Threads need minimal resources to do its task while a process uses more resources than threads
Termination Time: Threads takes littel time to terminate while a process takes more time to terminate due to its complex nature
Management - Threads do not depend on any OS system calls while a process depends on system calls
What is multi-threading
This a program’s ability to execute multiple threads simultaneously to maximize the utilization of the CPU
Importance of Multithreading
Application scalablity
Responsiveness
Efficient memory utilization
Efficent CPU utilization
What is concurrency
This is parallelly executing multiple threads at the same time.