[vlc-devel] commit: Rescale POSIX realtime priorities within a portable range ( Rémi Denis-Courmont )
git version control
git at videolan.org
Fri Jun 6 16:47:03 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Fri Jun 6 17:48:48 2008 +0300| [aa47b1621816c96eff4d6c7edb7b4859192013a4]
Rescale POSIX realtime priorities within a portable range
POSIX warrants at least 32 priorities from
sched_get_priority_min(SCHED_RR) to sched_get_priority_max(SCHED_RR).
We were previously relying on 41 priorities, from 0 to 40.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa47b1621816c96eff4d6c7edb7b4859192013a4
---
include/vlc_threads.h | 12 ++++++------
src/misc/threads.c | 8 ++++++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 3a04143..9cd0940 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -78,12 +78,12 @@
# define VLC_THREAD_PRIORITY_HIGHEST 15
#elif defined(LIBVLC_USE_PTHREAD)
-# define VLC_THREAD_PRIORITY_LOW 0
-# define VLC_THREAD_PRIORITY_INPUT 20
-# define VLC_THREAD_PRIORITY_AUDIO 10
-# define VLC_THREAD_PRIORITY_VIDEO 0
-# define VLC_THREAD_PRIORITY_OUTPUT 30
-# define VLC_THREAD_PRIORITY_HIGHEST 40
+# define VLC_THREAD_PRIORITY_LOW 0
+# define VLC_THREAD_PRIORITY_INPUT 10
+# define VLC_THREAD_PRIORITY_AUDIO 5
+# define VLC_THREAD_PRIORITY_VIDEO 0
+# define VLC_THREAD_PRIORITY_OUTPUT 15
+# define VLC_THREAD_PRIORITY_HIGHEST 20
#elif defined(WIN32) || defined(UNDER_CE)
/* Define different priorities for WinNT/2K/XP and Win9x/Me */
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 11b3d47..90c6029 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -48,6 +48,8 @@
static volatile unsigned i_initializations = 0;
#if defined( LIBVLC_USE_PTHREAD )
+# include <sched.h>
+
static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
@@ -520,8 +522,10 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
else
{
- struct sched_param param = { .sched_priority = +i_priority, };
- pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
+ struct sched_param param = { .sched_priority = i_priority, };
+
+ param.sched_priority += sched_get_priority_min (SCHED_RR);
+ pthread_attr_setschedpolicy (&attr, SCHED_RR);
pthread_attr_setschedparam (&attr, ¶m);
}
}
More information about the vlc-devel
mailing list