POSIX Message Queue Priority Scheduling

From: Jonathan Haws
Date: Thu Oct 26 2017 - 15:59:11 EST


Can someone explain to me how message queues handle waking multiple
threads blocked on a single message queue?

My situation is I have multiple writers blocking on a full message
queue, each posting messages with priority equal to the thread
priority. I want to make sure they wake and post in priority order,
however my application is behaving as if they are waking in FIFO order
(i.e. the order in which they blocked). Each blocking thread is
scheduled with the SCHED_FIFO policy with a different priority with
system level scope.

I've searched the Internet high and low for something describing how
this should work and all I can find is POSIX man pages describing that
multiple blockers wake in priority order **if Priority Scheduling is
supported**. Since the kernel scheduler is a priority scheduler I
would think that the threads would wake in priority order and post to
the queue, however that doesn't appear to be the case. I'm sure I'm
just missing some subtle detail and was hoping the experts here on
this list can help shine some light on what I'm seeing, since its at
the kernel level that these threads are made ready to run.

I have a small test application that I can post here if necessary. If
this isn't the right place to ask this, by all means let me know and
direct me to the right forum.

Thanks!
Jon

--
Jonathan R. Haws
hawsjr@xxxxxxxxx