12 SCHED_PRIORITY_INTERRUPT
,
58 SwitchToTaskStack(void)
70 typedef struct _DFCArgs
{
77 typedef void (*DFCFcn
)(DFCArgs
);
89 RunDFC(DFCFcn fcn
, DFCArgs args
)
96 * This is only called from the timer interrupt. As it doesn't
97 * return, it's necessary to unmask the timer IRQ prior to switching
102 TaskSchedule(uint64 timerIrq
)
113 sti(); // timer irq is still masked
115 for (dfc
= dfcHead
; dfc
!= NULL
; dfc
= dfcHead
) {
118 RunDFC(dfc
->fcn
, dfc
->args
);
124 * Run regular tasks now.
130 UnmaskPIC(timerIrq
- IRQBASE
);
131 SwitchToTask(); // executes an iretq
135 typedef void (*Task
)(void);
141 * Allocate new stack.
155 * Hook TaskSchedule into the timer interrupt.
165 * Create a deferred function call. This DFC is placed on the
166 * runqueue of the specified priority and, once scheduled, is
167 * passed the appropriate args.
169 * DFCs run synchronously on the stack of the scheduler which
170 * makes them especially convenient for IRQ/fault handling.
172 * The DFCArgs that is passed
176 Defer(SchedPriority p
, DFCFcn dfc
, DFCArgs
*args
)