---
title: "Threads, checkpoint, distributed commit"
subject: "Distributed System"
chapter: 3
key: "semester_7/distributed_system:threads-checkpoint-commit"
source: https://www.bctengineer.com/q/semester_7/distributed_system/threads-checkpoint-commit
site: BCT Engineering
---

# Threads, checkpoint, distributed commit

Distributed System · Chapter 3: Operating System Support

- Asked in: 2072 Kartik, 4+2+2 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/threads-checkpoint-commit
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-3

## Question

How do threads differ from process? How does checkpoint help in recovery? What does distributed commit refer to?

## Short answer

Threads share process memory and are lightweight, while processes have isolated address spaces. A checkpoint saves process state to stable storage, enabling rollback recovery from the latest consistent global state without domino effect. Distributed commit ensures all participants either all commit or all abort an operation, typically using two-phase commit.

## Answer

#### Threads versus process
A **process** has its own protected address space and resources, whereas **threads** are lightweight units of execution inside a process that share its address space, data and open files, but have their own stack, registers and program counter.

| Point | Process | Thread |
|---|---|---|
| Address space | Separate | Shared |
| Creation and switching | Costly | Cheap |
| Communication | IPC needed | Shared memory |
| Isolation | Strong | None |

#### Checkpoint in recovery
A **checkpoint** is a saved snapshot of the state of a process (or of the whole distributed application) on stable storage, taken periodically. If a failure occurs, the process is restarted from the latest checkpoint (**rollback recovery**) rather than from the beginning, so only the work since the checkpoint is lost. In a distributed system the checkpoints of processes must form a **consistent global state** (a *recovery line*, with no message received but not sent). Otherwise a rollback of one process forces others to roll back too (**domino effect**). Coordinated checkpointing or message logging avoids this.

#### Distributed commit
**Distributed commit** is the problem of making all the processes taking part in a distributed transaction or operation either all commit (make the changes permanent) or all abort, so that atomicity is kept. The usual solution is the **two-phase commit (2PC)** protocol: in phase 1 the coordinator asks all participants to vote (*prepare*); if all vote yes, in phase 2 the coordinator tells all to *commit*, otherwise to *abort*. Three-phase commit reduces blocking.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which resources do threads of the same process NOT share?
   A. Address space
   B. Open files
   C. Stack and registers
   D. Global data
   Answer: C. Each thread has its own stack, registers and program counter, while address space, data and open files are shared. (Key point: Thread vs process)

2. Why does a checkpoint help recovery after a failure?
   A. The process restarts from the latest saved state, so only work since then is lost
   B. It prevents failures from happening
   C. It removes the need for stable storage
   D. It lets the process skip the failed step
   Answer: A. A checkpoint is a snapshot on stable storage; rollback restarts from it instead of from the beginning. (Key point: Checkpoint recovery)

3. What can happen if the checkpoints of different processes do not form a consistent global state?
   A. Messages are lost permanently
   B. Rolling back one process forces others to roll back too (domino effect)
   C. The coordinator aborts the transaction
   D. Threads start sharing stacks
   Answer: B. An inconsistent recovery line (message received but not sent) causes cascading rollbacks called the domino effect. (Key point: Domino effect)

4. In two-phase commit, what does the coordinator do in phase 2 if every participant voted yes?
   A. Asks them to vote again
   B. Tells all to abort
   C. Tells all to commit
   D. Waits for a timeout and aborts
   Answer: C. Phase 1 collects votes; if all vote yes, phase 2 sends commit to all, otherwise abort, keeping atomicity. (Key point: Two-phase commit)

## Related in Distributed System

- [Process vs threads; importance in DS](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aprocess-vs-thread) — Distributed System, chapter 3, asked 3×
- [Distributed deadlock; two-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-deadlock-2pc) — Distributed System, chapter 8
- [Short note: Distributed commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-commit-note) — Distributed System, chapter 8
- [Distributed deadlock and recovery](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-deadlock-note) — Distributed System, chapter 8, asked 3×
- [Short note: Two-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Atwo-phase-commit-note) — Distributed System, chapter 8, asked 2×
- [Short note: Three-phase commit](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Athree-phase-commit-note) — Distributed System, chapter 8

## Related in other subjects

- [Process vs thread; user and kernel threads](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aprocess-vs-thread-user-kernel-threads) — Operating System, chapter 2
- [Data analytics process and distributed computing](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Adata-analytics-distributed-role) — Big Data Technologies, chapter 1
- [Recovery from log: deferred vs immediate](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Alog-recovery-deferred-immediate) — Database Management System, chapter 8
- [Power diode V-I and reverse recovery](https://www.bctengineer.com/question.md?key=semester_7%2Fpower_electronics%3Apower-diode-vi-reverse-recovery) — Power Electronics, chapter 1
