BCAMCABSc ITB.Tech CSE

Operating Systems — syllabus, exam questions and lab programs

Your scheme may call it Operating Systems.

Operating Systems reads like a theory paper and is scored like a maths paper. Look at any past paper and most of the marks sit in numericals: scheduling algorithms with a Gantt chart and average waiting time, page replacement with a frame table and a fault count, banker's algorithm with a safe sequence, disk scheduling with a head movement total. Each of those is a fixed procedure. Learn the procedure and the question is worth full marks every time.

That makes this one of the easier papers to convert from a fail to a first, because the marks do not depend on writing. They depend on drawing the table correctly and not making an arithmetic slip. Students who struggle with the descriptive papers often do best here.

The part that stays with you afterwards is smaller but real. Understanding what a process is, why a deadlock happens, and what virtual memory is doing behind your program will explain things later — why a server falls over under load, why your laptop crawls with fifty browser tabs open, why two services writing the same file corrupt it.

We teach this

Operating Systems is one of the papers we teach at WebPrims

This is not only a page about Operating Systems. It is a subject we teach in a classroom on Majitha Road — tuition for Operating Systems, if that is the word you were searching for — and a good share of every batch is college students taking it alongside their own semester. Bring your scheme and we cover what is on it.

What that means in practice: the whole syllabus gets covered rather than the parts that make a good demo, you write code on a machine instead of copying it into a file, and the lab work gets done here rather than the night before submission.

What we will not say is that this guarantees you marks or a job. We do not run placements and we do not promise results. Come and sit in a class, decide for yourself.

₹4,500 / month— one rate, any subjectMon–Sat, batches at 11, 1, 3 and 5Majitha Road, Amritsar

The syllabus, unit by unit

What each unit actually contains, and whether it is there because it matters or because it is on the paper. Unit order and numbering vary between GNDU, PTU and your batch’s scheme — check your own before you plan a revision week.

1

Introduction and system structure

What an operating system does, batch, multiprogramming, time-sharing, real-time and distributed systems, system calls, and the monolithic, layered and microkernel structures.

Definitions and one diagram. Learn the types with one example each and the unit is finished.

2

Processes and threads

Process states and the state diagram, the process control block, context switching, the difference between a process and a thread, user and kernel threads, and inter-process communication.

The five-state diagram is asked constantly and is worth drawing until it is automatic.

3

CPU scheduling

Scheduling criteria, FCFS, SJF preemptive and non-preemptive, priority scheduling, round robin with a time quantum, and multilevel queues; Gantt charts, average waiting time and turnaround time.

The single biggest source of marks in the paper. It is arithmetic — practise ten problems and it stops being able to surprise you.

4

Process synchronisation

The critical section problem, Peterson's solution, semaphores with wait and signal, mutexes, and the classic problems — producer-consumer, readers-writers and dining philosophers.

Producer-consumer with semaphores is asked most years. Learn one of the three classics properly rather than all three badly.

5

Deadlock

The four necessary conditions, resource allocation graphs, prevention, avoidance with the banker's algorithm, detection and recovery.

Banker's algorithm is a long numerical with a fixed method. The four conditions are two free marks in every paper.

6

Memory management

Contiguous allocation, first fit, best fit and worst fit, internal and external fragmentation, paging, segmentation, and the translation from a logical to a physical address.

First fit, best fit and worst fit on a given set of holes is a guaranteed numerical. Paging address translation is the other one.

7

Virtual memory

Demand paging, page faults, page replacement with FIFO, optimal and LRU, Belady's anomaly, thrashing and the working set model.

Page replacement is a numerical you can master in an evening. Belady's anomaly is a one-mark definition attached to it.

8

File systems and disk scheduling

File attributes and operations, directory structures, allocation methods — contiguous, linked and indexed — free space management, and disk scheduling with FCFS, SSTF, SCAN, C-SCAN and LOOK.

Disk scheduling is another numerical with a fixed method, and it is usually the last question, so it is often the least contested.

