[Mono-dev] Setting and Getting Thread Priority
Neale Ferguson
neale at sinenomine.net
Tue Jun 7 20:20:19 UTC 2016
After adding support for setting and getting thread priorities I’ve found
there’s one piece missing. Before a thread is started you can set its
priority such that when it’s started it will start with this priority
instead of the priority of the thread creating it.
At the moment the code lets this happen but does nothing with it. I have
started adding code to fix this missing piece. The trouble I am having is
that the wthreads.c implementation of GetThreadPriority() will simply
return THREAD_PRIORITY_NORMAL if the thread hasn’t been started yet: even
if a call to SetPriority has already been made. I was storing the priority
value in the MonoThread structure, however, wthreads.c does not have
visibility of this structure. I thought of putting it in MonoThreadInfo
but I’m not sure at which point this structure comes into existence. The
other place is within MonoThreadInternal which wthreads.c does see but
this requires a change in Threads.cs which has a one-to-one field
correspondence with the structure.
The other changes work fine such that a thread (running with the right
policy) will have its priority set at creation time. All that is missing
is GetPriority reporting the correct value before start time.
Neale
More information about the Mono-devel-list
mailing list