[Python-checkins] r76110 - sandbox/trunk/newgil/Python/ceval_gil.h (original) (raw)
antoine.pitrou python-checkins at python.org
Wed Nov 4 22:04:05 CET 2009
- Previous message: [Python-checkins] r76109 - in sandbox/trunk/newgil: Doc/library/datetime.rst Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_util.py Lib/getpass.py Lib/lib2to3/Grammar.txt Lib/lib2to3/fixes/fix_idioms.py Lib/lib2to3/fixes/fix_map.py Lib/lib2to3/fixes/fix_tuple_params.py Lib/lib2to3/pgen2/pgen.py Lib/lib2to3/pgen2/tokenize.py Lib/lib2to3/pytree.py Lib/lib2to3/tests/test_all_fixers.py Lib/lib2to3/tests/test_fixers.py Lib/lib2to3/tests/test_parser.py Lib/mailbox.py Lib/test/support.py Lib/test/test_bytes.py Lib/test/test_itertools.py Lib/test/test_mailbox.py Lib/test/test_multibytecodec_support.py Lib/test/test_normalization.py Lib/test/test_shutil.py Lib/test/test_site.py Lib/test/test_wsgiref.py Lib/test/test_xmlrpc_net.py Misc/NEWS Modules/itertoolsmodule.c Modules/termios.c configure configure.in
- Next message: [Python-checkins] r76111 - in python/branches/py3k: Lib/test/test_kqueue.py Misc/ACKS Misc/NEWS Modules/selectmodule.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: antoine.pitrou Date: Wed Nov 4 22:04:05 2009 New Revision: 76110
Log: Document the implementation
Modified: sandbox/trunk/newgil/Python/ceval_gil.h
Modified: sandbox/trunk/newgil/Python/ceval_gil.h
--- sandbox/trunk/newgil/Python/ceval_gil.h (original) +++ sandbox/trunk/newgil/Python/ceval_gil.h Wed Nov 4 22:04:05 2009 @@ -25,6 +25,40 @@ /* #define TRACE_PRIO */
+/*
- Notes about the implementation:
- The GIL is just a boolean variable (gil_locked) whose access is protected
by a mutex, and whose changes are signalled by a condition variable. The
mutex itself is rarely taken and, therefore, mostly uncontended.
- In the GIL-holding thread, the main loop (PyEval_EvalFrameEx) must be
able to release the GIL on demand by another thread. A volatile boolean
variable (gil_drop_request) is used for that purpose, which is checked
at every turn of the eval loop.
[Actually, another volatile boolean variable (eval_breaker) is used
which aggregates several conditions into one. Volatile booleans are
ok as signalling means since Python is run on cache-coherent
architectures only.]
- A thread wanting to take the GIL will first wait for a given amount of
time before setting gil_drop_request. This amount of time defines the
ideal thread switching period. It is available for the user to read
and modify using `sys.{get,set}switchinterval()`.
- Forced thread switching when releasing the GIL is implemented. When
a thread releases the GIL and gil_drop_request is set, that thread
ensures that another GIL-awaiting thread gets scheduled. It does so
by waiting on a variable (gil_last_holder) controlled through another
{mutex, condition} pair.
- An optional policy mechanism, priority requests, is currently disabled.
The intent was to further improve the latency of some types of GIL-taking
activities, such as being woken up on a socket. If it is confirmed that
this feature is unnecessary, support code should be removed.
+/ + #ifndef _POSIX_THREADS / This means pthreads are not implemented in libc headers, hence the macro not present in unistd.h. But they still can be implemented as an external
- Previous message: [Python-checkins] r76109 - in sandbox/trunk/newgil: Doc/library/datetime.rst Lib/distutils/tests/test_build_py.py Lib/distutils/tests/test_util.py Lib/getpass.py Lib/lib2to3/Grammar.txt Lib/lib2to3/fixes/fix_idioms.py Lib/lib2to3/fixes/fix_map.py Lib/lib2to3/fixes/fix_tuple_params.py Lib/lib2to3/pgen2/pgen.py Lib/lib2to3/pgen2/tokenize.py Lib/lib2to3/pytree.py Lib/lib2to3/tests/test_all_fixers.py Lib/lib2to3/tests/test_fixers.py Lib/lib2to3/tests/test_parser.py Lib/mailbox.py Lib/test/support.py Lib/test/test_bytes.py Lib/test/test_itertools.py Lib/test/test_mailbox.py Lib/test/test_multibytecodec_support.py Lib/test/test_normalization.py Lib/test/test_shutil.py Lib/test/test_site.py Lib/test/test_wsgiref.py Lib/test/test_xmlrpc_net.py Misc/NEWS Modules/itertoolsmodule.c Modules/termios.c configure configure.in
- Next message: [Python-checkins] r76111 - in python/branches/py3k: Lib/test/test_kqueue.py Misc/ACKS Misc/NEWS Modules/selectmodule.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]