1 // Copyright 2017 The Fuchsia Authors 2 // Copyright (c) 2008-2015 Travis Geiselbrecht 3 // 4 // Use of this source code is governed by a MIT-style 5 // license that can be found in the LICENSE file or at 6 // https://opensource.org/licenses/MIT 7 #pragma once 8 9 #include <kernel/thread.h> 10 #include <list.h> 11 #include <stdbool.h> 12 #include <zircon/compiler.h> 13 14 __BEGIN_CDECLS 15 16 // scheduler interface, used internally by thread.c 17 // not intended to be used by regular kernel code 18 void sched_init_early(void); 19 20 void sched_init_thread(thread_t* t, int priority); 21 void sched_block(void) TA_REQ(thread_lock); 22 void sched_yield(void) TA_REQ(thread_lock); 23 void sched_preempt(void) TA_REQ(thread_lock); 24 void sched_reschedule(void) TA_REQ(thread_lock); 25 void sched_resched_internal(void) TA_REQ(thread_lock); 26 void sched_unblock_idle(thread_t* t) TA_REQ(thread_lock); 27 void sched_migrate(thread_t* t) TA_REQ(thread_lock); 28 29 // set the inherited priority of a thread and return if the caller should locally reschedule. 30 // pri should be <= MAX_PRIORITY, negative values disable priority inheritance. 31 void sched_inherit_priority(thread_t* t, int pri, bool* local_resched) TA_REQ(thread_lock); 32 33 // set the priority of a thread and reset the boost value. This function might reschedule. 34 // pri should be 0 <= to <= MAX_PRIORITY. 35 void sched_change_priority(thread_t* t, int pri) TA_REQ(thread_lock); 36 37 // return true if the thread was placed on the current cpu's run queue 38 // this usually means the caller should locally reschedule soon 39 bool sched_unblock(thread_t* t) __WARN_UNUSED_RESULT TA_REQ(thread_lock); 40 bool sched_unblock_list(struct list_node* list) __WARN_UNUSED_RESULT TA_REQ(thread_lock); 41 42 void sched_transition_off_cpu(cpu_num_t old_cpu) TA_REQ(thread_lock); 43 44 // sched_preempt_timer_tick is called when the preemption timer for a CPU has fired. 45 // 46 // This function is logically private and should only be called by timer.cpp. 47 void sched_preempt_timer_tick(zx_time_t now); 48 49 __END_CDECLS 50