Ignore:
Timestamp:
Jul 27, 2017, 12:23:29 AM (5 years ago)
Author:
alain
Message:

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/scheduler.h

    r14 r279  
    3434struct thread_s;
    3535
    36 /***********************************************************************************************
     36/*********************************************************************************************
    3737 * This structure define the scheduler associated to a given core.
    3838 * WARNING : the idle thread is executed when there is no runable thread in the list
    3939 * of attached threads, but is NOT part of the list of attached threads.
    40  **********************************************************************************************/
     40 ********************************************************************************************/
    4141
    4242typedef struct scheduler_s
    4343{
    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 kernel thread */
    50     list_entry_t    * k_last;       /*! pointer on list entry for last executed user 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                   */
    5353}
    5454scheduler_t;
    5555
    56 /***********************************************************************************************
     56/*********************************************************************************************
    5757 *  This function initialises the scheduler for a given core.
    58  **********************************************************************************************
     58 ********************************************************************************************
    5959void sched_init( struct core_s * core );
    6060
    61 /***********************************************************************************************
     61/*********************************************************************************************
    6262 * This function register a new thread in a given core scheduler.
    63  ***********************************************************************************************
     63 *********************************************************************************************
    6464 * @ core    : local pointer on the core descriptor.
    6565 * @ thread  : local pointer on the thread descriptor.
    66  **********************************************************************************************
     66 ********************************************************************************************
    6767void sched_register_thread( struct core_s   * core,
    6868                            struct thread_s * thread );
    6969
    70 /***********************************************************************************************
     70/*********************************************************************************************
    7171 *  This function removes a thread from the set of threads attached to a given core.
    72  ***********************************************************************************************
     72 *********************************************************************************************
    7373 * @ thread  : local pointer on the thread descriptor.
    74  **********************************************************************************************
     74 ********************************************************************************************
    7575void sched_remove_thread( struct thread_s * thread );
    7676
    77 /***********************************************************************************************
     77/*********************************************************************************************
    7878 * This function handles pending signals for all registered threads, and tries to make
    7979 * a context switch for the core running the calling thread.
     
    8282 * - If there is no other runable thread, the calling thread continues execution.
    8383 * - If there is no runable thread, the idle thread is executed.
    84  **********************************************************************************************/
     84 ********************************************************************************************/
    8585void sched_yield();
    8686
    87 /***********************************************************************************************
     87/*********************************************************************************************
    8888 * This function handles pending signals for all registered threads, and make
    8989 * a context switch to the thread defined by the <thread> argument.
    9090 * If the selected thread is not attached to the same core as the calling thread,
    9191 * or is blocked, it causes a kernel panic.
    92  ***********************************************************************************************
     92 *********************************************************************************************
    9393 * @ new   : local pointer on the thread to run.
    94  **********************************************************************************************/
     94 ********************************************************************************************/
    9595void sched_switch_to( struct thread_s * new );
    9696
    97 /***********************************************************************************************
     97/*********************************************************************************************
    9898 * This function scan all threads attached to a given core scheduler, and executes
    9999 * the relevant actions for pending signals, such as the THREAD_SIG_KILL signal.
    100  ***********************************************************************************************
     100 *********************************************************************************************
    101101 * @ core    : local pointer on the core descriptor.
    102  **********************************************************************************************/
     102 ********************************************************************************************/
    103103void sched_handle_signals( struct core_s * core );
    104104
    105 /***********************************************************************************************
     105/*********************************************************************************************
    106106 * This function is used by the scheduler of a given core to actually kill a thread that has
    107107 * the SIG_KILL signal set (following a thread_exit() or a thread_kill() event).
     
    110110 * - It removes the thread from the scheduler.
    111111 * - It release physical memory allocated for thread descriptor.
    112  ***********************************************************************************************
     112 *********************************************************************************************
    113113 * @ thread  : local pointer on the thread descriptor.
    114  **********************************************************************************************/
     114 ********************************************************************************************/
    115115void sched_kill_thread( struct thread_s * thread );
    116116
    117 /***********************************************************************************************
     117/*********************************************************************************************
    118118 * This function does NOT modify the scheduler state.
    119119 * It just select a thread in the list of attached threads, implementing the following policy:
     
    123123 *    the last executed one, and returns the first runable found (can be the current thread).
    124124 * 3) if no runable thread found, it returns the idle thread.
    125  ***********************************************************************************************
     125 *********************************************************************************************
    126126 * @ core    : local pointer on the core descriptor.
    127127 * @ returns pointer on selected thread descriptor
    128  **********************************************************************************************/
     128 ********************************************************************************************/
    129129struct thread_s * sched_select( struct core_s * core );
    130130
    131 /***********************************************************************************************
     131/*********************************************************************************************
    132132 * This function scan the list of kernel threads to find an idle (blocked) RPC thread.
    133  ***********************************************************************************************
     133 *********************************************************************************************
    134134 * @ core    : local pointer on the core descriptor.
    135135 * @ returns pointer on RPC thread descriptor / returns NULL if no idle RPC thread.
    136  **********************************************************************************************/
     136 ********************************************************************************************/
    137137struct thread_s * sched_get_rpc_thead( struct core_s * core );
    138138
Note: See TracChangeset for help on using the changeset viewer.