SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /sos/sched.h (Article 6.5) and /sos/sched.h (Article 9)


001 /* Copyright (C) 2004 David Decotigny             001 /* Copyright (C) 2004 David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018 #ifndef _SOS_SCHED_H_                             018 #ifndef _SOS_SCHED_H_
019 #define _SOS_SCHED_H_                             019 #define _SOS_SCHED_H_
020                                                   020 
021                                                   021 
022 /**                                               022 /**
023  * @file sched.h                                  023  * @file sched.h
024  *                                                024  *
025  * A basic scheduler with simple FIFO threads' !! 025  * A basic scheduler inspired from the O(1) Linux scheduler. Supports
                                                   >> 026  * 2 classes of thread priorities:
                                                   >> 027  *  - so-called 'real-time' threads scheduled according to a simple
                                                   >> 028  *    traditional static priority real-time scheduler. "Real-time" round
                                                   >> 029  *    robin scheduling is not supported.
                                                   >> 030  * - "fair" time-sharing scheduling for non real-time threads. "fair"
                                                   >> 031  *    because no starvation among the non real-time threads is
                                                   >> 032  *    possible. Contrary to the original O(1) Linux scheduler, the
                                                   >> 033  *    on-line adjustment of the scheduling priorities to cope with
                                                   >> 034  *    interactive/non interactive threads discrimination is not
                                                   >> 035  *    supported: threads keep having the same priority as long as the
                                                   >> 036  *    user does not change it.
026  *                                                037  *
027  * The functions below manage CPU queues, and     038  * The functions below manage CPU queues, and are NEVER responsible
028  * for context switches (see thread.h for that    039  * for context switches (see thread.h for that) or synchronizations
029  * (see kwaitq.h or the higher levels primitiv    040  * (see kwaitq.h or the higher levels primitives [mutex, semaphore,
030  * ...] for that).                                041  * ...] for that).
031  *                                                042  *
032  * @note IMPORTANT: all the functions below ar    043  * @note IMPORTANT: all the functions below are meant to be called
033  * ONLY by the thread/timer/kwaitq subsystems.    044  * ONLY by the thread/timer/kwaitq subsystems. DO NOT use them
034  * directly from anywhere else: use ONLY the t    045  * directly from anywhere else: use ONLY the thread/kwaitq functions!
035  * If you still want to call them directly des    046  * If you still want to call them directly despite this disclaimer,
036  * simply disable interrupts before clling the    047  * simply disable interrupts before clling them.
037  */                                               048  */
038                                                   049 
039 #include <sos/errno.h>                            050 #include <sos/errno.h>
                                                   >> 051 #include <sos/time.h>
                                                   >> 052 
                                                   >> 053 
                                                   >> 054 /**
                                                   >> 055  * The definition of a priority
                                                   >> 056  */
                                                   >> 057 typedef unsigned char sos_sched_priority_t;
