Recruitment and knowledge question base. Filter, search and test your knowledge.
A process has its own address space and resources; threads share the same address space within a process. It matters for isolation, memory overhead, and how you manage shared state and concurrency.
Context switching is when the CPU switches from one thread/process to another. It’s expensive because the OS must save/restore registers, switch memory mappings, and flush caches/TLBs.
Virtual memory gives each process its own address space mapped to physical memory. Paging moves fixed-size pages between RAM and disk, enabling isolation and larger memory than RAM.
Preemptive scheduling lets the OS interrupt tasks to ensure fairness and responsiveness. Cooperative scheduling relies on tasks yielding voluntarily, which can cause starvation if they don’t.
A system call is the controlled entry point into the OS kernel for privileged operations (I/O, memory, processes). User/kernel mode separation protects the system from buggy or malicious applications.
A file descriptor is a numeric handle to an open file or socket. Buffering batches I/O in memory to reduce syscalls and improve throughput, at the cost of delayed writes.
Deadlocks require four conditions: mutual exclusion, hold-and-wait, no preemption, and circular wait. Prevention breaks at least one condition (e.g., ordering locks or using timeouts).
A mutex provides exclusive access, a semaphore controls access to a limited number of resources, and a read-write lock allows multiple readers or one writer. Use them based on contention and access patterns.
Signals are asynchronous notifications sent to a process (e.g., SIGTERM, SIGINT). A process can handle them with signal handlers, ignore them, or use default actions like termination.
mmap maps a file or device into a process’s address space so it can be accessed like memory. It’s useful for large files, random access, and zero-copy sharing.