Posts

Showing posts with the label gil

What is GIL (Global Interpreter Lock) in python?

Mutex : A mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a mutex is created with a unique name. GIL ( Global Interpreter Lock ) : A global interpreter lock (GIL) is a mechanism used in computer language interpreters to synchronize the execution of threads so that only one native thread can execute at a time. An interpreter that uses GIL always allows exactly one thread to execute at a time, even if run on a multi-core processor. C Python has a gil. GIL is a mutex that prevents multiple native threads from executing Python byte-codes at once. This lock is necessary because C Python's memory management is not thread-safe. The GIL is controversial because it prevents multi-threaded C Python programs from taking full advantage of multiprocessor systems in certain situations.