Multiprocessing and multithreading are purposed for better computing power of a system.
A system that has more than one or two processors.
CPUs are added to increase the computing the power.
There are two types of multiprocessing: symmetric multiprocessing and asymmetric multiprocessing.
A multiprocessor computer hardware & software architecture where two or more identical processors are connected to a single, shared main memory w/ full access to all input and output devices.
A type of multiprocessing where each processor is self-scheduling.
Multiprocessor computer system where NOT all of the multiple interconnected CPUs are treated equally. Only a master processor runs the tasks of the OS.
Processors are in a master-slave relationship, where only one serves as the master, responsible for assigning tasks to the slave processors.
Disadvantage: unequal load placed on processors may cause some processors to be idle while others have a huge job queue.
A system in which multiple threads are created of a process to increase the computing power.
Many threads of a process are executed simultaneously.
GIL: a mutex that protects access to Python objects & prevents multiple threads frome executing Python bytecodes at once
Because Python uses reference counting to manage memory, each object saves the number of variables that reference itself and memory release is done when the number hits 0. While this is a efficient method in terms of memory space, it is inefficient in other terms because the reference count has to be updated every time a reference is added or released and the reference count must be an atomic operation to prevent problems. To keep this operation atomic, each operation needs a lock, causing potential problems in performances and may be a dead lock.
Thus, CPython uses a lock on the interpreter and guarantees atomicity.
Since Java uses the Mark and Sweep algorithm for GC, which only operates when the memory is filled up to a certain extent, Java does not have to do atomic operations every time a reference is added or removed.
References