summaryrefslogtreecommitdiffstats
path: root/Python/thread_pthread.h
Commit message (Collapse)AuthorAgeFilesLines
* gh-110850: Remove _PyTime_TimeUnchecked() function (#118552)Victor Stinner2024-05-051-5/+13
| | | | | | | | | | | | | Use the new public Raw functions: * _PyTime_PerfCounterUnchecked() with PyTime_PerfCounterRaw() * _PyTime_TimeUnchecked() with PyTime_TimeRaw() * _PyTime_MonotonicUnchecked() with PyTime_MonotonicRaw() Remove internal functions: * _PyTime_PerfCounterUnchecked() * _PyTime_TimeUnchecked() * _PyTime_MonotonicUnchecked()
* gh-112536: Add TSAN builds on Github Actions (#116872)Donghee Na2024-03-161-0/+4
|
* gh-110850: Cleanup PyTime API: PyTime_t are nanoseconds (#115753)Victor Stinner2024-02-211-1/+1
| | | | | | | | | | PyTime_t no longer uses an arbitrary unit, it's always a number of nanoseconds (64-bit signed integer). * Rename _PyTime_FromNanosecondsObject() to _PyTime_FromLong(). * Rename _PyTime_AsNanosecondsObject() to _PyTime_AsLong(). * Remove pytime_from_nanoseconds(). * Remove pytime_as_nanoseconds(). * Remove _PyTime_FromNanoseconds().
* gh-110850: Replace private _PyTime_MAX with public PyTime_MAX (#115751)Victor Stinner2024-02-211-2/+2
| | | | | | | Remove references to the old names _PyTime_MIN and _PyTime_MAX, now that PyTime_MIN and PyTime_MAX are public. Replace also _PyTime_MIN with PyTime_MIN.
* gh-110850: Rename internal PyTime C API functions (#115734)Victor Stinner2024-02-201-4/+4
| | | | | | | | | | | | | | | | | Rename functions: * _PyTime_GetSystemClock() => _PyTime_TimeUnchecked() * _PyTime_GetPerfCounter() => _PyTime_PerfCounterUnchecked() * _PyTime_GetMonotonicClock() => _PyTime_MonotonicUnchecked() * _PyTime_GetSystemClockWithInfo() => _PyTime_TimeWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() Changes: * Remove "typedef PyTime_t PyTime_t;" which was "typedef PyTime_t _PyTime_t;" before a previous rename. * Update comments of "Unchecked" functions. * Remove invalid PyTime_Time() comment.
* gh-110850: Cleanup pycore_time.h includes (#115724)Victor Stinner2024-02-201-0/+1
| | | | | <pycore_time.h> include is no longer needed to get the PyTime_t type in internal header files. This type is now provided by <Python.h> include. Add <pycore_time.h> includes to C files instead.
* gh-110850: Replace _PyTime_t with PyTime_t (#115719)Victor Stinner2024-02-201-6/+6
| | | | | Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
* gh-115035: Mark ThreadHandles as non-joinable earlier after forking (#115042)Sam Gross2024-02-061-10/+0
| | | | | | This marks dead ThreadHandles as non-joinable earlier in `PyOS_AfterFork_Child()` before we execute any Python code. The handles are stored in a global linked list in `_PyRuntimeState` because `fork()` affects the entire process.
* gh-81925: Implement native thread ids for kFreeBSD (#111761)Samuel Thibault2023-11-091-0/+5
| | | | | --------- Co-authored-by: Antoine Pitrou <antoine@python.org>
* GH-110829: Ensure Thread.join() joins the OS thread (#110848)Antoine Pitrou2023-11-041-11/+60
| | | | | | | Joining a thread now ensures the underlying OS thread has exited. This is required for safer fork() in multi-threaded processes. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-109693: Remove pycore_atomic.h (gh-110992)Donghee Na2023-10-171-1/+0
|
* gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)Donghee Na2023-10-161-0/+1
|
* gh-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)Victor Stinner2023-09-301-4/+5
| | | | | | | | | | | | | | | | * pycore_pythread.h is now the central place to make sure that _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if available. * Make sure that pycore_pythread.h is included when _POSIX_THREADS and _POSIX_SEMAPHORES macros are tested. * PY_TIMEOUT_MAX is now defined as a constant, since its value depends on _POSIX_THREADS, instead of being defined as a macro. * Prevent integer overflow in the preprocessor when computing PY_TIMEOUT_MAX_VALUE on Windows: replace "0xFFFFFFFELL * 1000 < LLONG_MAX" with "0xFFFFFFFELL < LLONG_MAX / 1000". * Document the change and give hints how to fix affected code. * Add an exception for PY_TIMEOUT_MAX name to smelly.py * Add PY_TIMEOUT_MAX to the stable ABI
* gh-101538: Add experimental wasi-threads build (#101537)YAMAMOTO Takashi2023-06-221-0/+8
| | | | Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-81057: Fix the wasm32-wasi Buildbot (gh-100139)Eric Snow2022-12-091-1/+2
| | | | | The build was broken by gh-100084. https://github.com/python/cpython/issues/81057
* gh-81057: Move Threading-Related Globals to _PyRuntimeState (#100084)Eric Snow2022-12-091-11/+13
| | | https://github.com/python/cpython/issues/81057
* gh-95174: Add pthread stubs for WASI (GH-95234)Christian Heimes2022-07-271-1/+3
| | | Co-authored-by: Brett Cannon <brett@python.org>
* gh-74953: _PyThread_cond_after() uses _PyTime_t (#94056)Victor Stinner2022-06-211-26/+13
| | | | | | pthread _PyThread_cond_after() implementation now uses the _PyTime_t type to handle properly overflow: clamp to the maximum value. Remove MICROSECONDS_TO_TIMESPEC() function.
* gh-74953: Reformat PyThread_acquire_lock_timed() (#93947)Victor Stinner2022-06-191-46/+62
| | | | | | | | Reformat the pthread implementation of PyThread_acquire_lock_timed() using a mutex and a conditioinal variable. * Add goto to avoid multiple indentation levels and exit quickly * Use "while(1)" and make the control flow more obvious. * PEP 7: Add braces around if blocks.
* gh-74953: Fix PyThread_acquire_lock_timed() code recomputing the timeout ↵Victor Stinner2022-06-171-1/+1
| | | | | (#93941) Set timeout, don't create a local variable with the same name.
* gh-74953: Add _PyTime_FromMicrosecondsClamp() function (#93942)Victor Stinner2022-06-171-16/+9
|
* bpo-42047: Add native thread ID for DragonFlyBSD (#22714)David CARLIER2022-05-181-0/+5
| | | | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)Gregory P. Smith2022-05-091-19/+0
| | | | Remove the `PYTHONTHREADDEBUG` env var support. Remove no-op dprintf() macro calls.
* bpo-46008: Move thread-related interpreter state into a sub-struct. (gh-29971)Eric Snow2021-12-071-4/+4
| | | | | This parallels _PyRuntimeState.interpreters. Doing this helps make it more clear what part of PyInterpreterState relates to its threads. https://bugs.python.org/issue46008
* bpo-41710: Add private _PyDeadline_Get() function (GH-28674)Victor Stinner2021-10-011-10/+8
| | | | | | | | Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
* bpo-41710: PyThread_acquire_lock_timed() uses sem_clockwait() (GH-28662)Victor Stinner2021-10-011-6/+33
| | | | | | | | | On Unix, if the sem_clockwait() function is available in the C library (glibc 2.30 and newer), the threading.Lock.acquire() method now uses the monotonic clock (time.CLOCK_MONOTONIC) for the timeout, rather than using the system clock (time.CLOCK_REALTIME), to not be affected by system clock changes. configure now checks if the sem_clockwait() function is available.
* bpo-41710: PyThread_acquire_lock_timed() clamps the timout (GH-28643)Victor Stinner2021-09-301-29/+34
| | | | | | | | | | | | | | | | | | | PyThread_acquire_lock_timed() now clamps the timeout into the [_PyTime_MIN; _PyTime_MAX] range (_PyTime_t type) if it is too large, rather than calling Py_FatalError() which aborts the process. PyThread_acquire_lock_timed() no longer uses MICROSECONDS_TO_TIMESPEC() to compute sem_timedwait() argument, but _PyTime_GetSystemClock() and _PyTime_AsTimespec_truncate(). Fix _thread.TIMEOUT_MAX value on Windows: the maximum timeout is 0x7FFFFFFF milliseconds (around 24.9 days), not 0xFFFFFFFF milliseconds (around 49.7 days). Set PY_TIMEOUT_MAX to 0x7FFFFFFF milliseconds, rather than 0xFFFFFFFF milliseconds. Fix PY_TIMEOUT_MAX overflow test: replace (us >= PY_TIMEOUT_MAX) with (us > PY_TIMEOUT_MAX).
* bpo-41710: Add _PyTime_AsTimespec_clamp() (GH-28629)Victor Stinner2021-09-301-5/+1
| | | | | | | | | | | | | | | Add the _PyTime_AsTimespec_clamp() function: similar to _PyTime_AsTimespec(), but clamp to _PyTime_t min/max and don't raise an exception. PyThread_acquire_lock_timed() now uses _PyTime_AsTimespec_clamp() to remove the Py_UNREACHABLE() code path. * Add _PyTime_AsTime_t() function. * Add PY_TIME_T_MIN and PY_TIME_T_MAX constants. * Replace _PyTime_AsTimeval_noraise() with _PyTime_AsTimeval_clamp(). * Add pytime_divide_round_up() function. * Fix integer overflow in pytime_divide(). * Add pytime_divmod() function.
* bpo-34602: Quadruple stack size on macOS when compiling with UBSAN (GH-27309)Łukasz Langa2021-09-031-7/+6
|
* bpo-31904: Define THREAD_STACK_SIZE for VxWorks (GH-23718)pxinwr2020-12-091-0/+4
|
* Fix -Wstrict-prototypes warning in thread_pthread.h. (GH-21477)Benjamin Peterson2020-07-151-1/+1
|
* bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)Victor Stinner2020-04-141-2/+2
| | | | | | | Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET() for consistency with _PyThreadState_GET() and to have a shorter name (help to fit into 80 columns). Add also "assert(tstate != NULL);" to the function.
* bpo-40268: Include explicitly pycore_interp.h (GH-19505)Victor Stinner2020-04-141-0/+1
| | | | pycore_pystate.h no longer includes pycore_interp.h: it's now included explicitly in files accessing PyInterpreterState.
* bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)Victor Stinner2020-04-071-0/+20
| | | | | | | | | | | | | | | Add a private _at_fork_reinit() method to _thread.Lock, _thread.RLock, threading.RLock and threading.Condition classes: reinitialize the lock after fork in the child process; reset the lock to the unlocked state. Rename also the private _reset_internal_locks() method of threading.Event to _at_fork_reinit(). * Add _PyThread_at_fork_reinit() private function. It is excluded from the limited C API. * threading.Thread._reset_internal_locks() now calls _at_fork_reinit() on self._tstate_lock rather than creating a new Python lock object.
* Use calloc-based functions, not malloc. (GH-19152)Andy Lester2020-03-251-2/+1
|
* bpo-38852: Set thread stack size to 8 Mb for debug builds on android ↵xdegaye2019-12-081-0/+10
| | | | platforms (GH-17337)
* bpo-38068: Clean up gettimeofday configure logic. (GH-15775)Benjamin Peterson2019-09-101-8/+1
| | | Assume gettimeofday exists and takes two arguments.
* bpo-18049: Define THREAD_STACK_SIZE for AIX to pass default recursion limit ↵Michael Felt2019-08-031-0/+4
| | | | | | test (GH-15081) * Define THREAD_STACK_SIZE for AIX to pass default recursion limit test
* bpo-18049: Sync thread stack size to main thread size on macOS (GH-14748)Ronald Oussoren2019-08-011-1/+2
| | | | | | This changeset increases the default size of the stack for threads on macOS to the size of the stack of the main thread and reenables the relevant recursion test.
* bpo-37077: Add native thread ID (TID) for AIX (GH-13624)Michael Felt2019-06-131-2/+7
| | | | | | | This is the followup for issue36084 https://bugs.python.org/issue37077
* bpo-37160: Thread native ID NetBSD support (GH-13835)David Carlier2019-06-121-0/+5
|
* bpo-37087: Adding native ID support for OpenBSD (GH-13654)David Carlier2019-06-031-0/+5
|
* bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)Jake Tesler2019-05-221-0/+26
| | | | Add native thread ID (TID) to threading.Thread objects (supported platforms: Windows, FreeBSD, Linux, macOS).
* Revert "bpo-36084: Add native thread ID to threading.Thread objects ↵Victor Stinner2019-05-211-27/+0
| | | | | (GH-11993)" (GH-13458) This reverts commit 4959c33d2555b89b494c678d99be81a65ee864b0.
* bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)Jake Tesler2019-05-121-0/+27
|
* bpo-36594: Fix incorrect use of %p in format strings (GH-12769)Zackery Spytz2019-05-061-2/+2
| | | In addition, fix some other minor violations of C99.
* bpo-36475: Make PyThread_exit_thread with _Py_NO_RETURN (GH-13068)Victor Stinner2019-05-041-1/+1
|
* bpo-12822: use monotonic clock for condvar if possible (GH-11723)Inada Naoki2019-02-201-19/+62
|
* bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008)Siddhesh Poyarekar2018-11-301-4/+36
| | | | | | | Fix an undefined behaviour in the pthread implementation of PyThread_start_new_thread(): add a function wrapper to always return NULL. Add pythread_callback struct and pythread_wrapper() to thread_pthread.h.
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.