Skip to content

Commit d5afe08

Browse files
committed
Cap thread priority to normal for qos >= DISPATCH_QOS_DEFAULT
The high-priority class should be reserved for threads that must respond to time-critical events, user input threads should be THREAD_PRIORITY_NORMAL.
1 parent a3106e0 commit d5afe08

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/shims/priority.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ static inline int _dispatch_pp_to_win32_priority(pthread_priority_t pp) {
262262
return THREAD_PRIORITY_BELOW_NORMAL;
263263
case DISPATCH_QOS_DEFAULT:
264264
return THREAD_PRIORITY_NORMAL;
265+
// User input threads should be THREAD_PRIORITY_NORMAL, to
266+
// avoid unintentionally starving the system
265267
case DISPATCH_QOS_USER_INITIATED:
266-
return THREAD_PRIORITY_ABOVE_NORMAL;
268+
return THREAD_PRIORITY_NORMAL;
267269
case DISPATCH_QOS_USER_INTERACTIVE:
268-
return THREAD_PRIORITY_HIGHEST;
270+
return THREAD_PRIORITY_NORMAL;
269271
}
270272

271273
return THREAD_PRIORITY_NORMAL;

0 commit comments

Comments
 (0)