The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/run_queues.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993-1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon 
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        run_queues.h,v $
   29  * Revision 2.2  93/11/17  17:20:32  dbg
   30  *      Removed rq_rank (unused).
   31  *      [93/08/18            dbg]
   32  * 
   33  *      Processor set now has one run queue structure per scheduling
   34  *      policy.  The actual run queues are policy-specific.
   35  *      [93/04/06            dbg]
   36  * 
   37  *      Moved run queue definitions here from kern/sched.h.
   38  *      [93/01/12            dbg]
   39  * 
   40  */
   41 
   42 /*
   43  *      File:   kern/run_queues.h
   44  *      Original Author: Avadis Tevanian, Jr.
   45  *      Date:   1986
   46  *
   47  *      Run queues.
   48  */
   49 
   50 #ifndef _KERN_RUN_QUEUES_H_
   51 #define _KERN_RUN_QUEUES_H_
   52 
   53 #include <cpus.h>
   54 
   55 #include <mach/policy.h>
   56 
   57 #include <kern/kern_types.h>            /* thread_t, processor_t */
   58 #include <kern/queue.h>
   59 #include <kern/lock.h>
   60 #include <kern/macro_help.h>
   61 
   62 /*
   63  *      Each processor set has a prioritized list of run queues,
   64  *      one for each scheduling policy enabled on the processor
   65  *      set.  The run queue structure may vary according to the
   66  *      scheduling policy.  The common part of the structure
   67  *      holds a count of runnable threads and a pointer to the
   68  *      scheduling policy itself.  The head of the run queue holds
   69  *      the lock for all of the run queues, and an array of per-
   70  *      policy run queues.
   71  */
   72 
   73 struct run_queue {
   74         struct sched_policy *   rq_policy;      /* scheduling policy */
   75         int                     rq_count;       /* count of runnable threads */
   76 };
   77 
   78 typedef struct run_queue        *run_queue_t;
   79 #define RUN_QUEUE_NULL  ((run_queue_t) 0)
   80 
   81 /*
   82  *      Private data follows the common run_queue structure.
   83  */
   84 #define rq_private(rq)          ((void *)((rq) + 1))
   85 
   86 /*
   87  *      The run queue list is headed by a run_queue_head structure.
   88  *      It contains the lock for all of the run queues, a count of
   89  *      the total number of runnable threads in all of the queues,
   90  *      and pointers to the per-policy run queues.  
   91  */
   92 #define NUM_POLICIES            (8)             /* configurable! */
   93 
   94 struct run_queue_head {
   95         run_queue_t             runqs[NUM_POLICIES];
   96         int                     last;
   97         int                     count;
   98         decl_simple_lock_data(, lock)
   99 };
  100 typedef struct run_queue_head   *run_queue_head_t;
  101 #define RUN_QUEUE_HEAD_NULL     ((run_queue_head_t) 0)
  102 
  103 /*
  104  *      Initialization
  105  */
  106 #define run_queue_init(runq, policy) \
  107     MACRO_BEGIN \
  108         (runq)->rq_policy = (policy); \
  109         (runq)->rq_count  = 0; \
  110     MACRO_END
  111 
  112 /*
  113  *      Run queue head initialization and termination
  114  */
  115 extern void
  116 run_queue_head_init(
  117         run_queue_head_t        runq);
  118 extern void
  119 run_queue_head_dealloc(
  120         run_queue_head_t        runq);
  121 
  122 /*
  123  *      Make thread runnable.
  124  */
  125 extern void thread_setrun(
  126         thread_t        thread,
  127         boolean_t       may_preempt);
  128 
  129 /*
  130  *      Find the next runnable thread on either the
  131  *      per-processor or the processor set`s collection
  132  *      of run queues.
  133  */
  134 extern thread_t
  135 thread_select(
  136         processor_t     processor);
  137 
  138 /*
  139  *      Pull a thread off its run queue.
  140  */
  141 extern run_queue_head_t
  142 rem_runq(thread_t       thread);
  143 
  144 /*
  145  *      Check whether the current thread should be
  146  *      preempted by a higher priority thread on the
  147  *      run queues.
  148  */
  149 extern boolean_t
  150 csw_needed(
  151         thread_t        thread,
  152         processor_t     processor);
  153 
  154 #if     NCPUS > 1
  155 /*
  156  *      Force a thread to execute on the specified processor.
  157  */
  158 extern void
  159 thread_bind(
  160         thread_t        thread,
  161         processor_t     processor);
  162 
  163 #endif  /* NCPUS > 1 */
  164 
  165 #endif  /* _KERN_RUN_QUEUES_H_ */

Cache object: 4cd2ebdb1068ad699d118878e92c137b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.