UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
1. Define Process State. Draw the diagram of PCB.
OR
2. What is process. Explain about various field of process control block.
ANS:- A program does nothing unless its instructions are executed by CPU.
A program is execution is called a process. In order to accomplish its task,
process needs the computer resources.
There may exist more than one process in the system which may require the
same resource at the same time. Therefore, the operating system has to manage
all the processes and the resources in a convenient and efficient way.
Some resources may need to be executed by one process at one time to
maintain the consistency otherwise the system can become inconsistent and
deadlock may occur.
The operating system is responsible for the following activities in connection
with Process Management
1. Scheduling Processes and Threads on The CPUs.
2. Creating And Deleting Both User and System Processes.
3. Suspending And Resuming Processes.
4. Providing Mechanisms for Process Synchronization.
5. Providing Mechanisms for Process Communication.
Process states
There are mainly seven stages of a process which are:
1. New: The new process is created when a specific program calls from
secondary memory/ hard disk to primary memory/ RAM
2. Ready: In a ready state, the process should be loaded into the primary
memory, which is ready for execution.
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
3. Waiting: The process is waiting for the allocation of CPU time and other
resources for execution.
4. Executing: The process is an execution state.
5. Blocked: It is a time interval when a process is waiting for an event like
I/O operations to complete.
6. Suspended: Suspended state defines the time when a process is ready for
execution but has not been placed in the ready queue by OS.
7. Terminated: Terminated state specifies the time when a process is
terminated
Process Control Blocks
PCB stands for Process Control Block. It is a data structure that is
maintained by the Operating System for every process. The PCB should be
identified by an integer Process ID (PID). It helps you to store all the
information required to keep track of all the running processes.
It is also accountable for storing the contents of processor registers. These
are saved when the process moves from the running state and then returns
back to it. The information is quickly updated in the PCB by the OS as
soon as the process makes the state transition.
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
3. Difference between Thread and process.
4. Define the Context Switching. Explain process control block in brief.
ANS: - Context switching in OS is the process of storing the state of a
running process or thread, so that it can be restored and resume execution
at a later point, and then loading the context or state of another process or
thread and run it.
Context switching is a fundamental concept in operating systems, and is
necessary for multitasking and efficient resource management. In a
multitasking operating system, multiple processes or threads can be
running concurrently. The operating system uses context switching to
switch between these processes or threads, so that each one can have a fair
share of the CPU's time.
Context switching in OS involves saving and restoring the following
information:
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
The contents of the CPU's registers, which store the current state of
the process or thread.
The process or thread's memory map, which maps the process or
thread's virtual memory addresses to physical memory addresses.
The process or thread's stack, which stores the function call stack
and other information needed to resume execution.
Steps Of Context Switching in OS
The steps involved in context switching in OS are as follows:
1. Save the state of the current process: This includes saving the
contents of the CPU registers, the memory map, and the stack.
2. Load the state of the new process: This includes loading the
contents of the CPU registers, the memory map, and the stack.
3. Update the process scheduler: The process scheduler needs to be
updated to reflect the new state of the system.
4. Switch to the new process. This involves transferring control to the
new process's instruction pointer.
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
Process Control Blocks
PCB stands for Process Control Block. It is a data structure that is
maintained by the Operating System for every process. The PCB should be
identified by an integer Process ID (PID). It helps you to store all the
information required to keep track of all the running processes.
It is also accountable for storing the contents of processor registers. These
are saved when the process moves from the running state and then returns
back to it. The information is quickly updated in the PCB by the OS as
soon as the process makes the state transition.
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
5. Explain thread and its types.
ANS: - A thread is a single sequential flow of execution of tasks of a
process so it is also known as thread of execution or thread of control.
There is a way of thread execution inside the process of any operating
system. Apart from this, there can be more than one thread inside a
process. Each thread of the same process makes use of a separate program
counter and a stack of activation records and control blocks. Thread is
often referred to as a lightweight process.
Types of Threads:
1. User Level thread (ULT)
2. Kernel Level Thread (KLT)
User Level thread (ULT)
It 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.
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
Advantages of ULT
1. Can be implemented on an OS that doesn’t support multithreading.
2. Simple representation since thread has only program counter,
register set, stack space.
3. Simple to create since no intervention of kernel.
4. Thread switching is fast since no OS calls need to be made.
Limitations of ULT
1. No or less co-ordination among the threads and Kernel.
2. If one thread causes a page fault, the entire process blocks.
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
1. 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.
2. Good for applications that frequently block.
Limitations of KLT
1. Slow and inefficient.
2. It requires thread control block so it is an overhead.
6. Define Short term, long-term, medium-term scheduling.
ANS: - A scheduler is a type of system software that allows you to handle
process scheduling.
Process scheduling is an important activity done by the process manager
to remove the process from the CPU and schedule the next process, the
process removal and dispatch are based on multiple factors like process
completion, priority, I/O requirement, etc. Process scheduling plays
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
important role in Multiprogramming operating systems. There are mainly
three types of schedulers in operating systems, which are: Short-term
schedulers, medium-term schedulers, and long-term schedulers.
Three types of the scheduler are: -
1. Long term
2. Short term
3. Medium-term
Short Term Scheduler
Short term scheduling is also known as CPU scheduler. The main goal of
this scheduler is to boost the system performance according to set criteria.
This helps you to select from a group of processes that are ready to
execute and allocates CPU to one of them. The dispatcher gives control
of the CPU to the process selected by the short-term scheduler.
Long Term Scheduler
Long term scheduler is also known as a job scheduler. This scheduler
regulates the program and select process from the queue and loads them
into memory for execution. It also regulates the degree of multi-
programming. However, the main goal of this type of scheduler is to offer
a balanced mix of jobs, like Processor, I/O jobs., that allows managing
multiprogramming.
Medium Term Scheduler
Medium-term scheduling is an important part of swapping. It enables you
to handle the swapped out-processes. In this scheduler, a running process
can become suspended, which makes an I/O request. A running process
can become suspended if it makes an I/O request. A suspended processes
UNIT - 2 IMP QUESTIONS OS
Part 1 (Process Management)
can’t make any progress towards completion. In order to remove the
process from memory and make space for other processes, the suspended
process should be moved to secondary storage.
7. NUMERICAL QUESTIONS Based on CPU Scheduling?
FCFS
SJF
SRTF
ROUND ROBIN
PRIORITY