GATE GUIDE

GATE CSE Operating Systems Formula Sheet: Paging, EAT, Deadlock

By MD ANISH AHAMADUpdated 4 Oct 20268 min read
GATE CSE Operating Systems Formula Sheet: Paging, EAT, Deadlock

Operating systems numerical questions in GATE CSE come from a short list of formulas: scheduling times, effective access time, paging arithmetic, deadlock counts, inode sizes and fork counts. This sheet goes deeper than the general GATE CSE formula sheet. Each formula comes with a one-line worked example and the trap that costs marks.

In this guide
  1. Key takeaways
  2. The terms this sheet uses
  3. Scheduling formulas, from timeline to averages
  4. Paging arithmetic: entries, table size and levels
  5. Effective access time with a TLB
  6. Effective access time with page faults
  7. Deadlock: the minimum number of resources
  8. File-system formulas: inode size and disk accesses
  9. Process and semaphore counts
  10. Quick revision

Key takeaways

The terms this sheet uses

Every formula below is built from a few quantities. Learn them once and the formulas read like sentences.

Logs are base 2 throughout, and KB means 2102^{10} bytes unless a question says otherwise.

Scheduling formulas, from timeline to averages

Every scheduling question ends in the same three subtractions. Draw the Gantt chart first, read off completion times, then apply the table.

Formula One-line example Watch out for
TAT=C−A\text{TAT} = C - A Arrives at 2, completes at 11: TAT=9\text{TAT} = 9 Use completion, not the last dispatch
WT=TAT−burst\text{WT} = \text{TAT} - \text{burst} Burst 4: WT=9−4=5\text{WT} = 9 - 4 = 5 Context-switch time counts in waiting unless stated
RT=first dispatch−A\text{RT} = \text{first dispatch} - A First runs at 6: RT=4\text{RT} = 4 Response is not waiting in round robin
CPU utilisation ≈1−qn\approx 1 - q^{n} q=0.6q = 0.6, n=3n = 3: 1−0.216=0.7841 - 0.216 = 0.784 qq is the I/O-wait fraction, not the CPU fraction

Two conventions decide many timelines. In round robin, a new arrival joins the queue before the preempted process when both happen at the same instant. In SRTF, a new arrival preempts only if its burst is strictly less than the running process's remaining time.

Trap: A quantum larger than every remaining burst turns round robin into FCFS. Count context switches only when the running process changes. The CPU scheduling question guide works through these timelines.

Paging arithmetic: entries, table size and levels

Single-level paging needs one idea: the page-number bits decide how many entries the table has. Multi-level paging adds a second idea: each inner table must fit in one page.

Formula One-line example Watch out for
Pages =2v−o= 2^{v - o} v=32v = 32, 4 KB pages: 232−12=2202^{32-12} = 2^{20} pages oo comes from the page size in bytes
Table size == pages ×\times PTE size 220×4 B=4 MB2^{20} \times 4\text{ B} = 4\text{ MB} PTE size given in bits versus bytes
PTE bits ≥log⁡2(frames)+flag bits\ge \log_2(\text{frames}) + \text{flag bits} 1 GB RAM, 4 KB frames: 2182^{18} frames, 18 bits plus flags Frames come from physical memory, not virtual
Entries per page =page sizePTE size\displaystyle = \dfrac{\text{page size}}{\text{PTE size}} 8 KB8 B=1024\displaystyle \dfrac{8\text{ KB}}{8\text{ B}} = 1024, so 10 bits per level Assumes every table fits in one page
Levels =⌈v−obits per level⌉\displaystyle = \left\lceil \dfrac{v - o}{\text{bits per level}} \right\rceil v=46v = 46, o=13o = 13: ⌈33/10⌉=4\lceil 33/10 \rceil = 4 levels The top level may be partly used
Inverted table size == frames ×\times entry size 2182^{18} frames ×\times 8 B =2 MB= 2\text{ MB} Scales with physical, not virtual, memory

Remember: When you count the memory a sparse process uses for its page tables, the outer table always costs one full page, and every partly used inner table also costs a full page.

Effective access time with a TLB

The average time is the hit case weighted by its probability, plus the miss case weighted by its own. On a hit you pay one TLB lookup and one memory access. On a miss you pay the lookup, one access per page-table level, and then the data access:

EAT=h (tTLB+tm)+(1−h) (tTLB+(L+1) tm)\text{EAT} = h\,(t_{TLB} + t_{m}) + (1 - h)\,\big(t_{TLB} + (L + 1)\,t_{m}\big)

