CS Fundamentals Interview Questions
1: What is a system call?
- Tag/topic: Operating Systems
- Source: Amazon
- Role: Cloud Support Associate
Định nghĩa: System call là interface duy nhất để chương trình user space yêu cầu dịch vụ từ kernel (I/O, memory, process management).
Cơ chế: Chương trình thực thi một trap instruction (syscall trên x86-64) → CPU chuyển từ user mode sang kernel mode → kernel thực thi handler tương ứng dựa trên syscall number → trả kết quả và quay về user mode.

flowchart TD
subgraph USER["User space (Ring 3)"]
APP["Application<br/>calls printf(#quot;hi#quot;)"]
LIBC["libc wrapper<br/>write(1, #quot;hi#quot;, 2)"]
APP --> LIBC
end
SYS["syscall instruction<br/>CPU switch: Ring 3 to Ring 0"]
subgraph KERNEL["Kernel space (Ring 0)"]
TABLE["Syscall table<br/>dispatch by number in rax"]
HANDLER["sys_write handler<br/>copies buffer, does I/O"]
TABLE --> HANDLER
end
LIBC --> SYS
SYS --> TABLE
HANDLER -.->|"return value in rax"| APP
classDef userBox fill:#1B5E9B,stroke:#185FA5,color:#fff
classDef kernelBox fill:#4A3F9E,stroke:#534AB7,color:#fff
classDef node fill:#3F3F3C,stroke:#5F5E5A,color:#E8E6DE
classDef syscall fill:#7A4A0A,stroke:#BA7517,color:#FAC775
class APP,LIBC,TABLE,HANDLER node
class SYS syscall
style USER fill:#1B5E9B,stroke:#185FA5,color:#fff
style KERNEL fill:#4A3F9E,stroke:#534AB7,color:#fff
Ví dụ phổ biến: read(), write(), open(), fork(), execve(), mmap()...
Lưu ý: Library function (như printf) không phải syscall — nó là wrapper, bên dưới gọi write(). Dùng strace để quan sát syscall thực tế.
flowchart LR
A["printf()<br/>user code"] --> B["Format engine<br/>parse %d, %s"]
B --> C["stdio buffer<br/>in FILE struct"]
C --> D["write() syscall<br/>only on flush"]
classDef gray fill:#3F3F3C,stroke:#5F5E5A,color:#E8E6DE
classDef teal fill:#0F6E56,stroke:#1D9E75,color:#E1F5EE
classDef amber fill:#7A4A0A,stroke:#BA7517,color:#FAC775
class A,B gray
class C teal
class D amber
2: What is an interrupt and how does the OS handle it?
- Tag/topic: Operating Systems
- Source: Amazon
- Role: Cloud Support Associate
3: What is the difference between a process and a thread in Linux?
- Tag/topic: Operating Systems
- Source: Amazon
- Role: Cloud Support Associate
4: What is the dining philosophers problem?
- Tag/topic: Operating Systems
- Source: Amazon
- Role: N/A
5: Write an example to showcase deadlock.
- Tag/topic: Operating Systems
- Source: Amazon
- Role: N/A
6: What is priority inversion?
- Tag/topic: Operating Systems
- Source: Apple
- Role: N/A
7: Calculate waiting time for processes as if the OS scheduled them using FCFS.
- Tag/topic: Operating Systems
- Source: Google
- Role: N/A
8: Compare round-robin and FCFS CPU scheduling
- Tag/topic: Operating Systems
- Source: Google
- Role: N/A
9: Explain context switching.
- Tag/topic: Operating Systems
- Source: Google
- Role: N/A
10: Explain shortest-job-first (SJF) CPU scheduling.
- Tag/topic: Operating Systems
- Source: Google
- Role: N/A
11: What is a TLB (translation lookaside buffer)?
- Tag/topic: Operating Systems
- Source: Google
- Role: N/A
12: What is the difference between user mode and kernel mode?
- Tag/topic: Operating Systems
- Source: Google — Walmart · Startup
- Role: N/A
13: Explain paging.
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
14: Explain segmentation and page faults.
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
15: Explain the difference between paging and segmentation.
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
16: Explain thrashing.
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
17: Explain virtual memory.
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
18: What is the difference between mutex and semaphore?
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
19: What is the difference between process and thread?
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: N/A
20: What is virtual memory and why is it used?
- Tag/topic: Operating Systems
- Source: LinkedIn
- Role: SSE · India
21: What is the difference between a spinlock and a mutex?
- Tag/topic: Operating Systems
- Source: Meta
- Role: E4 SWE · Passed Hiring Committee · USA
22: How to solve deadlock?
- Tag/topic: Operating Systems
- Source: Microsoft
- Role: SDE · L60
23: What is starvation in CPU scheduling?
- Tag/topic: Operating Systems
- Source: Microsoft
- Role: SDE · L60
24: What are common HTTP status codes and their meanings?
- Tag/topic: Networking
- Source: Amazon
- Role: SDE-2 · Chennai
25: What is the difference between HTTP and HTTPS?
- Tag/topic: Networking
- Source: Amazon
- Role: SDE-2 · Chennai
26: What is the difference between IPv4 and IPv6?
- Tag/topic: Networking
- Source: Amazon
- Role: Cloud Support Associate
27: Explain the OSI model — what happens at each layer?
- Tag/topic: Networking
- Source: Google
- Role: N/A
28: How does DNS work?
- Tag/topic: Networking
- Source: Google
- Role: N/A
29: How does a CDN improve performance?
- Tag/topic: Networking
- Source: Google
- Role: N/A
30: What happens when you type google.com in a browser?
- Tag/topic: Networking
- Source: Google
- Role: N/A
31: What is the difference between ARP and DNS?
- Tag/topic: Networking
- Source: Google
- Role: N/A
32: What is the difference between TCP and UDP?
- Tag/topic: Networking
- Source: Google
- Role: N/A
33: What is the difference between authentication and authorization?
- Tag/topic: Networking
- Source: Google
- Role: N/A
34: What is the difference between cookies and sessions?
- Tag/topic: Networking
- Source: Google
- Role: N/A
35: When would you use UDP instead of TCP?
- Tag/topic: Networking
- Source: Google
- Role: N/A
36: Explain the TCP three-way handshake.
- Tag/topic: Networking
- Source: Meta
- Role: Software Engineer (Product) E4 · US
37: How does TLS/SSL work?
- Tag/topic: Networking
- Source: Meta
- Role: Software Engineer (Product) E4 · US
38: What is CORS and why does it exist?
- Tag/topic: Networking
- Source: Meta
- Role: Software Engineer (Product) E4 · US
39: What is the difference between HTTP/1.1 and HTTP/2?
- Tag/topic: Networking
- Source: Meta
- Role: Software Engineer (Product) E4 · US
40: Explain REST API principles.
- Tag/topic: Networking
- Source: Microsoft
- Role: Azure Data Team · AA Round Expectations
41: Explain how NAT works.
- Tag/topic: Networking
- Source: Microsoft
- Role: Azure Data Team · AA Round Expectations
42: Explain database replication.
- Tag/topic: Database
- Source: Amazon
- Role: SDE-2 · Chennai
43: How will you migrate data from RDBMS to NoSQL while maintaining availability and consistency?
- Tag/topic: Database
- Source: Amazon
- Role: SDE-2 · Chennai
44: What is connection pooling and why is it used?
- Tag/topic: Database
- Source: Amazon
- Role: SDE-2 · Chennai
45: What is database denormalization and when would you use it?
- Tag/topic: Database
- Source: Amazon
- Role: SDE-2 · Chennai
46: What is the difference between SQL and NoSQL?
- Tag/topic: Database
- Source: Amazon
- Role: SDE-2 · Chennai
47: Explain INNER JOIN vs LEFT JOIN.
- Tag/topic: Database
- Source: Google
- Role: Data Engineer
48: What is the difficulty level for DSA and SQL (Google Data Engineer)?
- Tag/topic: Database
- Source: Google
- Role: Data Engineer
49: How can deadlock occur in a database?
- Tag/topic: Database
- Source: LinkedIn
- Role: Senior Software Engineer
50: What are ACID properties?
- Tag/topic: Database
- Source: LinkedIn
- Role: Senior Software Engineer
51: What are database isolation levels?
- Tag/topic: Database
- Source: LinkedIn
- Role: Senior Software Engineer
52: What is a database transaction?
- Tag/topic: Database
- Source: LinkedIn
- Role: Senior Software Engineer
53: What is the difference between a primary key and a unique key?
- Tag/topic: Database
- Source: LinkedIn
- Role: Senior Software Engineer
54: Explain normalization in databases.
- Tag/topic: Database
- Source: Meta, Amazon, Facebook, Apple, ByteDance, Shoppee, Grab
- Role: Software Engineer
55: What is optimistic vs pessimistic locking in databases?
- Tag/topic: Database
- Source: Meta, Amazon, Facebook, Apple, ByteDance, Shoppee, Grab
- Role: Software Engineer
56: Explain database indexing — how does a B+ tree index work?
- Tag/topic: Database
- Source: Microsoft
- Role: Software Engineer · L60 · Bengaluru · Hyderabad
57: How would you index the database to efficiently handle GET requests?
- Tag/topic: Database
- Source: Microsoft
- Role: Software Engineer · L60 · Bengaluru · Hyderabad
58: What is a write-ahead log (WAL)?
- Tag/topic: Database
- Source: Microsoft
- Role: SDE · L60
59: What is the difference between clustered and non-clustered indexes?
- Tag/topic: Database
- Source: Microsoft
- Role: Software Engineer · L60 · Bengaluru · Hyderabad
60: What is sharding in databases?
- Tag/topic: Database
- Source: Uber
- Role: SSE - II (Level 5B) · India
61: What is two-phase commit (2PC)?
- Tag/topic: Database
- Source: Uber
- Role: SSE - II (Level 5B) · India
62: How do deadlocks happend and what are ways to resolve them?
- Tag/topic: Concurrency
- Source: Apple
- Role: Experienced
63: What is the difference between parallelism and concurrency?
- Tag/topic: Concurrency
- Source: Apple
- Role: Experienced
64: What is the difference between synchronous and asynchronous I/O?
- Tag/topic: Concurrency
- Source: Apple
- Role: Experienced
65: What is a thread pool and why use one?
- Tag/topic: Concurrency
- Source: Google — Walmart · Startup.
- Role: Experienced
66: What is the difference between multi-threading and multi-processing
- Tag/topic: Concurrency
- Source: Google
- Role: N/A
67: What is a condition variable?
- Tag/topic: Concurrency
- Source: LinkedIn
- Role: N/A
68: What is the difference between a mutex and a lock?
- Tag/topic: Concurrency
- Source: LinkedIn
- Role: N/A
69: Explain compare-and-swap (CAS)
- Tag/topic: Concurrency
- Source: Meta
- Role: E4 SWE · Passed Hiring Committee · USA.
70: How would you handle concurrency / race conditions when streaming from multiple devices at the same time?
- Tag/topic: Concurrency
- Source: Meta
- Role: E4 SWE · Passed Hiring Committee · USA.
71: What is a race condition and how do you prevent it?
- Tag/topic: Concurrency
- Source: Meta
- Role: E4 SWE · Passed Hiring Committee · USA.
72: What is an atomic operation?
- Tag/topic: Concurrency
- Source: Meta
- Role: E4 SWE · Passed Hiring Committee · USA.
73: What is a memory leak and how do you detect one?
- Tag/topic: Memory / Runtime
- Source: Apple
- Role: Experienced
74: What is a stack overflow vs heap overflow?
- Tag/topic: Memory / Runtime
- Source: Apple
- Role: Experienced
75: Explain the difference between heap and stack memory.
- Tag/topic: Memory / Runtime
- Source: Google
- Role: N/A
76: Explain garbage collection in Java.
- Tag/topic: Memory / Runtime
- Source: Linkedin
- Role: N/A
77: Explain mark-and-sweep vs generational garbage collection
- Tag/topic: Memory / Runtime
- Source: Linkedin
- Role: N/A
78: Explain the difference between final, finalize, and finally in Java.
- Tag/topic: Memory / Runtime
- Source: Linkedin
- Role: N/A
79: How does garbage collection work?
- Tag/topic: Memory / Runtime
- Source: Linkedin
- Role: N/A
80: What is the difference between pass-by-value and pass-by-reference?
- Tag/topic: Memory / Runtime
- Source: Microsoft
- Role: SDE · L60.
81: What is reference counting in garbage collection?
- Tag/topic: Memory / Runtime
- Source: Oracle
- Role: Software Engineer · Bengaluru.
82: Explain the observer design pattern.
- Tag/topic: OOP / Design Patterns
- Source: Amazon
- Role: N/A
83: What is the adapter design pattern?
- Tag/topic: OOP / Design Patterns
- Source: Amazon
- Role: N/A
84: What is abstraction in OOP?
- Tag/topic: OOP / Design Patterns
- Source: Apple
- Role: Human Engineering SDE1 · Cupertino.
85: What is encapsulation in OOP?
- Tag/topic: OOP / Design Patterns
- Source: Apple
- Role: Human Engineering SDE1 · Cupertino.
86: What is inheritance?
- Tag/topic: OOP / Design Patterns
- Source: Apple
- Role: Human Engineering SDE1 · Cupertino.
87: What is polymorphism?
- Tag/topic: OOP / Design Patterns
- Source: Apple
- Role: Human Engineering SDE1 · Cupertino.
88: Explain composition over inheritance.
- Tag/topic: OOP / Design Patterns
- Source: Google
- Role: N/A
89: Explain the factory design pattern.
- Tag/topic: OOP / Design Patterns
- Source: Microsoft
- Role: SDE · L60.
90: What is the difference between compile-time polymorphism and runtime polymorphism?
- Tag/topic: OOP / Design Patterns
- Source: Microsoft
- Role: SDE · L60.
91: Does Java support multiple inheritance?
- Tag/topic: OOP / Design Patterns
- Source: Oracle
- Role: Software Engineer · Bengaluru.
92: What is the difference between an interface and an abstract class?
- Tag/topic: OOP / Design Patterns
- Source: Oracle
- Role: Software Engineer · Bengaluru.
93: What is the singleton design pattern?
- Tag/topic: OOP / Design Patterns
- Source: Uber
- Role: SSE - II (Level 5B) · India.
94: What is the strategy design pattern?
- Tag/topic: OOP / Design Patterns
- Source: Uber
- Role: SSE - II (Level 5B) · India.
95: What is the difference between monolith and microservices?
- Tag/topic: Distributed Systems
- Source: Amazon
- Role: SDE-2 · Chennai.
96: How does a load balancer work?
- Tag/topic: Distributed Systems
- Source: Google
- Role: N/A.
97: What is idempotency in APIs?
- Tag/topic: Distributed Systems
- Source: Google
- Role: N/A.
98: How to keep distributed system consistent?
- Tag/topic: Distributed Systems
- Source: Microsoft
- Role: SDE · L60.
99: What is eventual consistency vs strong consistency?
- Tag/topic: Distributed Systems
- Source: Microsoft
- Role: SDE · L60.
100: Explain the CAP theorem.
- Tag/topic: Distributed Systems
- Source: Uber
- Role: SSE - II (Level 5B) · India.