Commit aa47b162 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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.
parent 33c8a14f
......@@ -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 */
......
......@@ -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, &param);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment