Global Interpreter Lock

Global Interpreter Lock

Global Interpreter Lock (abbr. GIL) is a mutual exclusion lock held by a programming language interpreter thread to avoid sharing code that is not thread-safe with other threads. There is always one GIL for one interpreter process.

Usage of a Global Interpreter Lock in a language effectively limits concurrency of a single interpreter process with multiple threads -- there is no or very little increase in speed when running the process on a multiprocessor machine.

The reasons of employing such a lock include:
* increased speed of single-threaded programs (no necessity to acquire or release locks on all data structures separately)
* easy integration of C libraries that usually are not thread-safe.

Applications written in languages with a GIL have to use separate processes (i.e. interpreters) to achieve full concurrency, as each interpreter has its own GIL.

Languages that implement a Global Interpreter Lock are, among others:
* Python (precisely, its C implementation, CPython [cite web
url=http://www.ddj.com/linux-open-source/206103078?pgno=2
title= Concurrency and Python
publisher=Dr. Dobb's Journal
quote="The GIL is a lock that is used to protect all the critical sections in Python. Hence, even if you have multiple CPUs, only one thread may be doing "pythony" things at a time."
date=2008-02-03
accessdate=2008-07-12
] [ [http://docs.python.org/api/threads.html Python/C API Reference Manual: Thread State and the Global Interpreter Lock] ] )
* Ruby (where it is called Global VM Lock).

References

See also

* Green threads


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • CPython — Not to be confused with Cython. CPython Developer(s) Python core developers and the Python community Stable release 3.2 / February 20, 2011; …   Wikipedia

  • Thread (computer science) — This article is about the concurrency concept. For the multithreading in hardware, see Multithreading (computer architecture). For the form of code consisting entirely of subroutine calls, see Threaded code. For other uses, see Thread… …   Wikipedia

  • Python (Programmiersprache) — Python Basisdaten Paradigmen: multiparadigmatisch Erscheinungsjahr: 1991 …   Deutsch Wikipedia

  • Ruby (Programmiersprache) — Ruby Offizielles Logo Basisdaten Paradigmen: multiparadigmatisch Erscheinungsjahr: 1995 …   Deutsch Wikipedia

  • Green threads — In computer programming, Green threads are threads that are scheduled by a Virtual Machine (VM) instead of natively by the underlying operating system. Green threads emulate multithreaded environments without relying on any native OS capabilities …   Wikipedia

  • CPython — Système d exploitation Multiplate forme CPython est l implémentation de référence du langage …   Wikipédia en Français

  • reentrant — 1. adjective a) Reentering; to point inward. The global interpreter lock of the embedded scripting engine is not re entrant. b) that the corresponding lock can be reacquired by the locking thread. Global variables must not be altered by reentrant …   Wiktionary

  • Gil — Gil, or GIL may refer to:Places* Gil Island, one of several islands by that name * Gil, Azerbaijan, places named Gil in AzerbaijanPeople;Given name * Gil, an abbreviated form of the name Gilbert. ** Gil (Hebrew: גיל Gil , joy or age ), common… …   Wikipedia

  • Python — У этого термина существуют и другие значения, см. Python (значения). Python Класс языка: му …   Википедия

  • PyPy — Тип Интерпретатор и компилятор Python Написана на Python Операционная система Кроссплатформенный Последняя версия 1.9 (8 июня 201 …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”