Brendan Ang

Search

Search IconIcon to open search

Threads

Last updated Nov 8, 2022 Edit Source

# Threads

A thread (or lightweight process) consists of its own thread id, program counter, registers and stack space. However it shares the same data and code as the parent process.

Multithreading: A process can have multiple threads: this allows efficient sharing of memory for the program without having to create additional processes which has high overhead. This is because thread creation is primarily done via APIs and not system calls. ^7d353c

# Implementation models

Want to support an arbitrary number of threads but the OS can only support a limited number due to physical constraints

Logical (user) threads: Created in user space and allows users to create as many threads as they want Kernel threads (physical): Created in kernel space and slower to create and manage than user threads; Resources are eventually allocated in kernel threads

Ways to map logical to physical:

# Practice Problems

Explain the difference between a single-threaded and a multi-threaded process.