CS
]
Threads in Programs
If you have ever used a smartphone, then you have interacted with threads.
Even though we might only interact with one app at a time, there are apps that are constantly running in the background (if we don’t choose to turn off their background activity in Settings).
But what are thread exactly?
A thread is a basic unit of CPU utilization, consisting of a program counter, a stack, and a set of registers, ( and a thread ID. )
Program counter
A program counter (PC) is a CPU register in the computer processor which has the address of the next instruction to be executed from memory. It is a digital counter needed for faster execution of tasks as well as for tracking the current execution point.
A program counter is also known as an instruction counter, instruction pointer, instruction address register or sequence control register. Original Source
Stack
Stack does not have a physical representation.
Stacks in computing architectures are regions of memory where data is added or removed in a last-in-first-out (LIFO) manner. In most modern computer systems, each thread has a reserved region of memory referred to as its stack. Original Source
Register Set
A thread has its own register set and stack while sharing code and global data with other threads of the same process. Original Source