Skip to content

Commit aad26e9

Browse files
ktopley-applerokhinip
authored andcommitted
Make workloop scheduling depend on TARGET_OS_MAC
Signed-off-by: Kim Topley <ktopley@apple.com>
1 parent 9c1b616 commit aad26e9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/queue_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ typedef struct dispatch_workloop_attr_s *dispatch_workloop_attr_t;
467467
typedef struct dispatch_workloop_attr_s {
468468
uint32_t dwla_flags;
469469
dispatch_priority_t dwla_pri;
470+
#if TARGET_OS_MAC
470471
struct sched_param dwla_sched;
472+
#endif // TARGET_OS_MAC
471473
int dwla_policy;
472474
struct {
473475
uint8_t percent;

src/unifdef.EdlZEO renamed to src/unifdef.d8V0yG

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,7 +3994,6 @@ _dispatch_workloop_has_kernel_attributes(dispatch_workloop_t dwl)
39943994
DISPATCH_WORKLOOP_ATTR_HAS_POLICY |
39953995
DISPATCH_WORKLOOP_ATTR_HAS_CPUPERCENT));
39963996
}
3997-
#endif // TARGET_OS_MAC
39983997

39993998
void
40003999
dispatch_workloop_set_scheduler_priority(dispatch_workloop_t dwl, int priority,
@@ -4018,6 +4017,7 @@ dispatch_workloop_set_scheduler_priority(dispatch_workloop_t dwl, int priority,
40184017
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
40194018
}
40204019
}
4020+
#endif // TARGET_OS_MAC
40214021

40224022
void
40234023
dispatch_workloop_set_qos_class_floor(dispatch_workloop_t dwl,
@@ -4036,12 +4036,16 @@ dispatch_workloop_set_qos_class_floor(dispatch_workloop_t dwl,
40364036
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_QOS_CLASS;
40374037
}
40384038

4039+
#if TARGET_OS_MAC
40394040
if (flags & DISPATCH_WORKLOOP_FIXED_PRIORITY) {
40404041
dwl->dwl_attr->dwla_policy = POLICY_RR;
40414042
dwl->dwl_attr->dwla_flags |= DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
40424043
} else {
40434044
dwl->dwl_attr->dwla_flags &= ~DISPATCH_WORKLOOP_ATTR_HAS_POLICY;
40444045
}
4046+
#else // TARGET_OS_MAC
4047+
(void)flags;
4048+
#endif // TARGET_OS_MAC
40454049
}
40464050

40474051
void
@@ -4102,7 +4106,6 @@ _dispatch_workloop_activate_simulator_fallback(dispatch_workloop_t dwl,
41024106
new_state |= DISPATCH_QUEUE_ROLE_BASE_ANON;
41034107
});
41044108
}
4105-
#endif // TARGET_OS_MAC
41064109

41074110
static const struct dispatch_queue_global_s _dispatch_custom_workloop_root_queue = {
41084111
DISPATCH_GLOBAL_OBJECT_HEADER(queue_global),
@@ -4115,6 +4118,7 @@ static const struct dispatch_queue_global_s _dispatch_custom_workloop_root_queue
41154118
.dq_serialnum = DISPATCH_QUEUE_SERIAL_NUMBER_WLF,
41164119
.dgq_thread_pool_size = 1,
41174120
};
4121+
#endif // TARGET_OS_MAC
41184122

41194123
static void
41204124
_dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
@@ -4126,6 +4130,7 @@ _dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
41264130
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_QOS_CLASS) {
41274131
dwl->dq_priority |= dwla->dwla_pri | DISPATCH_PRIORITY_FLAG_FLOOR;
41284132
}
4133+
#if TARGET_OS_MAC
41294134
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_SCHED) {
41304135
pthread_attr_setschedparam(&attr, &dwla->dwla_sched);
41314136
// _dispatch_async_and_wait_should_always_async detects when a queue
@@ -4138,6 +4143,7 @@ _dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
41384143
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_POLICY) {
41394144
pthread_attr_setschedpolicy(&attr, dwla->dwla_policy);
41404145
}
4146+
#endif // TARGET_OS_MAC
41414147
#if HAVE_PTHREAD_ATTR_SETCPUPERCENT_NP
41424148
if (dwla->dwla_flags & DISPATCH_WORKLOOP_ATTR_HAS_CPUPERCENT) {
41434149
pthread_attr_setcpupercent_np(&attr, dwla->dwla_cpupercent.percent,

0 commit comments

Comments
 (0)