Posts

Showing posts from February, 2021

Multi-threading in Python

Process: A process is an instance of a computer program that is being executed. Any process has 3 basic components: An executable program. The associated data needed by the program (variables, work space, buffers, etc.) The execution context of the program (State of process) Thread: A thread is an entity within a process that can be scheduled for execution.  Also, it is the smallest unit of processing that can be performed in an OS. A thread is a sequence of such instructions within a program that can be executed independently of other code.  For simplicity, you can assume that a thread is simply a subset of a process! A thread contains all this information in a Thread Control Block (TCB): Thread Identifier: Unique id (TID) is assigned to every new thread Stack pointer: Points to thread’s stack in the process. Stack contains the local variables under thread’s scope. Program counter: a register which stores the address of the instruction currently being executed by thread. Thread state: