What is a Thread?
A thread is a path of execution within a process. A process can contain multiple threads.
Process vs Thread
The primary difference is that threads within the same process run in a shared memory space, while processes run in separate memory spaces.
Threads are not independent of one another like processes are, and as a result threads share with other threads their code section, data section, and OS resources (like open files and signals). But, like process, a thread has its own program counter (PC), register set, and stack space.
Advantages of Thread over Process
Threads are executed one after another but gives the illusion as if they are executing in parallel. Each thread has different states. Each thread has
Threads are not independent of each other as they share the code, data, OS resources etc.
Similarity between Threads and Processes
Differences between Threads and Processes
There are two types of threads.
1. User Level thread (ULT): Is implemented in the user level library, they are not created using the system calls. Thread switching does not need to call OS and to cause interrupt to Kernel. Kernel doesn’t know about the user level thread and manages them as if they were single-threaded processes.
(i) Advantages of ULT
(ii) Disadvantages of ULT
2. Kernel Level Thread (KLT): Kernel knows and manages the threads. Instead of thread table in each process, the kernel itself has thread table (a master one) that keeps track of all the threads in the system. In addition kernel also maintains the traditional process table to keep track of the processes. OS kernel provides system call to create and manage threads.
(i) Advantages of KLT
(ii) Disadvantages of KLT
Difference between User Level thread and Kernel Level thread
10 videos|99 docs|33 tests
|
|
Explore Courses for Computer Science Engineering (CSE) exam
|