CS FundamentalsVery hardGATE CS (PYQ pattern)
A Unix file system contains only these names: directories /, /a, /a/b and /c, a regular file /a/f, and /c/g, which is a hard link to /a/f. Every directory has its '.' and '..' entries (the root's '..' refers to the root itself). What is the sum of the link counts of all inodes in the file system?
- A. 11
- B. 9
- C. 13
- D. 12
Correct answer: C. 13
The sum of all link counts equals the number of directory entries that name an inode. / has ., .., a, c (4); /a has ., .., b, f (4); /a/b has ., .. (2); /c has ., .., g (3): 13. Per inode: / = 4 (., .., a's .., c's ..), /a = 3, /a/b = 2, /c = 2, file = 2. Forgetting the root's own '..' and the hard link gives 11.
More Operating Systems questions
- A user-mode process accesses virtual pages with page-table entries (present, writable, user-accessible): page 0 (1,1,1), page 1 (1,0,1)…
- Locks are ordered L1 < L2 < L3 < L4 and every thread must acquire locks in increasing order. A thread acquires locks in the following…
- Memory (in KB, from address 0): OS 100, process A 150, hole 60, B 200, hole 90, C 120, hole 80, D 100, hole 100. Compaction slides every…
- A 100 MB process is swapped out and later swapped back in on a disk that transfers 50 MB/s with an 8 ms latency per transfer. Swap-out…
- Disk requests arrive as a Poisson stream of 100 per second; service times are exponential (M/M/1 per disk). Option X buys one disk twice…
- Round Robin uses a 20 ms quantum and every context switch costs 2 ms; all n processes are CPU-bound and always use the full quantum. From…