Processes vs Threads: Memory, Switching Cost, Communication and Isolation

Quick Overview

Explain the difference between a process and a thread and when to use each. It tests operating-system fundamentals: memory sharing, creation and context-switch costs, communication and synchronization, isolation and crash behavior, and choosing workers for CPU-bound or I/O-bound work.

Processes vs Threads: Memory, Switching Cost, Communication and Isolation

Company: Mercor

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Explain the difference between a process and a thread, and say when you would use several processes and when several threads. This was one of the rapid-fire fundamentals questions in a short screening call, so the core answer should take a minute or two, with more depth ready if the interviewer digs in. ```hint Start from what is shared List what two threads of one process share and what each keeps for itself, then think about what follows for bugs and for crashes. ``` ```hint Cost of a switch Think about what the operating system must change when it switches between two processes that it does not change when it switches between two threads of the same process. ``` ### Clarifying Questions - Is there a specific operating system or language runtime in mind, for example Linux, or Python with its global interpreter lock? - Should the answer also place lighter-weight options, such as coroutines or async I/O, relative to threads? ### What a Strong Answer Covers - What a process owns, what its threads share, and what each thread keeps to itself - Creation and context-switch costs, and the reason they differ - How processes communicate compared with threads, and the synchronization that sharing requires - Isolation, and what happens when one thread or one process crashes - Choosing between them for CPU-bound and I/O-bound work, including limits imposed by the language runtime ### Follow-up Questions - Why might threads fail to speed up a CPU-bound computation in Python, and what would you use instead? - What happens to a process's other threads when one of them calls `fork()`, and why is that risky? - How do coroutines or async I/O compare with threads for serving 10,000 mostly idle connections? - A thread writes through a bad pointer and crashes. What happens to the rest of the process, and how would a multi-process design change that?

Overview: Explain the difference between a process and a thread and when to use each. It tests operating-system fundamentals: memory sharing, creation and context-switch costs, communication and synchronization, isolation and crash behavior, and choosing workers for CPU-bound or I/O-bound work.

Mercor logo
Mercor
Nov 24, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Explain the difference between a process and a thread, and say when you would use several processes and when several threads. This was one of the rapid-fire fundamentals questions in a short screening call, so the core answer should take a minute or two, with more depth ready if the interviewer digs in.

Clarifying Questions Guidance

  • Is there a specific operating system or language runtime in mind, for example Linux, or Python with its global interpreter lock?
  • Should the answer also place lighter-weight options, such as coroutines or async I/O, relative to threads?

What a Strong Answer Covers Guidance

  • What a process owns, what its threads share, and what each thread keeps to itself
  • Creation and context-switch costs, and the reason they differ
  • How processes communicate compared with threads, and the synchronization that sharing requires
  • Isolation, and what happens when one thread or one process crashes
  • Choosing between them for CPU-bound and I/O-bound work, including limits imposed by the language runtime

Follow-up Questions Guidance

  • Why might threads fail to speed up a CPU-bound computation in Python, and what would you use instead?
  • What happens to a process's other threads when one of them calls fork() , and why is that risky?
  • How do coroutines or async I/O compare with threads for serving 10,000 mostly idle connections?
  • A thread writes through a bad pointer and crashes. What happens to the rest of the process, and how would a multi-process design change that?