Changeset a936aa49 in rtems


Ignore:
Timestamp:
Jun 6, 2013, 1:41:00 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
8b222be
Parents:
8f42092
git-author:
Sebastian Huber <sebastian.huber@…> (06/06/13 13:41:00)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/14/13 14:26:08)
Message:

scheduler: New simple SMP scheduler implementation

The new Simple SMP Scheduler allocates a processor for the processor
count highest priority ready threads. The thread priority and position
in the ready chain are the only information to determine the scheduling
decision. Threads with an allocated processor are in the scheduled
chain. After initialization the scheduled chain has exactly processor
count nodes. Each processor has exactly one allocated thread after
initialization. All enqueue and extract operations may exchange threads
with the scheduled chain. One thread will be added and another will be
removed. The scheduled and ready chain is ordered according to the
thread priority order. The chain insert operations are O(count of ready
threads), thus this scheduler is unsuitable for most real-time
applications.

The thread preempt mode will be ignored.

Location:
cpukit
Files:
1 added
3 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/confdefs.h

    r8f42092 ra936aa49  
    684684   */
    685685  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
    686     _Configure_From_workspace( sizeof(Chain_Control) ) \
     686    _Configure_From_workspace( sizeof( Scheduler_simple_smp_Control ) ) \
    687687  )
    688688  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
  • cpukit/score/Makefile.am

    r8f42092 ra936aa49  
    135135
    136136if HAS_SMP
    137 libscore_a_SOURCES += src/isrsmp.c src/smp.c \
    138     src/schedulersimplesmpblock.c src/schedulersimplesmpschedule.c \
    139     src/schedulersimplesmpunblock.c
     137libscore_a_SOURCES += src/isrsmp.c
     138libscore_a_SOURCES += src/schedulersimplesmp.c
     139libscore_a_SOURCES += src/smp.c
    140140endif
    141141
  • cpukit/score/include/rtems/score/schedulersimplesmp.h

    r8f42092 ra936aa49  
    11/**
    2  *  @file  rtems/score/schedulersimplesmp.h
     2 * @file
    33 *
    4  *  @brief Manipulation of Threads on a Simple-Priority-Based Ready Queue
     4 * @brief Simple SMP Scheduler API
    55 *
    6  *  This include file contains all the constants and structures associated
    7  *  with the manipulation of threads on a simple-priority-based ready queue.
    8  *  This implementation is SMP-aware and schedules across multiple cores.
    9  *
    10  *  The implementation relies heavily on the Simple Scheduler and
    11  *  only replaces a few routines from that scheduler.
     6 * @ingroup ScoreSchedulerSMP
    127 */
    138
    149/*
    1510 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
     11 *
     12 *  Copyright (c) 2013 embedded brains GmbH.
    1613 *
    1714 *  The license and distribution terms for this file may be
     
    2219#ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H
    2320#define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H
    24 
    25 /**
    26  *  @defgroup ScoreSchedulerSMP Simple SMP Scheduler
    27  *
    28  *  @ingroup ScoreScheduler
    29  *
    30  *  The Simple SMP Scheduler attempts to faithfully implement the
    31  *  behaviour of the Deterministic Priority Scheduler while spreading
    32  *  the threads across multiple cores.  It takes into account thread
    33  *  priority, preemption, and how long a thread has been executing
    34  *  on a core as factors.  From an implementation perspective, it
    35  *  relies heavily on the Simple Priority Scheduler.
    36  */
    37 /**@{*/
    3821
    3922#ifdef __cplusplus
     
    4629
    4730/**
    48  *  Entry points for Scheduler Simple SMP
     31 * @defgroup ScoreSchedulerSMP Simple SMP Scheduler
     32 *
     33 * @ingroup ScoreScheduler
     34 *
     35 * The Simple SMP Scheduler allocates a processor for the processor count
     36 * highest priority ready threads.  The thread priority and position in the
     37 * ready chain are the only information to determine the scheduling decision.
     38 * Threads with an allocated processor are in the scheduled chain.  After
     39 * initialization the scheduled chain has exactly processor count nodes.  Each
     40 * processor has exactly one allocated thread after initialization.  All
     41 * enqueue and extract operations may exchange threads with the scheduled
     42 * chain.  One thread will be added and another will be removed.  The scheduled
     43 * and ready chain is ordered according to the thread priority order.  The
     44 * chain insert operations are O(count of ready threads), thus this scheduler
     45 * is unsuitable for most real-time applications.
     46 *
     47 * The thread preempt mode will be ignored.
     48 *
     49 * @{
     50 */
     51
     52typedef struct {
     53  Chain_Control ready;
     54  Chain_Control scheduled;
     55} Scheduler_simple_smp_Control;
     56
     57/**
     58 * @brief Entry points for the Simple SMP Scheduler.
    4959 */
    5060#define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \
    5161  { \
    52     _Scheduler_simple_Initialize,         /* initialize entry point */ \
    53     _Scheduler_simple_smp_Schedule,       /* schedule entry point */ \
    54     _Scheduler_simple_Yield,              /* yield entry point */ \
    55     _Scheduler_simple_smp_Block,          /* block entry point */ \
    56     _Scheduler_simple_smp_Unblock,        /* unblock entry point */ \
    57     _Scheduler_simple_Allocate,           /* allocate entry point */ \
    58     _Scheduler_simple_Free,               /* free entry point */ \
    59     _Scheduler_simple_Update,             /* update entry point */ \
    60     _Scheduler_simple_Enqueue,            /* enqueue entry point */ \
    61     _Scheduler_simple_Enqueue_first,      /* enqueue_first entry point */ \
    62     _Scheduler_simple_Extract,            /* extract entry point */ \
    63     _Scheduler_priority_Priority_compare, /* compares two priorities */ \
    64     _Scheduler_priority_Release_job,      /* new period of task */ \
    65     _Scheduler_default_Tick               /* tick entry point */ \
     62    _Scheduler_simple_smp_Initialize, \
     63    _Scheduler_simple_smp_Schedule, \
     64    _Scheduler_simple_smp_Yield, \
     65    _Scheduler_simple_smp_Extract, \
     66    _Scheduler_simple_smp_Enqueue_priority_fifo, \
     67    _Scheduler_simple_Allocate, \
     68    _Scheduler_simple_Free, \
     69    _Scheduler_simple_Update, \
     70    _Scheduler_simple_smp_Enqueue_priority_fifo, \
     71    _Scheduler_simple_smp_Enqueue_priority_lifo, \
     72    _Scheduler_simple_smp_Extract, \
     73    _Scheduler_priority_Priority_compare, \
     74    _Scheduler_priority_Release_job, \
     75    _Scheduler_default_Tick, \
     76    _Scheduler_simple_smp_Start_idle \
    6677  }
    6778
    68 /**
    69  *  @brief Allocates ready SMP threads to individual cores in an SMP system.
    70  *
    71  *  This routine allocates ready threads to individual cores in an SMP
    72  *  system.  If the allocation results in a new heir which requires
    73  *  a dispatch, then the dispatch needed flag for that core is set.
    74  */
     79void _Scheduler_simple_smp_Initialize( void );
     80
     81void _Scheduler_simple_smp_Enqueue_priority_fifo( Thread_Control *thread );
     82
     83void _Scheduler_simple_smp_Enqueue_priority_lifo( Thread_Control *thread );
     84
     85void _Scheduler_simple_smp_Extract( Thread_Control *thread );
     86
     87void _Scheduler_simple_smp_Yield( Thread_Control *thread );
     88
    7589void _Scheduler_simple_smp_Schedule( void );
    7690
    77 /**
    78  *  @brief Remove SMP @a the_thread from the ready queue.
    79  *
    80  *  This routine removes @a the_thread from the scheduling decision,
    81  *  that is, removes it from the ready queue.  It performs
    82  *  any necessary scheduling operations including the selection of
    83  *  a new heir thread.
    84  *
    85  *  @param[in] the_thread is the thread that is to be blocked
    86  */
    87 void _Scheduler_simple_smp_Block(
    88   Thread_Control *the_thread
     91void _Scheduler_simple_smp_Start_idle(
     92  Thread_Control *thread,
     93  Per_CPU_Control *cpu
    8994);
    9095
    91 /**
    92  *  @brief Adds SMP @a the_thread to the ready queue and updates any
    93  *  appropriate scheduling variables, for example the heir thread.
    94  *
    95  *  This routine adds @a the_thread to the scheduling decision,
    96  *  that is, adds it to the ready queue and updates any appropriate
    97  *  scheduling variables, for example the heir thread.
    98  *
    99  *  @param[in] the_thread is the thread that is to be unblocked
    100  */
    101 void _Scheduler_simple_smp_Unblock(
    102   Thread_Control *the_thread
    103 );
     96/** @} */
    10497
    10598#ifdef __cplusplus
     
    107100#endif
    108101
    109 /**@}*/
    110 
    111102#endif
    112103/* end of include file */
  • cpukit/score/include/rtems/score/thread.h

    r8f42092 ra936aa49  
    385385  /** This field is true if the thread is preemptible. */
    386386  bool                                  is_preemptible;
     387#if defined(RTEMS_SMP)
     388  /**
     389   * @brief This field is true if the thread is scheduled.
     390   *
     391   * A thread is scheduled if it is ready and the scheduler allocated a
     392   * processor for it.  A scheduled thread is assigned to exactly one
     393   * processor.  There are exactly processor count scheduled threads in the
     394   * system.
     395   */
     396  bool                                  is_scheduled;
     397
     398  /**
     399   * @brief This field is true if the thread is executing.
     400   *
     401   * A thread is executing if it executes on a processor.  An executing thread
     402   * executes on exactly one processor.  There are exactly processor count
     403   * executing threads in the system.  An executing thread may have a heir
     404   * thread and thread dispatching is necessary.  On SMP a thread dispatch on a
     405   * remote processor needs help from an inter-processor interrupt, thus it
     406   * will take some time to complete the state change.  A lot of things can
     407   * happen in the meantime.
     408   */
     409  bool                                  is_executing;
     410#endif
    387411#if __RTEMS_ADA__
    388412  /** This field is the GNAT self context pointer. */
     
    408432  /** This pointer holds per-thread data for the scheduler and ready queue. */
    409433  void                                 *scheduler_info;
     434
     435#ifdef RTEMS_SMP
     436  Per_CPU_Control                      *cpu;
     437#endif
    410438
    411439  /** This field contains information about the starting state of
  • cpukit/score/src/smp.c

    r8f42092 ra936aa49  
    5252   */
    5353  heir = per_cpu->heir;
     54  heir->is_executing = true;
     55  per_cpu->executing->is_executing = false;
    5456  per_cpu->executing = heir;
     57  per_cpu->dispatch_necessary = false;
    5558
    5659  /*
  • cpukit/score/src/threaddispatch.c

    r8f42092 ra936aa49  
    9595  while ( _Thread_Dispatch_necessary == true ) {
    9696    heir = _Thread_Heir;
    97     #ifndef RTEMS_SMP
     97    #if defined(RTEMS_SMP)
     98      executing->is_executing = false;
     99      heir->is_executing = true;
     100    #else
    98101      _Thread_Dispatch_set_disable_level( 1 );
    99102    #endif
  • cpukit/score/src/threadinitialize.c

    r8f42092 ra936aa49  
    181181  the_thread->Start.isr_level         = isr_level;
    182182
     183#if defined(RTEMS_SMP)
     184  the_thread->is_scheduled            = false;
     185  the_thread->is_executing            = false;
     186  the_thread->cpu                     = NULL;
     187#endif
     188
    183189  the_thread->current_state           = STATES_DORMANT;
    184190  the_thread->Wait.queue              = NULL;
  • cpukit/score/src/threadstartmultitasking.c

    r8f42092 ra936aa49  
    4444  _Thread_Dispatch_necessary = false;
    4545
     46  #if defined(RTEMS_SMP)
     47    _Thread_Executing->is_executing = false;
     48    _Thread_Heir->is_executing = true;
     49  #endif
     50
    4651  _Thread_Executing = _Thread_Heir;
    4752
Note: See TracChangeset for help on using the changeset viewer.