Threading Models in Operating Systems: Concepts, Mapping and Worked Examples

Learn how user threads map to kernel threads, why blocking behaves differently across models, and how to calculate execution capacity on four CPU cores.

KnowledgeGate Team

Exam prep & CS education

Updated 19 Nov 20265 min read
Threading Models in Operating Systems: Concepts, Mapping and Worked Examples

A process can contain several threads, but the user-thread count alone does not reveal how many can run in parallel or what happens when one blocks. Parallel execution depends on user threads, kernel threads and CPU cores, not on the user-thread count alone. Fork() creation, copy-on-write and the full process-versus-thread ownership boundary belong to Threads and Process Creation in OS: fork() Worked Examples. Mapping questions then use that boundary to calculate how M:1, 1:1 and fixed-pool M:N models limit execution before, during and after a blocking call.

Start from the process-thread distinction

A process is a running program with an address space and operating-system-managed resources. A thread is one execution path inside it, with a private program counter, register set and stack but access to shared process resources.

Thread creation or switching can avoid duplicating a whole address space, unlike fork()-based process creation. Exact costs are implementation-specific.

Two threads are concurrent when their execution overlaps in time. They are parallel only when they execute simultaneously on different cores. One core can interleave two runnable threads, creating concurrency but not physical parallelism.

Shared and private state: account for the memory once

Process P has 64 KiB of code, a 256 KiB heap, shared integer x = 10, and open file descriptor F. T1 has a 32 KiB stack and PC1 = 0x1040; T2 has a separate 32 KiB stack and PC2 = 0x2080.

State

Shared or private?

Explanation

Code, 64 KiB

Shared

Both execute process code.

Heap, 256 KiB

Shared

Both can access heap objects.

x = 10 and file F

Shared

Both are process resources.

Program counters and registers

Private

Each records one execution path.

Two 32 KiB stacks

Private

Each thread owns one stack.

In this deliberately simplified accounting, the displayed memory is:

64 + 256 + 32 + 32 = 384 KiB

This excludes page tables, control blocks, kernel stacks and other runtime metadata.

Because x and file F are shared, concurrent access needs synchronization. A mapping model changes scheduling capacity; it does not make process resources thread-private.

Cutaway process diagram shows a shared box with 64 KiB code and 256 KiB heap beside two threads with 32 KiB stacks, totaling 384 KiB.

User-level and kernel-level threads answer different questions

A user-level thread is scheduled by a user-space runtime or library. A kernel-level thread is known to and scheduled by the kernel. Implementations vary, but the distinction supports a clear textbook model.

User-space scheduling can let some operations avoid a kernel transition. Kernel-visible threads can be scheduled independently and across cores. Neither fact makes one approach universally faster.

Capacity equals the minimum of runnable user threads, unblocked kernel threads and CPU cores.

capacity = min(runnable user threads, unblocked kernel threads, CPU cores)

It gives maximum simultaneous application execution under the question's stated assumptions.

The three core threading models and the two-level variation

Model

Mapping

Possible multicore parallelism

Effect of one blocking kernel call under the stated textbook model

Main trade-off

Many-to-one

Many user threads to one kernel thread

No

Blocking the sole kernel thread stops all its user threads

Simple management, one-core ceiling

One-to-one

One kernel thread per user thread

Yes, up to other limits

Sibling threads can continue

More kernel-managed state

Many-to-many

Many user threads over a kernel-thread pool

Yes, up to pool and core limits

A blocked fixed-pool member reduces capacity

Flexible, but pool management is complex

In practice, a many-to-one runtime may use non-blocking facilities. That sits outside this textbook blocking-call calculation.

The two-level model is a many-to-many variation that permits a selected user thread to bind to one kernel thread. It is not one-to-one.

Worked example: eight user threads on four cores

The machine has four cores, C1-C4. Eight user threads, U1-U8, all have CPU work remaining.

  • M:1: all eight user threads map to K1.

  • 1:1: Ui maps to Ki, giving K1-K8.

  • Fixed-pool M:N: all user threads share K1-K3.

Then U4 begins a blocking kernel call lasting exactly 12 ms. Under M:N, it runs on K2, and no replacement kernel thread is created.

Before the block:

  • M:1 = min(8, 1, 4) = 1, limited by one kernel thread.

  • 1:1 = min(8, 8, 4) = 4, limited by four cores.

  • M:N = min(8, 3, 4) = 3, limited by three kernel threads.

During the block:

  • M:1: blocked K1 gives min(7, 0, 4) = 0.

  • 1:1: only U4/K4 is blocked, giving min(7, 7, 4) = 4.

  • M:N: blocked K2 leaves K1 and K3, giving min(7, 2, 4) = 2.

After return, the ceilings become 1, 4 and 3 again if enough work remains.

Observed state

M:1

1:1

Fixed-pool M:N

Before U4 blocks

1

4

3

During the 12 ms block

0

4

2

After U4 returns

1

4

3

The rows are 1/4/3, 0/4/2, 1/4/3. A pool that can replace a blocked member may produce a different many-to-many answer, so use the stated assumption.

Three-panel thread-mapping figure compares M:1, 1:1, and fixed-pool M:N scheduling during U4 blocking, with capacities 0, 4, and 2.

Benefits, costs and traps that change the answer

Threads can improve responsiveness, share process resources and use multiple cores when enough kernel-visible threads exist. More threads do not automatically make a program faster.

Costs include creation, scheduling, stacks, context switching, contention and harder debugging. Shared memory also requires synchronization.

Mapping controls where execution may occur. Synchronization controls whether concurrent access is correct. Process Synchronization and Semaphores develops the mutual-exclusion trace.

Common traps are confusing user and kernel threads, treating concurrency as parallelism, assuming eight threads use eight cores, generalising blocking without naming the mapping, and ignoring whether the pool is fixed.

How competitive exams test threading models

Questions may ask you to classify state, recognise a mapping, calculate simultaneous execution, reason about blocking, or compare creation overhead qualitatively.

Quick drill: 10 user threads, 3 unblocked kernel threads and 6 cores. Name the bottleneck, then calculate min(10, 3, 6) = 3. If one fixed kernel thread blocks with no replacement, capacity becomes min(9, 2, 6) = 2. Kernel threads are the bottleneck both times.

Practise mapping and blocking questions with Threads and Process Creation MCQs for GATE OS, then place the lesson within the GATE CS exam preparation subject map.

Short version and next step

  • A thread owns execution state but shares its process resources.

  • User-thread and kernel-thread counts are not necessarily equal.

  • CPU cores impose the final physical ceiling on parallel execution.

  • Blocking behaviour depends on the mapping and the stated assumptions.

Use min(runnable U, unblocked K, cores) as a reasoning aid, not a universal operating-system API guarantee. Redraw the example and recompute all three rows. Then change the fixed pool from 3 to 4 kernel threads: M:N becomes 4, 3, 4.

For a wider guided path, continue with GATE Guidance by Sanchit Sir and place this model alongside scheduling, process creation and synchronization.