#361 Thread (POSIX) returns uninitialised value for OS priority

Platform_Specific
closed
nobody
5
2012-09-14
2010-06-25
sqrpeg
No

getOSPriorityImpl returns the data member _pData->osPrio. This is not initialised in the ThreadData constructor and is only set when calling the method setOSPriorityImpl. Calls to getOSPriority prior to this will return an uninitialised value. If this is the intended functionality, would it be possible to update the documentation?

Discussion

  • sqrpeg
    sqrpeg
    2010-06-25

    Note that there is an additional issue in the use of OS priorities, if you set it to an OS value such as 8-10 (as we did on QNX, which is in the recommended user range), when the thread is re-used in the Pool, the priority can be set to NORMAL (the default) and this works out to be 32, which can cause some issues. Would it be possible to allow LOW, NORMAL and HIGH to be configurable for the platform as 16, 32 and 48 on QNX can lead to some issues, not sure about other POSIX implementations. I realise these are portable components so when using OS features there is a risk but the OS priority and the enumerate priority are inevitably linked in the implementation.

     
  • Until we have a better solution, the osPrio member is initialized to zero, and the getOSPriority() method documentation has been updated to state this.

    You can now also override the system-provided thread priorities by compiling POCO with the preprocessor symbols POCO_THREAD_PRIORITY_MIN and POCO_THREAD_PRIORITY_MAX #define'd accordingly.