Operating Systems - Part 3

February 16, 2016    

Hi Folks,
operating system
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

A thread is a basic unit of CPU utilization, consisting of a program counter, a stack and set of registers. It is also called a light weight process. Each thread belongs a process and can not exist outside a process. They allow us to parallely execute application on shared multiprocessors. 
Like processes, threads share CPU and can create child threads using fork ( ) system call. All threads can access every address in the task. 

What's so good about them?

Multiple threads can share common data thereby eliminating the need for inter process communication. Also they consume very less resources as compared to processes. Context switching is more efficient with threads. We'll discuss about context switching in later articles. 

Types of Threads

1. User level 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

1. Many to One
Basic features of this model are as follows:
  • 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. 
Many to One
2. One to One
Basic features are as follows:
  • 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. 
One to One
3. Many to Many
Basic features are as follows:
  • 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. 
Many to Many

Thread Libraries

A thread library provides an API to developer for creating and managing threads. There are 3 main thread libraries that are used across operating systems:
  • POSIX Pthreads
  • Windows threads
  • Java threads

Issues related to Threads

1. Fork ( ) system call
The basic issue that arises is when a thread which forks ( ), duplicates itself only or all other threads which are associated with the process. Unix systems handle this by having two versions of fork ( ) system calls and an option suited to requirement is chosen. 
2. Signal Handling
Signals in OS are used to notify a process that some event has occurred. A signal handler processes all signals. Every signal has a default handler assigned by kernel. User defined signals can over ride them.
3. Thread Cancellation
Threads can be terminated before they have finished in case they are not required anymore. Two approaches are used for cancelling threads:
  • Asynchronous cancellation - it terminates the thread immediately.
  • Deferred cancellation - thread is periodically checked if it should be cancelled. 
On Linux systems, thread cancellation is handled through signals.

Interesting fact about OS

NASA's launch countdown clock runs on Fedora Servers. 
Join 40,000+ readers and get free notes in your email

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Operating Systems - Part 3 4.5 5 Yateendra sahu February 16, 2016 Hi Folks, Hope your IBPS IT officer's exams went well. A lot of professional section questions were from PK bundle and articles shared...


Related Post:

  • Current Affairs: 10 January 2017
    World's Largest LED Street Light Replacement Project Launched Union Power Minister Piyush Goyal launched the "world's largest" LED street light replacement project completed by SDMC in south Delhi wherein two lakh conventional street lights have … Read More
  • National Bank for Agriculture and Rural Development: Key Points
    Introduction "NABARD" means 'National Bank for Agriculture and Rural Development'. NABARD is an apex level bank set up by GOI(Government of India) with an instruction of providing credit flow for the promotion and development of agriculture, cot… Read More
  • Business of Banking Companies in Banking Regulation Act, 1949
    Introduction The banking and regulations act was enacted to safeguard the interest of the depositors and to control the abuse of powers by controlling the banks by any means necessary and to the interest of Indian economy in general. There are many… Read More
  • How to solve Syllogism using Venn Diagram
    Introduction:- This is one of the very important topics that is frequently asked in competitive exams. To understand, analyze & to solve questions on this topic abstract thinking is necessary. When the ordinary methods of reasoning fail, we can… Read More
  • SBI Specialist officer 2016 Admit Card Out
    State bank of India has released the Admit Card/Call letter for the SBI SO 2017 exam. State Bank of India is recruiting Specialist officers for the post of Assistant manager (JMGS-I), Developer, Test lead (MMGS-II). Date of Online Exam : 20 Januar… Read More
Load comments

No comments:

Post a Comment