Hi Readers,

In the previous article, I have explained the important topics from DBMS for GATE. This blog is on how to prepare Operating System for GATE and for job interviews.

If you look at the GATE syllabus, Operating System is core subject. Every year GATE asks around 8-10 marks of question from this subject.

So, consider this as an important subject. Below are some important topics, notes and tricks that you have to follow to score good marks with minimum efforts.

In this blog, first I will list some important topics to focus on. And later, we will discuss important OS questions and answers in detail.

**Important Topics on Operating System (OS)**

- Tyes of Operating System (Multiprogramming and Multitasking)
- System Call (Form, Kernal, User)
- CPU Scheduling (Round Rabin, SRTF, FIFO)
- Synchronization (Binary semaphore)
- Fragmentation (Internal, External, First-fit, and Best-fit algorithms)
- Page replacement and fault
- Paging and Disc scheduling
- Deadlock (Banker’s algorithm)

Now, let’s discuss some important topics in detail with shortcuts one-by-one.**.**

If you are preparing for GATE, check the GATE exam details and dates.

Table of Contents

From this topic, they ask standard questions every year. One question can be expected from multiprogramming and multitasking operating systems. The rest of them are not so important.

**Real Time Example:**

Consider in a class, there are five students and each student has five questions with them. As a teacher, I have two cases.

- First I will solve all questions of the first student then I will move to 2
^{nd}student. - Or, I will solve three questions of the first student and then move to the second student, and then after the fifth student again I will come to the first student.

At above, the first case is of Multiprogramming and 2^{nd} case is of multitasking. (consider teacher as CPU and student as a process)

Here, they ask questions on the Fork system call mainly. Practice questions on Kernel operating mode, user operating mode, and fork system call.

**Some Important Points to Solve Questions related to System Call**

- Kernel-based threads are slower than user-level thread because as kernel-level threads involves system calls.
- When an application wants to use resources of the em, it switches its control to kernel mode.
- In the exam, they will give you a program with a while loop condition. Just check how many times the fork system call can be executed.
- A number of child process =
`2^n-1`

, where n is the number of fork system call. There can be questions where you have to find the number of child processes requires for the execution of a given recursive program.

Learn the difference between process and thread in OS.

This topic is quite important from a GATE point of view, they ask frequent ques from Round Robin, SRTF, and priority-based algorithms. The questions will be like Arrival time, Burst time will be given, you need to calculate different parameter.

**CPU Scheduling Formulas**:

Here are some of the basic formulas you need to solve CPU scheduling problems.

Turnaround Time = Completion Time - Arrival Time

Waiting time = Turnaround Time - Burst time

Response Time = Time in which process got CPU for First Time - Arrival Time

**Short Tricks and Points to Solve CPU Scheduling Questions:**

- Be careful in the calculation part. Even a single mistake will create trouble calculating correct values.
- Remember the criteria of each algorithm like for SRTF criteria is Burst time.
- Read the question carefully whether you have been asked for non-preemptive or preemptive tasks.
- Always maintain a Ready queue and a Running queue while solving Round Robin algorithm.

GATE** **ask a bit complicated topic from this topic, only practice will make you perfect here. Practice as many questions as you can on Binary Semaphore.

**Few Tips to Remember while Solving Semaphore Questions:**

- If the question asks like it is mutually exclusive or not, then look for the clashes. Clashes are good in binary semaphore.
- Be careful in up and down operation, up have many names like Post, Signal, etc . and Down have names like Wait.
- Suppose in a question there are 3 resources A, B, C. and the semaphore works on all resource then it will never reach the final state.

From this topic, they ask about first, best and worse fit algorithms.

Like some partition blocks of different sizes will be given and some processes of different sizes. You have to arrange them according to the algorithm.

** Few Points to Remember while Solving Questions on Fragmentation**:

- Learn about internal and external fragmentation. The definition must be clear.
- When does external and internal fragmentation occur?
**External fragmentation**occurs due to contiguous memory allocation.**Internal fragmentation**occurs due to fixed-size partitioning, we can avoid that by variable size partitioning.

**What is the difference between First, Best and Worst Fit Algorithm?**

**First Fit:**It works on first come first serve besis. The first block which can allocate, it will fit the process.**Best Fit:**We will fit the process where after fitting less remaining space will left.**Worst Fit:**We will allocate the process in the largest ever block possible..

In the DYNAMIC PARTITIONING, the worst-fit algorithm works best. And in static partitioning best-fit algorithm works best.

Many of the times, GATE asks questions of page hit and fault calculation algorithm.

You need to check carefully whether it’s hit or fault.

**What is Page Hit?**

If the process number which is demanded by the CPU is present then it’s a hit otherwise fault.

**What is difference between FIFO, LRU and Optimal Algorithm?**

**FIFO (First In First Out):**The process number which enters first will eliminate first from the queue.**LRU (Least Recently Used / Far From Left):**You need to check from the left, which is far. Just replace that with a new process number.**OPTIMAL (FAR FROM RIGHT):**It process is far from the right side, replace that.

Number of frames will be given in the question itself.

Next topic you should consider to prepare Operating System for GATE is Disc Scheduling.

Here, GATE mainly focuses on the SCAN and LOOK algorithm. Just practice some basic numerical on that and have a clear concept on DISC structure.

**What is the difference between SCAN and LOOK algorithm?**

- In the
**SCAN algorithm**, the process first scanned from first to last. Then it moves from last to first. Starvation will not occur in this algorithm. - In the
**LOOK algorithm**, the header will move from first to the last request, and then from last to first servicing all the requests in between.

Just practice some numerical on how to calculate the average time and have a clear understanding of all the **disc scheduling algorithm**.

**Important Questions from Disc Scheduling Algorithm and Paging**:

- From the PAGING, they will ask you to calculate the size of the page table, page mainly. Practice some numerical on that.
- Be familiar with the terms like sector, tracks, platers, spindle, actuator arm, etc.

This topic is quite important for GATE as well as interview also. GATE will surely ask you a question on **BANKER’S ALGORITHM**. So, practice at least 4-5 difficult problems in that.

Question will be like– they will give you currently allocated resource and the max need, and a total number of resources present. You need to check the system is stable or not, the sequence of processes, the deadlock will occur or not, etc.

Read basic questions asked on Deadlock.

**Few Points to Keep in Mind while Solving Numerical:**

- Read the question carefully like what’s given and what they are asking. If you need the current requirement just apply the formula MAX NEED-CURRENTLY ALLOCATED.
- Then check whether you have the resource or not to satisfy at least one of the process requirements. After satisfying the requirement, the allocated resource of that process will get added to the currently available resource.
- If you are preparing for an interview, then read something about the DINING-PHILOSOPHER problem.
- Have a clear idea about the deadlock prevention and handling methods. Understand the concept. It will help you in long run.

Banker’s Algorithm is a part of deadlock voidance.

** JUST FOCUS ON THESE POINTS NOW, AND YOU WILL GET GOOD MARKS IN THE SUBJECT.**

Hope this helps you to prepare Operating System for GATE or job interview. If you have any doubt, ask me in the comment. All the best!