
Hope your IBPS IT officer's exams went well. A lot of professional section questions were from PK bundle and articles shared here. All the best for results!
We'll be continuing with operating systems and start with 'Threads'. Previous article on OS can be found at operating systems - part 2.
Threads
What's so good about them?
Types of Threads
- Implement in user level libraries not via system calls.
- No modification to operating system is required.
- Creation of thread, switching & sync between them can be done without interrupting the kernel.
2. Kernel level threads
- Kernel manages the threads by keeping track of all in a thread table.
- Uses system calls to create and manage threads.
- Scheduler may allocate more time to a process having more threads since kernel knows about them all.
- Much slower than user level threads.
Multi threading models
- Many user level threads mapped to a single kernel thread.
- Blocking of one thread causes all to block.
- Multiple threads may not run in parallel as only one in kernel at a time.
- E.g. - Solaris Green Threads, GNU Portable Threads.
- Each user level thread is mapped to kernel thread.
- If you create a user thread, a kernel thread will be created.
- Number of threads per process are sometimes restricted.
- E.g. - Linux, Windows.
- Many user level threads are mapped to many kernel level threads.
- If kernel system calls are blocked, it doesn't block the entire process.
- Users have no restrictions on number of threads created.
Thread Libraries
- POSIX Pthreads
- Windows threads
- Java threads
Issues related to Threads
- Asynchronous cancellation - it terminates the thread immediately.
- Deferred cancellation - thread is periodically checked if it should be cancelled.
Interesting fact about OS
Free Notes
Download Professional Knowledge Study Material here