core: same SCHED_PRIO_LEVELS for 16 and 32 bit code
Using a different value for SCHED_PRIO_LEVELS for 16 and 32 bit platforms hurts portability, one thing that we heavily advertise about RIOT. if you want to write a portable application, then you have to assume the lower value.
I would set SCHED_PRIO_LEVELS==16 for every board.
Sounds like a good idea to me.
Yes, we probably should have one unique value for SCHED_PRIO_LEVELS for consistency and simplicity. However, why do we need to stick with the lower value? We could set it to 32 for everyone; or is there a reason not to have more priority levels than there are bits in a GPR?
priority inside tcb_t as defined in core/include/tcb.h is a uint16_t and as far as I can tell every use of a inside the main tree is a number (in contrast to a bitmask), in many cases relative to PRIORITY_MAIN. Therefore I'd second the opinion of @rousselk and just use 32 priorities independent of the size of a register on a specific platform.
When would you need such a fine priority scaling?
MAXTHREADS is statically set to 32. A programming logic needs refactoring, if every thread needs its own priority level.
The big Linux has 40 priority levels, where only 20 are meant for the average user. With its "restricted" scale of priority levels, Linux currently runs 722 threads on my machine. While admittedly dynamic niceness reduces the need for many priority levels, you might see why I don't see a reason to have 32 priority levels in RIOT.
I think that you're right that 32 priority levels will likely never be needed in RIOT, but I don't see a real benefit as long as priority stays a uint16_t inside tcb_t. A similar argument could be made for pid (which also is a uint16_t): I don't think RIOT will ever run with 65535 threads, but as long as tcb_t isn't changed to use uint8_t for both it's just an artificial barrier.
Be aware of the fact that RIOT maintains a runqueue for every priority: https://github.com/RIOT-OS/RIOT/blob/master/core/sched.c#L52
~~Maybe we could even go a step further and set SCHED_PRIO_LEVELS==8?~~