What is worth keeping after the exam

Revise all of it — the marks are the marks. But it is worth knowing which half of this paper you will still be using in two years, and which half exists because it is on the paper.

Stays with you

  • +What a process and a thread actually are, which explains most production incidents you will ever see
  • +Why deadlock happens, which you will meet again the first time two parts of a system wait on each other
  • +Virtual memory and paging, which is why a server with enough RAM still slows to a crawl
  • +The idea of a race condition and why shared state needs a lock

For the exam, and then gone

  • −Peterson's solution, which is a teaching device and not used anywhere
  • −Banker's algorithm — real systems detect and recover rather than avoid
  • −Computing average waiting time by hand for six processes
  • −The historical system types: batch and time-sharing as categories to name

Questions that come up year after year

Not a guess paper, and not a promise about what will be set. These are the questions this subject keeps asking because they are the ones that test whether you understood it.

  1. 01Given processes with burst and arrival times, draw the Gantt chart and find average waiting and turnaround time for FCFS, SJF and round robin
  2. 02Apply FIFO, LRU and optimal page replacement to the given reference string and count page faults
  3. 03Solve the given system using banker's algorithm and state whether it is in a safe state
  4. 04Explain the four necessary conditions for deadlock
  5. 05Draw and explain the process state transition diagram
  6. 06Apply first fit, best fit and worst fit to the given memory holes
  7. 07Explain the producer-consumer problem and its solution using semaphores
  8. 08Compare SSTF, SCAN and C-SCAN with total head movement for the given request queue

What students get wrong

From teaching this paper, not from a list somewhere. Each of these costs marks every year.

Wrong — Treating this as a theory paper and revising only the definitions.

Right — Count the marks on a past paper. Most of them are numericals. Work ten scheduling problems and ten page replacement problems and you have covered more of the paper than a week of reading would.

Wrong — Forgetting arrival times in an SJF or round robin problem and scheduling as if everything arrived at zero.

Right — Write a timeline first and mark when each process becomes available. At every decision point, choose only from the processes that have actually arrived. This one habit prevents most lost marks in the paper.

Wrong — Confusing waiting time with turnaround time.

Right — Turnaround time is completion minus arrival. Waiting time is turnaround minus burst. Write both formulas at the top of the answer before you start and you cannot mix them up.

Wrong — Saying more frames always mean fewer page faults.

Right — That is exactly what Belady's anomaly disproves, and FIFO is the algorithm that shows it. Examiners ask this specifically to catch the assumption.

Lab file programs

These compile and run as written — type them in, break them, and fix them. Copying a program into a file you never ran is how a practical viva goes badly.

FCFS and SJF scheduling — worked out

The method written as a program, so the arithmetic is visible. Same steps you follow on paper.

c
#include <stdio.h>

int main(void) {
    int n, i, j;
    int pid[20], burst[20], wait[20], turn[20];
    int total_w = 0, total_t = 0;

    printf("Number of processes: ");
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        pid[i] = i + 1;
        printf("Burst time for P%d: ", pid[i]);
        scanf("%d", &burst[i]);
    }

    /* For SJF, sort by burst time first. Comment this block out for FCFS. */
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (burst[j] < burst[i]) {
                int tb = burst[i]; burst[i] = burst[j]; burst[j] = tb;
                int tp = pid[i];   pid[i]   = pid[j];   pid[j]   = tp;
            }
        }
    }

    wait[0] = 0;
    for (i = 1; i < n; i++) {
        wait[i] = wait[i - 1] + burst[i - 1];
    }

    printf("\nPID  Burst  Wait  Turnaround\n");
    for (i = 0; i < n; i++) {
        turn[i] = wait[i] + burst[i];
        total_w += wait[i];
        total_t += turn[i];
        printf("P%-3d %-6d %-5d %d\n", pid[i], burst[i], wait[i], turn[i]);
    }

    printf("\nAverage waiting time    = %.2f\n", (float)total_w / n);
    printf("Average turnaround time = %.2f\n", (float)total_t / n);
    return 0;
}

