30 câu hỏi OS/JVM runtime
Trả lời theo ownership, lifecycle, kernel/runtime state, failure evidence và mitigation.
30 câu hỏi
Process và memory
1. Process khác program?
Program là executable/static code; process là running instance với PID, address space, credentials, FDs, threads và kernel state. exec thay program image trong process.
2. fork có copy toàn bộ memory?
Thường copy page tables/mappings với copy-on-write; physical page copy khi write. Kernel/runtime metadata vẫn có cost.
3. fork trong multithreaded process caveat?
Child chỉ có calling thread nhưng locks có thể ở trạng thái owner biến mất; trước exec chỉ async-signal-safe operations.
4. Zombie giữ gì?
Minimal exit status/accounting/PID entry chờ parent wait; không giữ normal heap/FD. Nhiều zombie exhaust process table/PIDs.
5. VSZ, RSS, PSS?
Virtual mapped range; resident pages with shared double-count; proportional shared allocation. Không cái nào riêng lẻ là heap/live data.
6. Minor vs major page fault?
Minor resolve không disk I/O, major cần load backing storage. Faults normal; rates/latency/working set determine impact.
7. RSS không giảm sau free?
Allocator arenas/cache, fragmentation, page cache/shared mappings or runtime retention; free to allocator không đảm bảo return kernel.
8. OOMKilled vs OOME?
Kernel/cgroup kills process vs JVM throws error on managed/native allocation path. Inspect cgroup events/exit/kernel and JVM evidence.
9. Copy-on-write bị phá khi nào?
Writes dirty pages, including allocator/runtime/GC activity after fork; large managed runtimes can lose sharing quickly.
10. mmap dùng gì?
File/anonymous/shared/private mappings, memory-mapped I/O and allocation; page faults, synchronization, durability and address-space lifecycle apply.
Threads, scheduler và IPC
11. Process vs thread resource sharing?
Threads share VM/files/handlers but have TID, registers, stack, scheduler state, signal mask and TLS; processes have stronger isolation.
12. Thread rẻ hơn process?
Often create/communicate cheaper, but stacks/tasks/context switches and shared-state correctness cost remain; measure workload.
13. Voluntary/involuntary context switch?
Block/yield vs scheduler preemption. Counts need reason and workload; cache/locality cost varies.
14. Load average high CPU low?
Runnable queue or uninterruptible I/O tasks; quota/throttling and D-state can raise load without host CPU saturation.
15. Nice/priority guarantee latency?
No; scheduling class/weight only CPU competition, locks/I/O/IRQ/quota and system pressure still dominate.
16. Affinity trade-off?
Locality/isolation vs reduced balancing/hotspots/NUMA mistakes. Use measured reason and cpuset/container awareness.
17. Futex là gì?
Fast user-space atomic path plus kernel wait/wake on contention; primitive under many locks/conditions, not complete mutex protocol alone.
18. Condition variable cần while?
Spurious wakeups and predicate can change before lock reacquire; always recheck condition under mutex.
19. Shared memory vs socket IPC?
Shared memory low-copy/high throughput but synchronization/crash/layout complexity; sockets isolate/frame/backpressure and work across hosts.
20. Deadlock vs livelock vs starvation?
Wait cycle/no progress, active reactions/no progress, and one task denied progress. Evidence and mitigations differ.
FD, containers và JVM
21. FD vs open file description?
FD per-process index; multiple FDs/processes may reference shared kernel open description with offset/status. FD flags can be per descriptor.
22. EMFILE vs ENFILE?
Per-process descriptor limit vs system-wide open file table exhaustion.
23. epoll readiness nghĩa gì?
Operation may make progress, not full read/write guarantee; edge-trigger must drain until EAGAIN and handle races.
24. SIGTERM vs SIGKILL?
TERM handleable for drain/cleanup; KILL immediate kernel termination. Grace deadline usually escalates TERM→KILL.
25. PID 1 container?
Namespace init must reap orphans and signal behavior differs; exec entrypoint/minimal init and process-tree shutdown tests.
26. cgroup CPU throttling?
cpu.max quota exhaust causes throttled intervals even if host has spare CPU elsewhere; inspect cpu.stat/PSI and latency.
27. Java RUNNABLE có đang CPU?
Not necessarily; JVM RUNNABLE may be native socket/I/O. Map per-thread CPU and stacks over time.
28. Virtual thread loại bỏ pool?
Reduces platform-thread scarcity for blocking concurrency, but downstream/CPU/memory must be bounded; semaphore/rate controls still needed.
29. Java process RSS gồm gì?
Heap, metaspace, code cache, stacks, GC/JIT structures, direct/JNI/native/mmap/shared libraries and allocator state.
30. CPU incident workflow?
Impact/time/scope → host+cgroup CPU/run queue/throttle → process/TID → sampled Java/native stacks → correlate load/release → bounded mitigation → SLI verification.