040                                                   058 
041                                                   059 
042 #include <sos/thread.h>                           060 #include <sos/thread.h>
043                                                   061 
044                                                   062 
045 /**                                               063 /**
                                                   >> 064  * Valid priority interval ("real-time" and non real-time threads altogether)
                                                   >> 065  */
                                                   >> 066 #define SOS_SCHED_PRIO_HIGHEST 0
                                                   >> 067 #define SOS_SCHED_PRIO_LOWEST  63
                                                   >> 068 #define SOS_SCHED_NUM_PRIO     64
                                                   >> 069 
                                                   >> 070 
                                                   >> 071 /**
                                                   >> 072  * Class-specific priorities
                                                   >> 073  */
                                                   >> 074 #define SOS_SCHED_PRIO_RT_HIGHEST 0  /**< Highest 'real-time' static prio. */
                                                   >> 075 #define SOS_SCHED_PRIO_RT_LOWEST  15 /**< Lowest 'real-time' static priority */
                                                   >> 076 #define SOS_SCHED_PRIO_TS_HIGHEST 16 /**< Highest time-sharing priority */
                                                   >> 077 #define SOS_SCHED_PRIO_TS_LOWEST  63 /**< Lowest time-sharing priority */
                                                   >> 078 
                                                   >> 079 #define SOS_SCHED_PRIO_DEFAULT 40    /**< Default priority */
                                                   >> 080 
                                                   >> 081 
                                                   >> 082 /**
                                                   >> 083  * Helper macros (Yes, priorities ordered in decreasing numerical value)
                                                   >> 084  *
                                                   >> 085  * @note: The use of this function is RESERVED
                                                   >> 086  */
                                                   >> 087 #define SOS_SCHED_PRIO_CMP(prio1,prio2)  ((prio1) - (prio2))
                                                   >> 088 
                                                   >> 089 #define SOS_SCHED_PRIO_IS_VALID(prio) \
                                                   >> 090   ({ int __prio = (int)(prio); \
                                                   >> 091      ((__prio) <= SOS_SCHED_PRIO_LOWEST) \
                                                   >> 092       && \
                                                   >> 093      ((__prio) >= SOS_SCHED_PRIO_HIGHEST); })
                                                   >> 094 
                                                   >> 095 #define SOS_SCHED_PRIO_IS_RT(prio)    \
                                                   >> 096   ({ int __prio = (int)(prio); \
                                                   >> 097      ((__prio) <= SOS_SCHED_PRIO_RT_LOWEST) \
                                                   >> 098       && \
                                                   >> 099      ((__prio) >= SOS_SCHED_PRIO_RT_HIGHEST); })
                                                   >> 100 
                                                   >> 101 
                                                   >> 102 /**
                                                   >> 103  * The time slices for 'time-sharing' user threads, in ms
                                                   >> 104  */
                                                   >> 105 #define SOS_TIME_SLICE_MIN  10 /* for SOS_SCHED_PRIO_TS_HIGHEST */
                                                   >> 106 #define SOS_TIME_SLICE_MAX 200 /* for SOS_SCHED_PRIO_TS_LOWEST */
                                                   >> 107 
                                                   >> 108 
                                                   >> 109 /**
046  * Initialize the scheduler                       110  * Initialize the scheduler
047  *                                                111  *
048  * @note: The use of this function is RESERVED    112  * @note: The use of this function is RESERVED
049  */                                               113  */
050 sos_ret_t sos_sched_subsystem_setup();            114 sos_ret_t sos_sched_subsystem_setup();
051                                                   115 
052                                                   116 
053 /**                                               117 /**
054  * Mark the given thread as ready                 118  * Mark the given thread as ready
055  *                                                119  *
056  * @note: The use of this function is RESERVED    120  * @note: The use of this function is RESERVED
057  */                                               121  */
058 sos_ret_t sos_sched_set_ready(struct sos_threa    122 sos_ret_t sos_sched_set_ready(struct sos_thread * thr);
059                                                   123 
060                                                   124 
061 /**                                               125 /**
062  * Return the identifier of the next thread to    126  * Return the identifier of the next thread to run. Also removes it
063  * from the ready list, but does NOT set is as    127  * from the ready list, but does NOT set is as current_thread !
064  *                                                128  *
065  * @param current_thread TCB of the thread cal    129  * @param current_thread TCB of the thread calling the function
066  *                                                130  *
067  * @param do_yield When TRUE, put the current     131  * @param do_yield When TRUE, put the current executing thread at the
068  * end of the ready list. Otherwise it is kept    132  * end of the ready list. Otherwise it is kept at the head of it.
069  *                                                133  *
070  * @note: The use of this function is RESERVED    134  * @note: The use of this function is RESERVED
071  */                                               135  */
072 struct sos_thread * sos_reschedule(struct sos_    136 struct sos_thread * sos_reschedule(struct sos_thread * current_thread,
073                                     sos_bool_t    137                                     sos_bool_t do_yield);
                                                   >> 138 
                                                   >> 139 /**
                                                   >> 140  * Called by thread subsystem each time a READY thread's priority is
                                                   >> 141  * changed
                                                   >> 142  *
                                                   >> 143  * @note: The use of this function is RESERVED (to thread.c)
                                                   >> 144  */
                                                   >> 145 sos_ret_t sos_sched_change_priority(struct sos_thread * thr,
                                                   >> 146                                     sos_sched_priority_t priority);
                                                   >> 147 
                                                   >> 148 
                                                   >> 149 /**
                                                   >> 150  * Account for the execution of a time tick. Should be called
                                                   >> 151  * immediately before the timer ISR calls sos_reschedule() before
                                                   >> 152  * returning to thread context.
                                                   >> 153  *
                                                   >> 154  * @note The use of this function is RESERVED (to timer IRQ)
                                                   >> 155  */
                                                   >> 156 sos_ret_t sos_sched_do_timer_tick();
074                                                   157 
075 #endif /* _SOS_WAITQUEUE_H_ */                    158 #endif /* _SOS_WAITQUEUE_H_ */
                                                      

source navigation ] diff markup ] identifier search ] general search ]