Here hh is the TLB hit ratio, tTLBt_{TLB} the lookup time, tmt_m one memory access and LL the number of page-table levels.

Worked example. Take tTLB=10t_{TLB} = 10 ns, tm=100t_m = 100 ns, h=0.9h = 0.9 and a single-level table:

EAT=0.9×110+0.1×210=99+21=120 ns\text{EAT} = 0.9 \times 110 + 0.1 \times 210 = 99 + 21 = 120\text{ ns}

With a two-level table the miss term grows to 10+300=31010 + 300 = 310 ns, so the EAT becomes 99+31=13099 + 31 = 130 ns.

If the question says the TLB is searched in parallel with memory, the hit term is just tmt_m and the miss term stays tTLB+(L+1) tmt_{TLB} + (L + 1)\,t_m. The page-table walk always goes to memory.

Effective access time with page faults

Demand paging uses the same weighting, with the page-fault rate pp in place of the miss ratio:

EAT=(1−p) tm+p tfault,tfault=d tdirty+(1−d) tclean\text{EAT} = (1 - p)\,t_{m} + p\,t_{\text{fault}}, \qquad t_{\text{fault}} = d\,t_{\text{dirty}} + (1 - d)\,t_{\text{clean}}

Here dd is the fraction of victim pages that are dirty and must be written back.

Worked example. With tm=100t_m = 100 ns, tfault=8t_{\text{fault}} = 8 ms =8×106= 8 \times 10^{6} ns and p=10−6p = 10^{-6}, the fault term adds 10−6×8×106=810^{-6} \times 8 \times 10^{6} = 8 ns. The EAT is about 100+8=108100 + 8 = 108 ns.

Trap: Multiplying pp by 8 instead of 8×1068 \times 10^{6} gives an answer a million times too small. Write the unit next to every number before you substitute.

The page-replacement traces that feed these fault rates are covered in page replacement questions for GATE CSE.

The book's last-minute revision sheet gives the full operating systems formula table, with symbols, when each formula applies and its typical trap, alongside the same tables for the other nine subjects. It is part of the GATE CSE 2027 book.

Deadlock: the minimum number of resources

The worst case for one resource type is that every process holds one unit fewer than it needs. If one more unit exists, some process can finish and release everything. So deadlock is impossible exactly when:

R≥∑i(needi−1)+1R \ge \sum_{i} (\text{need}_i - 1) + 1
Formula One-line example Watch out for
Homogeneous: R≥n(k−1)+1R \ge n(k - 1) + 1 3 processes needing 4 each: 3×3+1=103 \times 3 + 1 = 10 R=n(k−1)R = n(k - 1) is still deadlock-prone
Largest nn for given RR, kk: ⌊R−1k−1⌋\displaystyle \left\lfloor \dfrac{R - 1}{k - 1} \right\rfloor R=10R = 10, k=4k = 4: ⌊9/3⌋=3\lfloor 9/3 \rfloor = 3 Floor, not ceiling
Banker's: Need=Max−Allocation\text{Need} = \text{Max} - \text{Allocation} Max 7, holds 2: need 5 Compare a request with Need and Available, not Max

File-system formulas: inode size and disk accesses

A block of BB bytes holds p=B/pointer sizep = B / \text{pointer size} pointers. The single indirect pointer reaches pp blocks, the double p2p^2 and the triple p3p^3, so:

Max file size=(d+p+p2+p3)×B\text{Max file size} = (d + p + p^{2} + p^{3}) \times B

Worked example. With B=1B = 1 KB, 4-byte pointers and d=10d = 10, p=256p = 256. The sum is 10+256+65536+16777216=1684301810 + 256 + 65536 + 16777216 = 16843018 blocks of 1 KB, a little over 16 GB.

Formula One-line example Watch out for
Accesses for byte XX (inode cached): 1 if ⌊X/B⌋<d\lfloor X/B \rfloor < d, 2 if <d+p< d + p, 3 if <d+p+p2< d + p + p^2, else 4 Byte 300 KB is block 300, which is ≥266\ge 266 and <65802< 65802: 3 accesses Add one if the inode itself must be read
FAT size == blocks ×⌈log⁡2blocks⌉\times \lceil \log_2 \text{blocks} \rceil bits 1 GB disk, 1 KB blocks: 220×202^{20} \times 20 bits =2.5= 2.5 MB Convert bits to bytes at the end
Bitmap size == blocks bits 2202^{20} bits =128= 128 KB One bit per block, not per byte

