Operating System Unit 2
Que.1 Explain different states of a process with a suitable diagram
Ans:-
New
This is the state when the process has just been created. It is the initial state in the process life cycle.
Ready
In the ready state, the process is waiting to be assigned the processor by the short term scheduler, so it can run. This state is immediately after the new state for the process.
Ready Suspended
The processes in ready suspended state are in secondary memory. They were initially in the ready state in main memory but lack of memory forced them to be suspended and gets placed in the secondary memory.
Running
The process is said to be in running state when the process instructions are being executed by the processor. This is done once the process is assigned to the processor using the short-term scheduler.
Blocked
The process is in blocked state if it is waiting for some event to occur. This event may be I/O as the I/O events are executed in the main memory and don't require the processor. After the event is complete, the process again goes to ready state.
Blocked Suspended
This is similar to ready suspended. The processes in blocked suspended state are in secondary memory. They were initially in the blocked state in main memory waiting for some event but lack of memory forced them to be suspended and gets placed in the secondary memory. A process may go from blocked suspended to ready suspended if its work is done.
Terminated
The process is terminated once it finishes its execution. In the terminated state, the process is removed from main memory and its process control block is also deleted.
Que.2 What is thread? Explain thread Structure? Explain any one type of thread in details.
Ans:- Thread is a single sequence stream within a process. Threads have same properties as of the process so they are called as light weight processes. 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
- A program counter
- A register set
- A stack space
Threads are not independent of each other as they share the code, data, OS resources etc.
- 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.
- Advantages of KLT –
- Since kernel has full knowledge about the threads in the system, scheduler may decide to give more time to processes having large number of threads.
- Good for applications that frequently block.
- Limitations of KLT –
- Slow and inefficient.
- It requires thread control block so it is an overhead.
- Que.3 Explain Round Robin algorithm with proper example.
- Ans:-
- In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This algorithm also offers starvation free execution of processes.
Comments
Post a Comment