Common Operating System Questions
1. What do you mean by an operating system? What are its function?
2. binary semaphore vs. mutex
signal mechanism vs. locking mechanism
-
mutex mutual exclusion object, used for protecting critical resource only the owner process can release the mutex
-
binary semaphore wait() and signal() //using signaling mechanism hey, i’m done, you can carry on wait() and singal() is totally decoupled you can wait() (decrement) on Process B and signal() on process A (increment) semaphore: integer indicating number of “toilets” available mutex: object acts like a key
recursive mutex
chrt -p
3. interrupt vs system call
independent process and cooperating process
A child process inherits open files from its parent
socket and RPCs (Remote Procedure Calls)
rendezvous mechanism.
4. Thread
A thread is a basic unit of CPU utilizatin; it comprises a thread ID, a program counter (PC), a register set, and a stack.
Amdahl’s Law
check page-size (today typically 4KB or 8 KB), linux 4KB getconf PAGESIZE
The standard solution to this problem is to use a special, small, fast-lookup hardware cache called a translation look-aside buffer ( TLB )
why stack’s memory address grows downward and heap’s memory grows upward
Most of the answers are too caught up in the abstractions.
Stack allocation is done at the CPU level, by a simple sub intruction on the stack pointer.
Heap allocation, on the other hand, is managed by the operating system, or some other abstraction that “manages” memory.
What’s faster - a single CPU instruction, or the set of operations done by calling an operating system’s memory management algorithm? ;)
Heap allocations are done at run time, so there’s no way for a compiler to know where in the heap something gets allocated.
I’m wondering about the historical rationale for this