Warning, cross-references for /kernel/sched/sched.c need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "arch/i386.h"
0019 #include "arch/i386-percpu.h"
0020 #include "kernel.h"
0021 #include "smp/smp.h"
0022 #include "smp/apic.h"
0023 #include "util/debug.h"
0024 #include "sched/sched.h"
0025
0026 #define QUEST_SCHED vcpu
0027
0028
0029 #ifdef DEBUG_SCHED
0030 #define DLOG(fmt,...) DLOG_PREFIX("sched",fmt,##__VA_ARGS__)
0031 #else
0032 #define DLOG(fmt,...) ;
0033 #endif
0034
0035
0036 uint8 sched_enabled = 0;
0037
0038
0039 extern void
0040 queue_append (uint16 * queue, uint16 selector)
0041 {
0042
0043 quest_tss *tssp;
0044
0045 if (*queue) {
0046 if (*queue == selector)
0047 return;
0048
0049 for (tssp = lookup_TSS (*queue); tssp->next; tssp = lookup_TSS (tssp->next))
0050 if (tssp->next == selector)
0051
0052 return;
0053
0054
0055 tssp->next = selector;
0056
0057 } else
0058 *queue = selector;
0059
0060 tssp = lookup_TSS (selector);
0061 tssp->next = 0;
0062
0063 }
0064
0065 extern uint16
0066 queue_remove_head (uint16 * queue)
0067 {
0068
0069 quest_tss *tssp;
0070 uint16 head;
0071
0072 if (!(head = *queue))
0073 return 0;
0074
0075 tssp = lookup_TSS (head);
0076
0077 *queue = tssp->next;
0078
0079 return head;
0080 }
0081
0082 extern void
0083 wakeup_queue (uint16 * q)
0084 {
0085 uint16 head;
0086
0087 while ((head = queue_remove_head (q)))
0088 wakeup (head);
0089 }
0090
0091
0092
0093 DEF_PER_CPU (u16, current_task);
0094 INIT_PER_CPU (current_task) {
0095 percpu_write (current_task, 0);
0096 }
0097
0098
0099
0100 #define ___glue(a,b) a##b
0101 #define __glue(a,b) ___glue(a,b)
0102 #define S __glue(QUEST_SCHED,_schedule)
0103 #define W __glue(QUEST_SCHED,_wakeup)
0104 extern void S (void);
0105 void (*schedule) (void) = S;
0106 extern void W (uint16);
0107 void (*wakeup) (uint16) = W;
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118