-
Kernel -- software that manages the system by providing access to hardware and other resources (memory, network stack, scheduling cpu, etc). Runs in priveleged CPU mode -- kernel mode. It uses kernel-space stack.
-
Process -- an OS abstraction for running programs. Runs in user mode with access to kernel mode via system calls. It consists of: memory address space, file descriptors, thread stacks, registers. Process uses user-space stacks. For example, syscalls use a s kernel exception stack associated with each thread.
-
System call -- a protocol for user programs to request kernel to perform privileged operations
-
Trap -- a signal sent to kernel to request a system routine (system calls, processor exceptions, interrups)
-
Hardware interrupt -- a signal sent by devise to kernel, it is a type of trap
-
Socket -- endpoints by which user-level aplications access the network
-
Network interface -- physical device to connect to network
-
IPIs -- inter-processor interrupt which is a way to coordinate processors in multiprocessor system
-
SystemD -- service manager on Linux. Among features -- dependecy-aware service startup, analytics (
systemd-analyze
) -
KPTI -- kernel page table isolation patches to mitigate "meltdown" vulnerability. The cost is 0.1% - 6% depending on number of syscalls (context switch is more expensive)
-
Functional unit CPU component does the following: fetch instruction, decode instruction, execute and (optionaly) memory access, register write-back.
-
user-time/kernel-time
ratio is high for computationally intensive applications and low for I/O bound (web server, etc). -
MMU -- memory managment unit. Performs virtual memory management. Memory is paged and the chache for pages translation is TLB (translation lookaside buffer). If there is tlb miss, MMU goes to Page tables (main memory).
-
futex -- fast user space mutex which is using atomic integer under the hood. Basic operations are
WAIT(addr, val)
(if *addr == val => current thread sleeps
andWAKE(addr, num)
(wakes up num threads waiting for the addressaddr
. -
toplev -- tool to find bottleneck in software https://github.com/andikleen/pmu-tools/wiki/toplev-manual
Reader/Writer problem and it's solution
https://gclub.com/when-to-use-reader-writer
As shown above, the writer uses the
atomic_store_explicit
function withmemory_order_release
to set the guard variable. This ensures that the write to data completes before the write to guard variable completes while allowing for later memory operations to hoist above the barrier.The reader uses the
atomic_load_explicit
function withmemory_order_acquire
to load the guard variable. This ensures that the load of the data starts only after the load of the guard variable completes while allowing for the earlier operations to sink below the barrier.atomic_store_explicit and atomic_load_explicit functions ensure that the operations are atomic and enforce the required compiler barriers implicitly.