← mercor Interview Insights

mercor·Software Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Technical screen for an Infrastructure Engineer role at Mercor. One question, pretty deep on Linux internals. The kind of interview where you realize mid-answer how many edge cases you've never actually thought through carefully.

Questions Asked (1)

Q1

Walk me through the difference between a process and a thread on Linux, covering memory isolation, how the kernel schedules them, file descriptor sharing, signal handling, context switch overhead, and when you'd actually choose one over the other.

System DesignTechnical Trade-offs
Author's notes

Started okay with address space isolation and task_struct, but when they pushed on clone() flags and exactly how threads share memory vs processes I got a bit fuzzy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by contrasting processes and threads across the six dimensions the interviewer listed, using a consistent comparison framework. Start with the fundamental memory isolation difference, then move through scheduling, file descriptors, signals, and context switch overhead, and finish with practical guidance on when to choose each. Keep the explanation grounded in concrete Linux examples (e.g., fork/clone, pthreads) to show depth without overcomplicating.

Pro tip: Mention that Linux doesn't inherently distinguish processes and threads—both are tasks created via clone() with different flags—and that the real difference is which resources are shared. This shows you understand the kernel implementation, not just textbook definitions.

1. Define the core distinction

Explain that a process is an independent execution unit with its own virtual address space, while a thread is a lighter execution unit within a process that shares the address space and other resources. Note that in Linux both are represented as tasks and created via clone().

2. Compare memory isolation and file descriptor sharing

Describe how processes have separate memory (copy-on-write after fork) and separate file descriptor tables, while threads share memory and file descriptors by default. Mention that threads can still have thread-local storage and that file descriptor sharing means closing a file in one thread affects all.

3. Explain scheduling and signal handling

State that the Linux CFS scheduler schedules threads (tasks) individually, not processes as a whole, so threads within a process can run concurrently on different CPUs. For signals, explain that process-directed signals can be handled by any thread that doesn't block them, while thread-directed signals (e.g., from pthread_kill) go to a specific thread.

4. Discuss context switch overhead

Contrast the cost: a thread context switch within the same process is cheaper because it avoids switching page tables (no TLB flush), while a process context switch requires changing the address space and flushing TLB entries, making it more expensive. Note that both still involve kernel mode transitions and saving/restoring registers.

5. Give practical selection criteria

Conclude with when to use each: processes for isolation, fault tolerance, and security (e.g., separate services); threads for performance, shared state, and low-latency communication (e.g., parallel computation, I/O multiplexing). Mention that modern designs often use a hybrid (e.g., process pools with thread pools) or async I/O to avoid thread overhead.

Key Points to Mention

  • Linux implements both as tasks via clone(); the difference is which resources are shared (CLONE_VM, CLONE_FILES, etc.).
  • Processes have separate virtual address spaces; threads share the same address space, so one thread's crash can bring down the whole process.
  • The CFS scheduler schedules individual threads, not processes, allowing intra-process parallelism.
  • File descriptors are shared among threads by default, so operations like close() affect all threads; processes have independent FD tables.
  • Signals can be process-directed (handled by any thread) or thread-directed (specific thread); signal masks are per-thread.
  • Thread context switches are cheaper (no page table switch/TLB flush), but process switches provide stronger isolation.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.