Thread: Difference between revisions

From Rice Wiki
No edit summary
No edit summary
 
Line 7: Line 7:


Each thread will also have its own stack, which is thus called '''thread-local storage'''. The address space diagram shows that not all stacks can grow indefinitely and may run into problems if there are lots of recursion.
Each thread will also have its own stack, which is thus called '''thread-local storage'''. The address space diagram shows that not all stacks can grow indefinitely and may run into problems if there are lots of recursion.
== Motivation ==
The first motivation for threads is '''parallelizing operations''' to multiple processors, which may speed up certain operations such as array calculations significantly.
The second motivation is to avoid progress being blocked by I/O such as disk read/writes.
== Downsides ==
[[Category:Operating System]]
[[Category:Operating System]]

Latest revision as of 19:28, 7 October 2024

Credits to OSTEP textbook

A thread in Computer Science is defined as a sequence of executing instructions from a program. Notably, it is active/running. It is different from a process in that multiple threads can share an address space.

The state of a thread consists of the Program Counter and the set of register values.

A thread control block (TCB) stores the states of threads to enable switching between them.

Each thread will also have its own stack, which is thus called thread-local storage. The address space diagram shows that not all stacks can grow indefinitely and may run into problems if there are lots of recursion.

Motivation

The first motivation for threads is parallelizing operations to multiple processors, which may speed up certain operations such as array calculations significantly.

The second motivation is to avoid progress being blocked by I/O such as disk read/writes.

Downsides