Lowering Thread Priority
Lowering Thread Priority
- Subject: Lowering Thread Priority
- From: "Duane Murphy" <email@hidden>
- Date: Mon, 26 Nov 2007 22:17:47 -0800
I would like to lower the priority of a background thread in my kext.
I'm using thread_policy_set() with the THREAD_PRECEDENCE_POLICY. At best
I am making a guess at what the importance number should be for this
thread. I'd have a better understanding of what to use for importance if
I could call thread_policy_get() except that thread_policy_get() is not
exported <sigh>.
This one thread is a background thread while most of the other threads
are IO requests from userland, so I'm assuming I really shouldn't be
changing any priorities there.
"Using Mac Scheduling From User Applications" says that an importance
number of 0 is idle, described as "threads set to IDLE_PRI will only
execute when no other thread is scheduled to execute." This seems too
low for my purposes; that is i'd like it to run sometimes, just not as
high priority as the IO request threads.
Another part of "Using Mac Scheduling From User Applications" says
"While this is a signed 32-bit value, the minimum legal value is zero
(IDLE_PRI)." However, some reading in past emails use negative values
for importance. (I can't even find a definition for IDLE_PRI).
How can I determine an appropriate value for importance? Or is there a
better way to lower the priority of this thread?
Some background on this thread. This thread does not run all the time.
It is called upon to do a lot of work for a period of time and then
stop. The work is in competition with the IO requests, but should have a
lower priority to ensure that the IO requests get through in a
reasonable amount of time.
Thanks for any tips on how to lower the priority of this background thread.
...Duane
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden