How do we know what priority of the Init task is?
Joel Sherrill
joel at rtems.org
Tue Feb 23 14:17:01 UTC 2021
On Tue, Feb 23, 2021 at 4:25 AM Heinz Junkes <junkes at fhi-berlin.mpg.de>
wrote:
> what I have just never understood
>
> POSIX Prio 2 ist LOW Priority
> RTEMS Prio 1 is HIGH Priority
>
In general, RTOS threading APIs tended to use 1 as a high priority. The
RTEMS
Classic API based on pSOS+, VxWorks, and VRTX32 which preceded all those
all follow 1 is high priority model.
POSIX calls for the opposite range. Not sure why. Interestingly, I had a
discussion
with the main kernel person for another RTOS about this in a standards
meeting
and he noted that although every implementation of POSIX threads we both
knew
about does use low number as low priority, it is not as explicit in the
POSIX standard
as one would think. We have just all read the same text that way since
POSIX is
careful to say raises or lowers priority and the implication we all saw is
that the
numbers follow that languge. But at this point, the priorities run this way
for no
other reason than history and compatibility. For all I know, it may even be
baked
into the POSIX Compliance Test Suite. Any program with hard-coded numbers
certainly has it baked in.
While I am beating this topic mercilessly, let me point out that POSIX only
calls
for a minimum of 32 priority levels. Portable programs cannot assume more.
And the default attribute set for all POSIX threading and synchronization
objects is implementation defined. Portable programs should always
explicitly
set all attributes for pthreads, mutexes, etc.
The RTOS choice probably reflects using a bitmap to represent if a thread
is present on the FIFO for each priority. This would make a bit index map
directly to priority in most cases. This design dates back to at least VMS
where you have 32 priority levels because you could scan 32 bits in a
single instruction. This was carried forward into Windows NT.
THe diversity of choices reminded me of this quote from Andrew Tanenbaum:
"The nice thing about standards is that there are so many of them to choose
from."
In the end different people had an arbitrary decision and picked different
answers. Ada task priority is another set of choices. :)
--joel
> Heinz
>
>
> > On 23. Feb 2021, at 09:17, Sebastian Huber <
> sebastian.huber at embedded-brains.de> wrote:
> >
> > On 23/02/2021 08:36, Heinz Junkes wrote:
> >
> >> I would have a similar question ;-)
> >>
> >> What is the priority of the POSIX_Init - Task (as Posix-Prio)?
> > There is no option to configure the priority of the POSIX initialization
> thread, so the default priority of 2 is used, see
> _POSIX_Threads_Default_attributes.
> >
> > --
> > embedded brains GmbH
> > Herr Sebastian HUBER
> > Dornierstr. 4
> > 82178 Puchheim
> > Germany
> > email: sebastian.huber at embedded-brains.de
> > phone: +49-89-18 94 741 - 16
> > fax: +49-89-18 94 741 - 08
> >
> > Registergericht: Amtsgericht München
> > Registernummer: HRB 157899
> > Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> > Unsere Datenschutzerklärung finden Sie hier:
> > https://embedded-brains.de/datenschutzerklaerung/
> >
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210223/da8807b3/attachment.html>
More information about the devel
mailing list