FIFO page replacement

Counts page faults for a reference string. Run it on the string from a past paper and check your hand working.

c
#include <stdio.h>

int main(void) {
    int frames, n, i, j, k = 0, faults = 0, found;
    int frame[10], ref[50];

    printf("Number of frames: ");
    scanf("%d", &frames);
    printf("Length of reference string: ");
    scanf("%d", &n);
    printf("Reference string: ");
    for (i = 0; i < n; i++) scanf("%d", &ref[i]);

    for (i = 0; i < frames; i++) frame[i] = -1;

    for (i = 0; i < n; i++) {
        found = 0;
        for (j = 0; j < frames; j++) {
            if (frame[j] == ref[i]) { found = 1; break; }
        }
        if (!found) {
            frame[k] = ref[i];      /* replace the oldest — that is FIFO */
            k = (k + 1) % frames;
            faults++;
        }
        printf("%2d : ", ref[i]);
        for (j = 0; j < frames; j++) {
            if (frame[j] == -1) printf(" - ");
            else printf("%2d ", frame[j]);
        }
        printf("%s\n", found ? "" : "  <- fault");
    }

    printf("\nTotal page faults = %d\n", faults);
    return 0;
}

SSTF disk scheduling

Shortest seek time first, with the total head movement the question always asks for.

c
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int n, head, i, j, nearest, min, total = 0;
    int req[50], done[50];

    printf("Number of requests: ");
    scanf("%d", &n);
    printf("Request queue: ");
    for (i = 0; i < n; i++) { scanf("%d", &req[i]); done[i] = 0; }
    printf("Initial head position: ");
    scanf("%d", &head);

    printf("\nOrder served: %d", head);
    for (i = 0; i < n; i++) {
        min = 100000; nearest = -1;
        for (j = 0; j < n; j++) {
            if (!done[j] && abs(req[j] - head) < min) {
                min = abs(req[j] - head);
                nearest = j;
            }
        }
        total += min;
        head = req[nearest];
        done[nearest] = 1;
        printf(" -> %d", head);
    }

    printf("\n\nTotal head movement = %d\n", total);
    return 0;
}

Long questions, answered the way they are marked

Not model answers to reproduce. What the examiner is checking for, and where the marks actually sit in each one.

Given processes with arrival and burst times, compute average waiting time for FCFS, SJF and round robin.

Draw the Gantt chart first, every time — most of the marks are in it. Then a table with columns Process, Arrival, Burst, Completion, Turnaround (completion minus arrival), Waiting (turnaround minus burst). Two traps: in SJF with arrival times you choose the shortest job among those that have arrived, not overall; in round robin a process that is preempted goes to the back of the ready queue, behind anything that arrived while it was running. Getting that queue order right is what separates a correct answer from a nearly correct one.

What are the four necessary conditions for deadlock?

Mutual exclusion — at least one resource is non-shareable. Hold and wait — a process holding one resource is waiting for another. No preemption — a resource cannot be forcibly taken back. Circular wait — a closed chain of processes each waiting on the next. All four must hold simultaneously; breaking any one prevents deadlock, which is exactly what prevention strategies do. Add that last sentence, and draw a small resource allocation graph with a cycle — it usually carries a mark of its own.

Explain the difference between paging and segmentation.

Paging divides memory into fixed-size pages and frames; the division is invisible to the programmer, it suffers internal fragmentation and no external fragmentation, and the address is a page number plus an offset. Segmentation divides by logical unit — code, stack, data — so segments vary in size, the programmer sees them, it suffers external fragmentation and no internal, and the address is a segment number plus an offset. A two-column table plus one address-translation diagram answers this completely.

What is thrashing? How is it handled?

Thrashing is when a process spends more time servicing page faults than executing, because it has too few frames to hold its working set. Raising the degree of multiprogramming makes it worse, because every new process takes frames from the others — which is the counterintuitive part examiners look for. It is handled with the working set model, which gives each process the frames its recent references need, or with page fault frequency, which adds frames when the fault rate rises above a threshold and takes them back when it falls below. Mention that the CPU utilisation graph rises, peaks and then collapses; sketching that curve is often worth a mark.

Difference between — the ones that get asked

Every one of these is a five-mark question somewhere on this syllabus, and the marks are rarely in the first line. They are in the consequences underneath it.

OSI model vs TCP/IP model

OSI is the seven-layer teaching model that describes how networking ought to be organised. TCP/IP is the four-layer model the internet is actually built on.

 OSITCP/IP
LayersSeven — Physical, Data Link, Network, Transport, Session, Presentation, Application.Four — Link, Internet, Transport, Application.
Developed byISO, as a reference standard.DARPA, out of a working network.
Order of eventsModel first, protocols afterwards — which is why some layers have little real traffic.Protocols first, model written to describe them.
Session and PresentationSeparate layers 5 and 6.Folded into the Application layer.
Use in practiceTeaching, troubleshooting, and the phrase "that is a layer 2 problem".What the internet runs on.

Where people lose the marks

Learn the seven OSI layers in order — a mnemonic helps — because the exam asks for them and because engineers genuinely talk in layer numbers. Then know that TCP/IP is what is actually running on the machine in front of you.

Process vs Program

A program is a file on disk. A process is that file running, with memory, a program counter and a place in the scheduler's queue. One program can become many processes.

 ProgramProcess
What it isPassive — instructions stored in a file.Active — an instance in execution.
Lives inSecondary storage.Main memory, while running.
LifetimeUntil you delete the file.From launch to exit.
ResourcesNone.Memory, CPU time, open files, registers, a PCB.
How manyOne file.Many — open the same browser twice and there are two processes.

Where people lose the marks

The analogy that sticks: a program is the recipe, a process is the cooking. Two people can cook from one recipe at the same time, in separate kitchens, and neither one is the recipe.

Kernel vs Shell

The kernel is the part of the OS that talks to the hardware. The shell is the part you type into. The shell asks the kernel to do things on your behalf.

 KernelShell
PositionThe core, between hardware and everything else.The outer layer, between you and the kernel.
JobManage memory, processes, files and devices.Read your command, interpret it, ask the kernel to run it.
Interacts withHardware directly.The user directly.
How manyOne per running system.Several available — bash, zsh, sh, PowerShell — and you can switch.
Runs inKernel mode, with full privileges.User mode, like any other program.

Where people lose the marks

A shell is just a program. That is worth saying out loud, because it explains why you can have several, replace yours, or write your own — which is a standard OS lab exercise.

System software vs Application software

System software runs the machine. Application software does a job for you. The operating system is the clearest example of the first; a browser is the clearest example of the second.

 System softwareApplication software
ServesThe hardware and the other software.The user's own task.
Runs whenFrom boot until shutdown.When you open it.
ExamplesOperating system, device drivers, compilers, assemblers, utilities.Browsers, word processors, Tally, media players, games.
Can you work without itNo — the machine will not run.Yes. The computer still works, you just cannot do that one task.
Written forA specific architecture or platform.A platform's API, often portable across machines.

Where people lose the marks

Compilers catch people out. A compiler is system software, even though you open it deliberately like an application — because its job is to serve other software, not to do a task for you directly.

Multiple choice, with the reason

