1.

Define GIL.

Answer»

GIL stands for Global Interpreter Lock. This is a mutex used for limiting access to python objects and AIDS in effective thread synchronization by avoiding deadlocks. GIL helps in achieving multitasking (and not parallel computing). The following DIAGRAM represents how GIL works.

Based on the above diagram, there are three THREADS. FIRST Thread acquires the GIL first and starts the I/O execution. When the I/O operations are done, thread 1 releases the acquired GIL which is then taken up by the second thread. The process REPEATS and the GIL are used by different threads alternatively until the threads have completed their execution. The threads not having the GIL lock goes into the waiting state and resumes execution only when it acquires the lock.



Discussion

No Comment Found