Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/sched/sched.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef _SCHED_H_
0019 #define _SCHED_H_
0020 
0021 #include "kernel.h"
0022 #include "arch/i386-percpu.h"
0023 #include "sched/sched-defs.h"
0024 
0025 extern void runqueue_append (uint32 prio, uint16 selector);
0026 extern void queue_append (uint16 * queue, uint16 selector);
0027 extern uint16 queue_remove_head (uint16 * queue);
0028 extern void (*schedule) (void);
0029 extern void (*wakeup) (uint16);
0030 extern void wakeup_queue (uint16 *);
0031 
0032 extern void sched_usleep (uint32);
0033 extern void process_sleepqueue (void);
0034 
0035 extern DEF_PER_CPU (task_id, current_task);
0036 static inline task_id
0037 str (void)
0038 {
0039   return percpu_read (current_task);
0040 }
0041 static inline void
0042 ltr (task_id id)
0043 {
0044   percpu_write (current_task, id);
0045 }
0046 
0047 static inline void
0048 software_context_switch (task_id next)
0049 {
0050   u16 tr = percpu_read (current_task);
0051   tss *cur_TSS = (tr == 0 ? NULL : (tss *) lookup_TSS (tr));
0052   tss *nxt_TSS = (tss *) lookup_TSS (next);
0053 
0054   percpu_write (current_task, next);
0055 
0056   asm volatile ("call _sw_jmp_task":
0057                 :"S" (cur_TSS), "D" (nxt_TSS)
0058                 :"eax", "ebx", "ecx", "edx");
0059 }
0060 
0061 
0062 #endif
0063 
0064 /*
0065  * Local Variables:
0066  * indent-tabs-mode: nil
0067  * mode: C
0068  * c-file-style: "gnu"
0069  * c-basic-offset: 2
0070  * End:
0071  */
0072 
0073 /* vi: set et sw=2 sts=2: */