]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/sched_prim.h
xnu-3247.1.106.tar.gz
[apple/xnu.git] / osfmk / kern / sched_prim.h
CommitLineData
1c79356b 1/*
39236c6e 2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 */
58/*
59 * File: sched_prim.h
60 * Author: David Golub
61 *
62 * Scheduling primitive definitions file
63 *
64 */
65
66#ifndef _KERN_SCHED_PRIM_H_
67#define _KERN_SCHED_PRIM_H_
68
69#include <mach/boolean.h>
70#include <mach/machine/vm_types.h>
71#include <mach/kern_return.h>
72#include <kern/clock.h>
73#include <kern/kern_types.h>
74#include <kern/thread.h>
91447636 75#include <sys/cdefs.h>
9bccf70c
A
76
77#ifdef MACH_KERNEL_PRIVATE
1c79356b 78
3e170ce0
A
79#include <mach/branch_predicates.h>
80
91447636 81/* Initialization */
39236c6e 82extern void sched_init(void);
1c79356b 83
91447636 84extern void sched_startup(void);
1c79356b 85
91447636 86extern void sched_timebase_init(void);
1c79356b 87
91447636 88/* Force a preemption point for a thread and wait for it to stop running */
1c79356b 89extern boolean_t thread_stop(
39236c6e
A
90 thread_t thread,
91 boolean_t until_not_runnable);
1c79356b 92
91447636
A
93/* Release a previous stop request */
94extern void thread_unstop(
1c79356b
A
95 thread_t thread);
96
91447636
A
97/* Wait for a thread to stop running */
98extern void thread_wait(
316670eb
A
99 thread_t thread,
100 boolean_t until_not_runnable);
1c79356b 101
91447636
A
102/* Unblock thread on wake up */
103extern boolean_t thread_unblock(
104 thread_t thread,
105 wait_result_t wresult);
1c79356b 106
91447636
A
107/* Unblock and dispatch thread */
108extern kern_return_t thread_go(
109 thread_t thread,
110 wait_result_t wresult);
1c79356b 111
2d21ac55 112/* Handle threads at context switch */
91447636 113extern void thread_dispatch(
2d21ac55
A
114 thread_t old_thread,
115 thread_t new_thread);
1c79356b 116
91447636
A
117/* Switch directly to a particular thread */
118extern int thread_run(
119 thread_t self,
120 thread_continue_t continuation,
121 void *parameter,
122 thread_t new_thread);
123
124/* Resume thread with new stack */
125extern void thread_continue(
126 thread_t old_thread);
127
1c79356b
A
128/* Invoke continuation */
129extern void call_continuation(
91447636
A
130 thread_continue_t continuation,
131 void *parameter,
132 wait_result_t wresult);
9bccf70c
A
133
134/* Set the current scheduled priority */
135extern void set_sched_pri(
136 thread_t thread,
137 int priority);
1c79356b 138
9bccf70c 139/* Set base priority of the specified thread */
fe8ab488 140extern void sched_set_thread_base_priority(
9bccf70c
A
141 thread_t thread,
142 int priority);
143
fe8ab488
A
144/* Set the thread to be categorized as 'background' */
145extern void sched_set_thread_throttled(thread_t thread,
146 boolean_t wants_throttle);
147
148/* Set the thread's true scheduling mode */
149extern void sched_set_thread_mode(thread_t thread,
150 sched_mode_t mode);
151/* Demote the true scheduler mode */
152extern void sched_thread_mode_demote(thread_t thread,
153 uint32_t reason);
154/* Un-demote the true scheduler mode */
155extern void sched_thread_mode_undemote(thread_t thread,
156 uint32_t reason);
157
3e170ce0
A
158/* Re-evaluate base priority of thread (thread locked) */
159void thread_recompute_priority(thread_t thread);
160
161/* Re-evaluate base priority of thread (thread unlocked) */
162void thread_recompute_qos(thread_t thread);
163
9bccf70c 164/* Reset scheduled priority of thread */
3e170ce0 165extern void thread_recompute_sched_pri(
9bccf70c
A
166 thread_t thread,
167 boolean_t override_depress);
1c79356b 168
1c79356b 169/* Periodic scheduler activity */
6d2010ae 170extern void sched_init_thread(void (*)(void));
1c79356b 171
91447636 172/* Perform sched_tick housekeeping activities */
6d2010ae 173extern boolean_t can_update_priority(
9bccf70c 174 thread_t thread);
1c79356b 175
6d2010ae
A
176extern void update_priority(
177 thread_t thread);
178
179extern void lightweight_update_priority(
180 thread_t thread);
181
3e170ce0 182extern void sched_default_quantum_expire(thread_t thread);
6d2010ae 183
91447636 184/* Idle processor thread */
1c79356b
A
185extern void idle_thread(void);
186
91447636
A
187extern kern_return_t idle_thread_create(
188 processor_t processor);
1c79356b 189
1c79356b
A
190/* Continuation return from syscall */
191extern void thread_syscall_return(
192 kern_return_t ret);
193
91447636 194/* Context switch */
9bccf70c
A
195extern wait_result_t thread_block_reason(
196 thread_continue_t continuation,
91447636 197 void *parameter,
9bccf70c 198 ast_t reason);
1c79356b 199
91447636 200/* Reschedule thread for execution */
1c79356b 201extern void thread_setrun(
9bccf70c 202 thread_t thread,
55e303ae 203 integer_t options);
1c79356b 204
2d21ac55
A
205#define SCHED_TAILQ 1
206#define SCHED_HEADQ 2
207#define SCHED_PREEMPT 4
1c79356b 208
3e170ce0
A
209extern uintptr_t sched_thread_on_rt_queue;
210#define THREAD_ON_RT_RUNQ ((processor_t)(uintptr_t)&sched_thread_on_rt_queue)
211
b0d623f7
A
212extern processor_set_t task_choose_pset(
213 task_t task);
214
2d21ac55 215/* Bind the current thread to a particular processor */
55e303ae 216extern processor_t thread_bind(
55e303ae 217 processor_t processor);
1c79356b 218
6d2010ae
A
219/* Choose the best processor to run a thread */
220extern processor_t choose_processor(
221 processor_set_t pset,
222 processor_t processor,
223 thread_t thread);
224
6d2010ae
A
225
226extern void thread_quantum_init(
227 thread_t thread);
228
2d21ac55
A
229extern void run_queue_init(
230 run_queue_t runq);
231
6d2010ae
A
232extern thread_t run_queue_dequeue(
233 run_queue_t runq,
234 integer_t options);
235
236extern boolean_t run_queue_enqueue(
237 run_queue_t runq,
238 thread_t thread,
239 integer_t options);
240
241extern void run_queue_remove(
242 run_queue_t runq,
243 thread_t thread);
244
3e170ce0
A
245struct sched_update_scan_context
246{
247 uint64_t earliest_bg_make_runnable_time;
248 uint64_t earliest_normal_make_runnable_time;
249 uint64_t earliest_rt_make_runnable_time;
250};
251typedef struct sched_update_scan_context *sched_update_scan_context_t;
fe8ab488
A
252
253#if defined(CONFIG_SCHED_TIMESHARE_CORE)
254
3e170ce0 255extern boolean_t thread_update_add_thread(thread_t thread);
fe8ab488 256extern void thread_update_process_threads(void);
3e170ce0
A
257extern boolean_t runq_scan(run_queue_t runq, sched_update_scan_context_t scan_context);
258
259extern void sched_timeshare_init(void);
260extern void sched_timeshare_timebase_init(void);
261extern void sched_timeshare_maintenance_continue(void);
262
263extern boolean_t priority_is_urgent(int priority);
264extern uint32_t sched_timeshare_initial_quantum_size(thread_t thread);
fe8ab488 265
3e170ce0 266extern int sched_compute_timeshare_priority(thread_t thread);
fe8ab488
A
267
268#endif /* CONFIG_SCHED_TIMESHARE_CORE */
269
3e170ce0
A
270extern void rt_runq_scan(sched_update_scan_context_t scan_context);
271
6d2010ae 272/* Remove thread from its run queue */
3e170ce0
A
273extern boolean_t thread_run_queue_remove(thread_t thread);
274thread_t thread_run_queue_remove_for_handoff(thread_t thread);
275
276/* Put a thread back in the run queue after being yanked */
277extern void thread_run_queue_reinsert(thread_t thread, integer_t options);
6d2010ae 278
91447636
A
279extern void thread_timer_expire(
280 void *thread,
281 void *p1);
282
6d2010ae
A
283extern boolean_t thread_eager_preemption(
284 thread_t thread);
285
6d2010ae
A
286extern boolean_t sched_generic_direct_dispatch_to_idle_processors;
287
9bccf70c
A
288/* Set the maximum interrupt level for the thread */
289__private_extern__ wait_interrupt_t thread_interrupt_level(
290 wait_interrupt_t interruptible);
291
292__private_extern__ wait_result_t thread_mark_wait_locked(
293 thread_t thread,
294 wait_interrupt_t interruptible);
295
9bccf70c
A
296/* Wake up locked thread directly, passing result */
297__private_extern__ kern_return_t clear_wait_internal(
298 thread_t thread,
299 wait_result_t result);
1c79356b 300
6d2010ae
A
301extern void sched_stats_handle_csw(
302 processor_t processor,
303 int reasons,
304 int selfpri,
305 int otherpri);
306
307extern void sched_stats_handle_runq_change(
308 struct runq_stats *stats,
309 int old_count);
310
311
312
313#define SCHED_STATS_CSW(processor, reasons, selfpri, otherpri) \
314do { \
315 if (__builtin_expect(sched_stats_active, 0)) { \
316 sched_stats_handle_csw((processor), \
317 (reasons), (selfpri), (otherpri)); \
318 } \
319} while (0)
320
321
322#define SCHED_STATS_RUNQ_CHANGE(stats, old_count) \
323do { \
324 if (__builtin_expect(sched_stats_active, 0)) { \
325 sched_stats_handle_runq_change((stats), \
326 (old_count)); \
327 } \
328} while (0)
329
3e170ce0
A
330extern uint32_t sched_debug_flags;
331#define SCHED_DEBUG_FLAG_PLATFORM_TRACEPOINTS 0x00000001
332#define SCHED_DEBUG_FLAG_CHOOSE_PROCESSOR_TRACEPOINTS 0x00000002
333
334#define SCHED_DEBUG_PLATFORM_KERNEL_DEBUG_CONSTANT(...) do { \
335 if (__improbable(sched_debug_flags & SCHED_DEBUG_FLAG_PLATFORM_TRACEPOINTS)) { \
336 KERNEL_DEBUG_CONSTANT(__VA_ARGS__); \
337 } \
338 } while(0)
339
340#define SCHED_DEBUG_CHOOSE_PROCESSOR_KERNEL_DEBUG_CONSTANT(...) do { \
341 if (__improbable(sched_debug_flags & SCHED_DEBUG_FLAG_CHOOSE_PROCESSOR_TRACEPOINTS)) { \
342 KERNEL_DEBUG_CONSTANT(__VA_ARGS__); \
343 } \
344 } while(0)
345
6d2010ae
A
346#define THREAD_URGENCY_NONE 0 /* indicates that there is no currently runnable */
347#define THREAD_URGENCY_BACKGROUND 1 /* indicates that the thread is marked as a "background" thread */
348#define THREAD_URGENCY_NORMAL 2 /* indicates that the thread is marked as a "normal" thread */
349#define THREAD_URGENCY_REAL_TIME 3 /* indicates that the thread is marked as a "real-time" or urgent thread */
350#define THREAD_URGENCY_MAX 4 /* Marker */
39236c6e 351/* Returns the "urgency" of a thread (provided by scheduler) */
6d2010ae 352extern int thread_get_urgency(
39236c6e 353 thread_t thread,
6d2010ae
A
354 uint64_t *rt_period,
355 uint64_t *rt_deadline);
356
357/* Tells the "urgency" of the just scheduled thread (provided by CPU PM) */
358extern void thread_tell_urgency(
359 int urgency,
360 uint64_t rt_period,
39236c6e 361 uint64_t rt_deadline,
3e170ce0 362 uint64_t sched_latency,
39236c6e 363 thread_t nthread);
6d2010ae
A
364
365/* Tells if there are "active" RT threads in the system (provided by CPU PM) */
366extern void active_rt_threads(
367 boolean_t active);
368
1c79356b
A
369#endif /* MACH_KERNEL_PRIVATE */
370
91447636 371__BEGIN_DECLS
55e303ae 372
91447636
A
373#ifdef XNU_KERNEL_PRIVATE
374
375extern boolean_t assert_wait_possible(void);
1c79356b 376
39236c6e
A
377/* Toggles a global override to turn off CPU Throttling */
378#define CPU_THROTTLE_DISABLE 0
379#define CPU_THROTTLE_ENABLE 1
380extern void sys_override_cpu_throttle(int flag);
381
1c79356b 382/*
91447636 383 ****************** Only exported until BSD stops using ********************
1c79356b 384 */
1c79356b 385
3e170ce0
A
386extern void thread_vm_bind_group_add(void);
387
1c79356b 388/* Wake up thread directly, passing result */
9bccf70c
A
389extern kern_return_t clear_wait(
390 thread_t thread,
391 wait_result_t result);
1c79356b 392
b7266188
A
393/* Start thread running */
394extern void thread_bootstrap_return(void);
395
91447636 396/* Return from exception (BSD-visible interface) */
2d21ac55 397extern void thread_exception_return(void) __dead2;
1c79356b 398
3e170ce0
A
399#define SCHED_STRING_MAX_LENGTH (48)
400/* String declaring the name of the current scheduler */
401extern char sched_string[SCHED_STRING_MAX_LENGTH];
402
403extern kern_return_t sched_work_interval_notify(thread_t thread, uint64_t work_interval_id, uint64_t start, uint64_t finish, uint64_t deadline, uint64_t next_start, uint32_t flags);
404
91447636 405#endif /* XNU_KERNEL_PRIVATE */
1c79356b 406
91447636
A
407/* Context switch */
408extern wait_result_t thread_block(
409 thread_continue_t continuation);
1c79356b 410
91447636
A
411extern wait_result_t thread_block_parameter(
412 thread_continue_t continuation,
413 void *parameter);
1c79356b 414
1c79356b 415/* Declare thread will wait on a particular event */
91447636
A
416extern wait_result_t assert_wait(
417 event_t event,
418 wait_interrupt_t interruptible);
1c79356b 419
91447636
A
420/* Assert that the thread intends to wait with a timeout */
421extern wait_result_t assert_wait_timeout(
422 event_t event,
423 wait_interrupt_t interruptible,
424 uint32_t interval,
425 uint32_t scale_factor);
1c79356b 426
39236c6e
A
427/* Assert that the thread intends to wait with an urgency, timeout and leeway */
428extern wait_result_t assert_wait_timeout_with_leeway(
429 event_t event,
430 wait_interrupt_t interruptible,
431 wait_timeout_urgency_t urgency,
432 uint32_t interval,
433 uint32_t leeway,
434 uint32_t scale_factor);
435
91447636
A
436extern wait_result_t assert_wait_deadline(
437 event_t event,
438 wait_interrupt_t interruptible,
439 uint64_t deadline);
1c79356b 440
39236c6e
A
441/* Assert that the thread intends to wait with an urgency, deadline, and leeway */
442extern wait_result_t assert_wait_deadline_with_leeway(
443 event_t event,
444 wait_interrupt_t interruptible,
445 wait_timeout_urgency_t urgency,
446 uint64_t deadline,
447 uint64_t leeway);
448
91447636
A
449/* Wake up thread (or threads) waiting on a particular event */
450extern kern_return_t thread_wakeup_prim(
451 event_t event,
452 boolean_t one_thread,
6d2010ae
A
453 wait_result_t result);
454
316670eb
A
455extern kern_return_t thread_wakeup_prim_internal(
456 event_t event,
6d2010ae
A
457 boolean_t one_thread,
458 wait_result_t result,
459 int priority);
316670eb 460
1c79356b
A
461
462#define thread_wakeup(x) \
316670eb 463 thread_wakeup_prim((x), FALSE, THREAD_AWAKENED)
1c79356b 464#define thread_wakeup_with_result(x, z) \
316670eb 465 thread_wakeup_prim((x), FALSE, (z))
1c79356b 466#define thread_wakeup_one(x) \
316670eb 467 thread_wakeup_prim((x), TRUE, THREAD_AWAKENED)
6d2010ae
A
468
469#ifdef MACH_KERNEL_PRIVATE
316670eb 470#define thread_wakeup_one_with_pri(x, pri) \
6d2010ae
A
471 thread_wakeup_prim_internal((x), TRUE, THREAD_AWAKENED, pri)
472#endif
1c79356b 473
91447636
A
474extern boolean_t preemption_enabled(void);
475
6d2010ae
A
476#ifdef MACH_KERNEL_PRIVATE
477
478/*
479 * Scheduler algorithm indirection. If only one algorithm is
480 * enabled at compile-time, a direction function call is used.
481 * If more than one is enabled, calls are dispatched through
482 * a function pointer table.
483 */
484
fe8ab488 485#if !defined(CONFIG_SCHED_TRADITIONAL) && !defined(CONFIG_SCHED_PROTO) && !defined(CONFIG_SCHED_GRRR) && !defined(CONFIG_SCHED_MULTIQ)
6d2010ae
A
486#error Enable at least one scheduler algorithm in osfmk/conf/MASTER.XXX
487#endif
488
489#define SCHED(f) (sched_current_dispatch->f)
490
491struct sched_dispatch_table {
3e170ce0 492 const char *sched_name;
6d2010ae
A
493 void (*init)(void); /* Init global state */
494 void (*timebase_init)(void); /* Timebase-dependent initialization */
495 void (*processor_init)(processor_t processor); /* Per-processor scheduler init */
496 void (*pset_init)(processor_set_t pset); /* Per-processor set scheduler init */
3e170ce0 497
6d2010ae 498 void (*maintenance_continuation)(void); /* Function called regularly */
3e170ce0 499
6d2010ae
A
500 /*
501 * Choose a thread of greater or equal priority from the per-processor
502 * runqueue for timeshare/fixed threads
503 */
504 thread_t (*choose_thread)(
505 processor_t processor,
fe8ab488
A
506 int priority,
507 ast_t reason);
3e170ce0
A
508
509 /* True if scheduler supports stealing threads */
510 boolean_t steal_thread_enabled;
511
6d2010ae
A
512 /*
513 * Steal a thread from another processor in the pset so that it can run
514 * immediately
515 */
516 thread_t (*steal_thread)(
517 processor_set_t pset);
3e170ce0 518
6d2010ae 519 /*
3e170ce0 520 * Compute priority for a timeshare thread based on base priority.
6d2010ae 521 */
3e170ce0
A
522 int (*compute_timeshare_priority)(thread_t thread);
523
6d2010ae
A
524 /*
525 * Pick the best processor for a thread (any kind of thread) to run on.
526 */
527 processor_t (*choose_processor)(
528 processor_set_t pset,
529 processor_t processor,
530 thread_t thread);
531 /*
532 * Enqueue a timeshare or fixed priority thread onto the per-processor
533 * runqueue
534 */
535 boolean_t (*processor_enqueue)(
536 processor_t processor,
537 thread_t thread,
538 integer_t options);
3e170ce0 539
6d2010ae
A
540 /* Migrate threads away in preparation for processor shutdown */
541 void (*processor_queue_shutdown)(
542 processor_t processor);
3e170ce0 543
6d2010ae
A
544 /* Remove the specific thread from the per-processor runqueue */
545 boolean_t (*processor_queue_remove)(
fe8ab488 546 processor_t processor,
6d2010ae 547 thread_t thread);
3e170ce0 548
6d2010ae
A
549 /*
550 * Does the per-processor runqueue have any timeshare or fixed priority
551 * threads on it? Called without pset lock held, so should
552 * not assume immutability while executing.
553 */
554 boolean_t (*processor_queue_empty)(processor_t processor);
3e170ce0 555
6d2010ae
A
556 /*
557 * Would this priority trigger an urgent preemption if it's sitting
558 * on the per-processor runqueue?
559 */
560 boolean_t (*priority_is_urgent)(int priority);
3e170ce0 561
6d2010ae
A
562 /*
563 * Does the per-processor runqueue contain runnable threads that
564 * should cause the currently-running thread to be preempted?
565 */
566 ast_t (*processor_csw_check)(processor_t processor);
3e170ce0 567
6d2010ae
A
568 /*
569 * Does the per-processor runqueue contain a runnable thread
570 * of > or >= priority, as a preflight for choose_thread() or other
571 * thread selection
572 */
573 boolean_t (*processor_queue_has_priority)(processor_t processor,
574 int priority,
575 boolean_t gte);
3e170ce0 576
6d2010ae
A
577 /* Quantum size for the specified non-realtime thread. */
578 uint32_t (*initial_quantum_size)(thread_t thread);
579
580 /* Scheduler mode for a new thread */
581 sched_mode_t (*initial_thread_sched_mode)(task_t parent_task);
3e170ce0 582
6d2010ae
A
583 /*
584 * Is it safe to call update_priority, which may change a thread's
585 * runqueue or other state. This can be used to throttle changes
586 * to dynamic priority.
587 */
588 boolean_t (*can_update_priority)(thread_t thread);
589
590 /*
591 * Update both scheduled priority and other persistent state.
592 * Side effects may including migration to another processor's runqueue.
593 */
594 void (*update_priority)(thread_t thread);
3e170ce0 595
6d2010ae
A
596 /* Lower overhead update to scheduled priority and state. */
597 void (*lightweight_update_priority)(thread_t thread);
3e170ce0 598
6d2010ae
A
599 /* Callback for non-realtime threads when the quantum timer fires */
600 void (*quantum_expire)(thread_t thread);
3e170ce0 601
6d2010ae
A
602 /*
603 * Runnable threads on per-processor runqueue. Should only
604 * be used for relative comparisons of load between processors.
605 */
606 int (*processor_runq_count)(processor_t processor);
6d2010ae 607
3e170ce0
A
608 /* Aggregate runcount statistics for per-processor runqueue */
609 uint64_t (*processor_runq_stats_count_sum)(processor_t processor);
fe8ab488
A
610
611 boolean_t (*processor_bound_count)(processor_t processor);
612
3e170ce0 613 void (*thread_update_scan)(sched_update_scan_context_t scan_context);
fe8ab488 614
6d2010ae
A
615 /*
616 * Use processor->next_thread to pin a thread to an idle
617 * processor. If FALSE, threads are enqueued and can
618 * be stolen by other processors.
619 */
620 boolean_t direct_dispatch_to_idle_processors;
3e170ce0
A
621
622 /* Supports more than one pset */
623 boolean_t multiple_psets_enabled;
624 /* Supports scheduler groups */
625 boolean_t sched_groups_enabled;
6d2010ae
A
626};
627
628#if defined(CONFIG_SCHED_TRADITIONAL)
6d2010ae
A
629extern const struct sched_dispatch_table sched_traditional_dispatch;
630extern const struct sched_dispatch_table sched_traditional_with_pset_runqueue_dispatch;
631#endif
632
fe8ab488
A
633#if defined(CONFIG_SCHED_MULTIQ)
634extern const struct sched_dispatch_table sched_multiq_dispatch;
fe8ab488 635extern const struct sched_dispatch_table sched_dualq_dispatch;
fe8ab488
A
636#endif
637
6d2010ae 638#if defined(CONFIG_SCHED_PROTO)
6d2010ae
A
639extern const struct sched_dispatch_table sched_proto_dispatch;
640#endif
641
642#if defined(CONFIG_SCHED_GRRR)
6d2010ae
A
643extern const struct sched_dispatch_table sched_grrr_dispatch;
644#endif
645
6d2010ae
A
646/*
647 * It is an error to invoke any scheduler-related code
648 * before this is set up
649 */
6d2010ae
A
650extern const struct sched_dispatch_table *sched_current_dispatch;
651
652#endif /* MACH_KERNEL_PRIVATE */
653
91447636 654__END_DECLS
1c79356b
A
655
656#endif /* _KERN_SCHED_PRIM_H_ */