src/core/linux/SDL_threadprio.c


Log

Author Commit Date CI Message
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Frank Praznik b72cf207 2022-08-14T09:41:42 core: linux: Don't cache the RealtimeKit D-Bus connection If the D-Bus subsystem is shutdown and restarted mid-execution, the cached connection will be invalid. Fetch it each time that it is used to ensure that the connection is always from the current context.
Frank Praznik 22f25b03 2022-07-24T13:22:39 core: linux: Favor xdg-desktop-portal for elevating thread priority Use the xdg-desktop-portal interface to RealtimeKit1, when available, to set realtime scheduling and elevated priority for threads. This portal allows for the use of rtkit within containers such as Flatpak. It will fall back to using RealtimeKit1 directly if the xdg-desktop-portal interface is too old or not available.
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sylvain dd6817b3 2021-11-23T10:47:34 Fix warnings: static function, {} initializier, un-needed enum forward declaration
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Ozkan Sezer 15cbddf4 2020-12-13T18:00:20 linux/SDL_threadprio.c: fix build on older systems: SCHED_RESET_ON_FORK is in kernel >= 2.6.32.
Sam Lantinga 07eae7d6 2020-11-11T08:47:18 Fix process randomly getting killed when SDL_THREAD_PRIORITY_HIGH/TIME_CRITICAL is set When we request realtime priority from rtkit, we have a rttime limit. If we exceed that limit, the kernel will send SIGKILL to the process to terminate it. This isn't something that most high priority processes will want, only processes that selectively opt into SCHED_RR/FIFO through SDL_HINT_THREAD_PRIORITY_POLICY should be subject to this level of scrutiny. This change: * Switches non-apple posix OSs to use SCHED_OTHER instead of SCHED_RR for SDL_THREAD_PRIORITY_HIGH/SDL_THREAD_PRIORITY_TIME_CRITICAL. * Fixes using a hardcoded RLIMIT_RTTIME, instead queries it from rtkit * Only sets RLIMIT_RTTIME for MakeRealtime rtkit requests * Adds a note regarding the possible SIGKILL with SDL_HINT_THREAD_PRIORITY_POLICY * Introduces SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow apps to acquire realtime scheduling policies on Linux
Sam Lantinga 94924f01 2020-11-09T10:11:55 Fix failing to set high priority for threads on Linux desktop. Debugging inside rtkit showed we were failing the RLIMIT_RTTIME check, now that we're asking for realtime and not just high-priority due to a change in SDL. Between that and the DBus code in SDL being wrong in previous changelist I'm not sure how this could have ever worked.
Sam Lantinga abf9dfd5 2020-11-09T10:11:38 Fix MakeThreadRealtime DBus method call on Linux, type mismatch due to copy paste. Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32" Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32" Docs: http://git.0pointer.net/rtkit.git/tree/README CLIENTS: To be able to make use of realtime scheduling clients may request so with a small D-Bus interface that is accessible on the interface org.freedesktop.RealtimeKit1 as object /org/freedesktop/RealtimeKit1 on the service org.freedesktop.RealtimeKit1: void MakeThreadRealtime(u64 thread_id, u32 priority); void MakeThreadHighPriority(u64 thread_id, s32 priority);
Ozkan Sezer 4ba0a847 2020-06-22T23:24:02 core/linux/SDL_threadprio.c: fix build against older glibc versions
Sam Lantinga cced5eb9 2020-06-04T09:23:18 Fixed bug 5169 - Can not build current sources because of recent thread management changes Manuel Alfayate Corchete I'm trying to build SDL2 with threads support here in GNU/Linux, both X86 and ARM, and it does not seem to be possible ATM: /home/manuel/src/SDLLLL/src/core/linux/SDL_threadprio.c:233:26: error: 'rtkit_max_realtime_priority' undeclared (first use in this function)
Sam Lantinga cc2fe84d 2020-05-26T13:19:48 Getting closer.
Sam Lantinga 0713c579 2020-05-26T13:19:44 More Linux fixes.
Sam Lantinga abd58418 2020-05-26T13:19:19 Make some changes to SDL_SetThreadPriority to try and have SDL transparently handle more of the work. 1. Comment that SDL_SetThreadPriority will make any necessary system changes when applying priority. 2. Add a hint to override SDL's default behavior for scheduler policy. 3. Modify the pthreads SDL_SetThreadPriority so that instead of just using the current thread scheduler policy it will change it to a policy that should work best for the requested priority. 4. Add hint checks in SDL_SetThreadPriority so that #3 can be overridden if desired. 5. Modify the Linux SDL_SetThreadPriority so that in the case that policy, either by SDL defaults or from the hint, is a realtime policy it uses the realtime rtkit API. 6. Prior to calling rtkit on Linux make the necessary thread state changes that rtkit requires. Currently this is done every time as it isn't expected that SDL_SetThreadPriority will be called repeatedly for a thread.
Sam Lantinga ba95fa61 2020-04-08T08:42:09 Revert "Fix incorrectly terminated MakeThreadHighPriority dbus message" The first terminator is for input parameters. The second terminator was for the output parameters. If an error occurs when calling MakeThreadHighPriority(), e.g. a bad thread id, then the reply from connection_send_with_reply_and_block() will be null.
Sam Lantinga 2e667a8b 2020-03-30T14:26:10 Fix incorrectly terminated MakeThreadHighPriority dbus message Currently the message is double terminated, which results in SDL_DBus_CallMethodInternal() incorrectly assuming that the other party is always returning true. I'm not super familiar with dbus, so I'm not sure if this could also be the cause of this bug: https://github.com/ValveSoftware/steam-for-linux/issues/6901
Fabrice Fontaine cbc65ce8 2020-02-10T13:56:53 src/core/linux/SDL_threadprio.c: fix build without threads Add an include on SDL_error.h to avoid the following build failure without threads: /home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabihf/8.3.0/../../../../arm-buildroot-linux-uclibcgnueabihf/bin/ld: build/.libs/SDL_threadprio.o: in function `SDL_LinuxSetThreadPriority_REAL': SDL_threadprio.c:(.text+0x0): undefined reference to `SDL_Unsupported' Fixes: - http://autobuild.buildroot.org/results/7f7712c5bd47de4a3fcec1e0d0526fd5a3ecd532 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 191fe25b 2019-09-27T15:21:31 Fixed rtkit feature guard
Sam Lantinga 84dc44e2 2019-09-27T15:21:27 Fix the RealtimeKit dbus include guards The SDL_USE_LIBDBUS define is set inside SDL_debug.h, therefore the circular dependency made it impossible for this feature to be enabled. Instead, guard SDL_dbus.h based on the autoconf variable HAVE_DBUS_DBUS_H Additionally, fix one of the rtkit comments. CAP_SYS_NICE isn't required to achieve high priority. But there is some scheduler config that rtkit needs the app to setup.
Sam Lantinga 93a5e4ce 2019-06-17T08:38:33 Fixed bug 4667 - Build errors on Linux when building without Threads support Manuel Sabogal There is an issue on the latest commit of the mercurial repo when SDL_THREADS_DISABLED is set: src/core/linux/SDL_threadprio.c:79:28: error: unknown type name 'Sint64'; did you mean 'int'
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Ryan C. Gordon c7b71371 2018-12-05T17:53:38 Whoops, forgot to add a new source file. :/