Introduction
The information here is a simplification of information from
the video
threading vs multiprocessing in python
(YouTube). Essentially it is notes taken from the video.
Please watch the video. It is excellent and contains
very important and useful information. (It is 23 minutes long.)
Words of wisdom: Python is multi-threaded but is not
simultaneously multi-threaded. Only one thread is executing at a time.
Processes
What is a process?
- a process is an instance of a program
- a process has at least one thread (the program)
- a process can spawn threads
- the OS determines when and how long a thread will execute
- processes have their own data spaces
- a process have no direct access to other processes data space
- to share data, processes use queues or pipes
(or shared memory)
Threads
What is a thread?
- a thread is the smallest sequence of instructions managed by the OS
- a thread has registers associated with when it is executing code
- a thread have direct access to the processes data space
- each thread has its own stack1
1
Registers, Stacks, and Threads