In one line: Pointers per block is pp, each extra level of indirection multiplies the reach by pp, and each level costs one more disk access.

Process and semaphore counts

Two small formulas cover most counting questions on fork() and semaphores.

Formula One-line example Watch out for
nn unconditional forks: 2n2^{n} processes, 2n−12^{n} - 1 children 3 forks: 8 processes, 7 children A fork inside a branch runs only in that branch's process
printf after a fork in an nn-iteration loop: 2n+1−22^{n+1} - 2 lines n=3n = 3: 2+4+8=142 + 4 + 8 = 14 lines Buffered output without a newline duplicates on fork
Blocked processes =∣S∣= \lvert S \rvert when S<0S < 0 S=2S = 2, five waits: S=−3S = -3, 3 blocked A semaphore initialised to 0 blocks the first wait

The operating systems important topics guide shows which of these families past papers have asked most, and the common mistakes guide lists the convention slips subject by subject.

More formula sheets: all of GATE CSE · Computer Networks · COA · Engineering Mathematics

Quick revision

  1. TAT=C−A\text{TAT} = C - A, WT=TAT−burst\text{WT} = \text{TAT} - \text{burst}, RT=first dispatch−A\text{RT} = \text{first dispatch} - A.
  2. TLB: EAT=h(tTLB+tm)+(1−h)(tTLB+(L+1)tm)\text{EAT} = h(t_{TLB} + t_m) + (1 - h)(t_{TLB} + (L + 1)t_m); one level gives tTLB+2tmt_{TLB} + 2t_m on a miss.
  3. Demand paging: EAT=(1−p)tm+p tfault\text{EAT} = (1 - p)t_m + p\,t_{\text{fault}}, with milliseconds converted to nanoseconds.
  4. Levels =⌈(v−o)/log⁡2(entries per page)⌉= \lceil (v - o) / \log_2(\text{entries per page}) \rceil; count the outer table as a full page.
  5. Deadlock-free needs n(k−1)+1n(k - 1) + 1 units; the largest nn is ⌊(R−1)/(k−1)⌋\lfloor (R - 1)/(k - 1) \rfloor.
  6. Inode: (d+p+p2+p3)×B(d + p + p^2 + p^3) \times B, with 1 to 4 disk accesses by pointer level.
  7. nn forks give 2n2^n processes and 2n−12^n - 1 children.

Frequently asked questions

What is the effective access time formula with a TLB in GATE?

With a serial TLB lookup and an L-level page table, EAT =h(tTLB+tm)+(1−h)(tTLB+(L+1)tm)= h(t_{TLB} + t_m) + (1 - h)(t_{TLB} + (L + 1)t_m). A hit costs one TLB lookup and one memory access. A miss costs the lookup, L page-table accesses and the data access. For a single-level table the miss term is tTLB+2tmt_{TLB} + 2t_m. Read whether the question says the TLB lookup overlaps memory access.

How many resources are needed so that deadlock can never occur?

For one resource type, deadlock is impossible when the number of units R is at least the sum of (need minus one) over all processes, plus one. With n processes each needing k units this becomes n(k−1)+1n(k - 1) + 1. Exactly n(k−1)n(k - 1) units is still deadlock-prone, because every process can hold k−1k - 1 units and wait forever.

How do I find the number of levels in a multi-level page table?

First find how many entries fit in one page: page size divided by the page-table entry size. The bits per level are the base-2 log of that number. Divide the page-number bits by the bits per level and take the ceiling. For example, 8 KB pages with 8-byte entries give 1,024 entries, so 10 bits per level, and 33 page-number bits need 4 levels.

What is the maximum file size formula for an inode?

Maximum file size =(d+p+p2+p3)×B= (d + p + p^2 + p^3) \times B, where d is the number of direct pointers, B is the block size and p is the number of pointers that fit in one block, block size divided by pointer size. The double indirect pointer reaches p2p^2 blocks and the triple indirect p3p^3. Units are powers of two unless the question says otherwise.

Do I need to memorise operating system formulas for GATE CSE?

Yes. You cannot carry notes into the exam hall, and most operating system numerical questions in past papers reuse a small set of formulas: scheduling times, effective access time, paging levels, minimum resources for deadlock freedom and inode file size. Learn each with one worked example and its trap. Confirm the current exam-day rules at gate2027.iitm.ac.in.

Sources

Dates, fees and the syllabus are set by the GATE 2027 organising institute and can change. Always confirm at gate2027.iitm.ac.in.

Keep reading

GATE CSE 2027 book1,020 pages · ₹250 ₹300
Buy now — ₹250