Opened 8 years ago

Closed 8 years ago

#13299 closed bug (fixed)

pthread_setschedparam should return 0 on success (easy)

Reported by: korli Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

set_thread_priority() returns the previous priority on success, our implementation of pthread_setschedparam() returns this value on success instead of zero.

http://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/pthread/pthread.cpp#n294 http://cgit.haiku-os.org/haiku/tree/src/system/kernel/scheduler/scheduler.cpp#n216

Reference: excerpt from http://minisoc.xyz/HaikuMono/

diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
index 99206e6..ef1077c 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -642,7 +642,13 @@ mono_thread_internal_set_priority (MonoInternalThread *internal, MonoThreadPrior
 	}
 
 	res = pthread_setschedparam (tid, policy, &param);
+#if defined(__HAIKU__)
+	/* On Haiku, pthread_setschedparam returns a positive number on success,
+           which is the priority, or a negative number, which is the errno. */
+	if (res < 0) {
+#else
 	if (res != 0) {
+#endif
 		if (res == EPERM) {
 			g_warning ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
 			return;
On Haiku, pthread_setschedparam returns a positive number that represents the priority - this is different than most OSes.

Change History (1)

comment:1 by korli, 8 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev50954.

Note: See TracTickets for help on using tickets.