Universities set an objective section and campus written rounds are almost nothing else. The answer is marked, and every one of them says why — an answer key you can only memorise is worth nothing in a viva.

  1. 01

    Which scheduling algorithm can cause starvation of long processes?

    • aFCFS
    • bShortest Job First
    • cRound Robin
    • dFirst In First Out

    Why — SJF always prefers the shortest job, so a long one can be postponed indefinitely while short jobs keep arriving. Round robin cannot starve anybody, because every process gets its quantum in turn.

  2. 02

    Turnaround time is calculated as:

    • aCompletion time minus arrival time
    • bCompletion time minus burst time
    • cWaiting time plus arrival time
    • dBurst time minus waiting time

    Why — Turnaround is the whole time in the system: completion minus arrival. Waiting time is then turnaround minus burst. Writing both formulas at the top of the answer prevents the commonest arithmetic slip in this paper.

  3. 03

    Belady's anomaly is the observation that:

    • aMore frames always reduce page faults
    • bMore frames can increase page faults
    • cLRU always beats FIFO
    • dPage faults are independent of frame count

    Why — With FIFO replacement, adding a frame can increase the fault count for some reference strings. It is set specifically to catch the assumption that more memory is always better. LRU and optimal do not suffer from it.

  4. 04

    Which is NOT one of the four necessary conditions for deadlock?

    • aMutual exclusion
    • bHold and wait
    • cPreemption
    • dCircular wait

    Why — The condition is NO preemption — a resource cannot be forcibly taken back. Allowing preemption is one of the ways deadlock is prevented, so listing it as a cause is backwards.

  5. 05

    Internal fragmentation is a problem in:

    • aSegmentation
    • bPaging
    • cBoth equally
    • dNeither

    Why — Paging uses fixed-size frames, so the last page of a process is usually part empty — wasted space inside an allocated block. Segmentation uses variable sizes and suffers external fragmentation instead.

  6. 06

    A process in the ready state is waiting for:

    • aAn I/O operation
    • bThe CPU
    • cA semaphore
    • dA page to be loaded

    Why — Ready means it has everything it needs except a processor. Waiting for I/O or a semaphore puts it in the blocked state, and the difference between ready and blocked is the heart of the state diagram.

  7. 07

    Thrashing happens when:

    • aToo many processes share too few frames, so paging dominates execution
    • bThe disk is full
    • cThe CPU overheats
    • dTwo processes deadlock

    Why — Each process lacks the frames its working set needs, so it faults constantly. The counterintuitive part is that raising the degree of multiprogramming makes it worse, because new processes take frames from the others.

  8. 08

    Which disk scheduling algorithm services the request closest to the current head position?

    • aFCFS
    • bSSTF
    • cSCAN
    • dC-SCAN

    Why — Shortest Seek Time First. It minimises head movement and can starve distant requests, which is why SCAN — the lift algorithm — sweeps in one direction instead.

Viva questions, and what a good answer sounds like

GNDU’s own scheme says the viva runs one-to-one beside the practical exam, about the code you are writing at that moment. These are the questions that get asked, and what the examiner is listening for in the reply.

“What is the difference between a process and a thread?”

A process has its own address space; threads of one process share it. That makes a thread cheaper to create and switch between, and it is also why threads need synchronisation and separate processes usually do not.

“Why does the operating system switch between processes at all?”

To keep the CPU busy while a process waits on something slow, usually I/O, and to give every process a fair share. The cost is the context switch, which is pure overhead — saving and restoring registers and the program counter.

“What exactly is saved during a context switch?”

The contents of the process control block: the program counter, the register set, the memory management information and the process state. It has to be enough to resume as if nothing had happened.

“You have a deadlock. What are your options?”

Prevent it by breaking one of the four conditions, avoid it by checking each request against a safe state, detect it and recover by killing a process or preempting a resource, or ignore it — which is what most general-purpose systems actually do.

“Why is a semaphore needed if a simple flag variable would do?”

Because testing the flag and setting it are two separate steps, and another process can run between them. A semaphore's wait and signal are atomic, which is exactly the guarantee a flag cannot give.

“Explain the output your scheduling program just produced.”

Walk the Gantt chart aloud: which process was chosen at each decision point and why it was chosen over the others that had arrived. An answer that reads out the average without being able to justify one choice is the one that loses marks.

Past the syllabus

Your paper stops somewhere, and a job interview does not. If you want the version of this subject that goes further than the scheme asks for, there is a full course for it.

CallWhatsAppFree demo