Changeset 279 for trunk/kernel/kern/scheduler.h
- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/scheduler.h
r14 r279 34 34 struct thread_s; 35 35 36 /********************************************************************************************* **36 /********************************************************************************************* 37 37 * This structure define the scheduler associated to a given core. 38 38 * WARNING : the idle thread is executed when there is no runable thread in the list 39 39 * of attached threads, but is NOT part of the list of attached threads. 40 ******************************************************************************************** **/40 ********************************************************************************************/ 41 41 42 42 typedef struct scheduler_s 43 43 { 44 spinlock_t lock; /*! readlock protecting lists of threads 45 uint16_t u_threads_nr; /*! total numbre of attached user threads 46 uint16_t k_threads_nr; /*! total number of attached kernel threads 47 list_entry_t u_root; /*! root of list of user threads for this scheduler 48 list_entry_t k_root; /*! root of list of kernel threads for this scheduler 49 list_entry_t * u_last; /*! pointer on list_entry for last executed k ernel thread*/50 list_entry_t * k_last; /*! pointer on list entry for last executed u ser thread*/51 struct thread_s * idle; /*! pointer on idle thread 52 struct thread_s * current; /*! pointer on current running thread 44 spinlock_t lock; /*! readlock protecting lists of threads */ 45 uint16_t u_threads_nr; /*! total numbre of attached user threads */ 46 uint16_t k_threads_nr; /*! total number of attached kernel threads */ 47 list_entry_t u_root; /*! root of list of user threads for this scheduler */ 48 list_entry_t k_root; /*! root of list of kernel threads for this scheduler */ 49 list_entry_t * u_last; /*! pointer on list_entry for last executed k_thread */ 50 list_entry_t * k_last; /*! pointer on list entry for last executed u_thread */ 51 struct thread_s * idle; /*! pointer on idle thread */ 52 struct thread_s * current; /*! pointer on current running thread */ 53 53 } 54 54 scheduler_t; 55 55 56 /********************************************************************************************* **56 /********************************************************************************************* 57 57 * This function initialises the scheduler for a given core. 58 ******************************************************************************************** **/58 ********************************************************************************************/ 59 59 void sched_init( struct core_s * core ); 60 60 61 /********************************************************************************************* **61 /********************************************************************************************* 62 62 * This function register a new thread in a given core scheduler. 63 ********************************************************************************************* **63 ********************************************************************************************* 64 64 * @ core : local pointer on the core descriptor. 65 65 * @ thread : local pointer on the thread descriptor. 66 ******************************************************************************************** **/66 ********************************************************************************************/ 67 67 void sched_register_thread( struct core_s * core, 68 68 struct thread_s * thread ); 69 69 70 /********************************************************************************************* **70 /********************************************************************************************* 71 71 * This function removes a thread from the set of threads attached to a given core. 72 ********************************************************************************************* **72 ********************************************************************************************* 73 73 * @ thread : local pointer on the thread descriptor. 74 ******************************************************************************************** **/74 ********************************************************************************************/ 75 75 void sched_remove_thread( struct thread_s * thread ); 76 76 77 /********************************************************************************************* **77 /********************************************************************************************* 78 78 * This function handles pending signals for all registered threads, and tries to make 79 79 * a context switch for the core running the calling thread. … … 82 82 * - If there is no other runable thread, the calling thread continues execution. 83 83 * - If there is no runable thread, the idle thread is executed. 84 ******************************************************************************************** **/84 ********************************************************************************************/ 85 85 void sched_yield(); 86 86 87 /********************************************************************************************* **87 /********************************************************************************************* 88 88 * This function handles pending signals for all registered threads, and make 89 89 * a context switch to the thread defined by the <thread> argument. 90 90 * If the selected thread is not attached to the same core as the calling thread, 91 91 * or is blocked, it causes a kernel panic. 92 ********************************************************************************************* **92 ********************************************************************************************* 93 93 * @ new : local pointer on the thread to run. 94 ******************************************************************************************** **/94 ********************************************************************************************/ 95 95 void sched_switch_to( struct thread_s * new ); 96 96 97 /********************************************************************************************* **97 /********************************************************************************************* 98 98 * This function scan all threads attached to a given core scheduler, and executes 99 99 * the relevant actions for pending signals, such as the THREAD_SIG_KILL signal. 100 ********************************************************************************************* **100 ********************************************************************************************* 101 101 * @ core : local pointer on the core descriptor. 102 ******************************************************************************************** **/102 ********************************************************************************************/ 103 103 void sched_handle_signals( struct core_s * core ); 104 104 105 /********************************************************************************************* **105 /********************************************************************************************* 106 106 * This function is used by the scheduler of a given core to actually kill a thread that has 107 107 * the SIG_KILL signal set (following a thread_exit() or a thread_kill() event). … … 110 110 * - It removes the thread from the scheduler. 111 111 * - It release physical memory allocated for thread descriptor. 112 ********************************************************************************************* **112 ********************************************************************************************* 113 113 * @ thread : local pointer on the thread descriptor. 114 ******************************************************************************************** **/114 ********************************************************************************************/ 115 115 void sched_kill_thread( struct thread_s * thread ); 116 116 117 /********************************************************************************************* **117 /********************************************************************************************* 118 118 * This function does NOT modify the scheduler state. 119 119 * It just select a thread in the list of attached threads, implementing the following policy: … … 123 123 * the last executed one, and returns the first runable found (can be the current thread). 124 124 * 3) if no runable thread found, it returns the idle thread. 125 ********************************************************************************************* **125 ********************************************************************************************* 126 126 * @ core : local pointer on the core descriptor. 127 127 * @ returns pointer on selected thread descriptor 128 ******************************************************************************************** **/128 ********************************************************************************************/ 129 129 struct thread_s * sched_select( struct core_s * core ); 130 130 131 /********************************************************************************************* **131 /********************************************************************************************* 132 132 * This function scan the list of kernel threads to find an idle (blocked) RPC thread. 133 ********************************************************************************************* **133 ********************************************************************************************* 134 134 * @ core : local pointer on the core descriptor. 135 135 * @ returns pointer on RPC thread descriptor / returns NULL if no idle RPC thread. 136 ******************************************************************************************** **/136 ********************************************************************************************/ 137 137 struct thread_s * sched_get_rpc_thead( struct core_s * core ); 138 138
Note: See TracChangeset
for help on using the changeset viewer.