Cooperative Multitasking: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m actually fix grammAr (how ironic)
Zesterer (talk | contribs)
This is co-operative multi-tasking, not pre-emptive. Changed references to "preempt" to "yield".
Line 2:
{{In_Progress}}
 
In this tutorial, we'll cover the creation of a co-operative (not pre-emptive) kernel-level multitasking system. That is, kernel threads and processes. The code here is specific to the IA-32 architecture.
 
== Requirements ==
Line 29:
extern void createTask(Task*, void(*)(), uint32_t, uint32_t*);
 
extern void preemptyield(); // Switch task frontend
extern void switchTask(Registers *old, Registers *new); // The function which actually switches
 
Line 36:
 
== ''task.c'' ==
This file defines the actual wrappers that ''switchTask()'' uses, ''createTask()'' and ''preemptyield()'':
<source lang="c">
#include "task.h"
Line 46:
static void otherMain() {
printk("Hello multitasking world!"); // Not implemented here...
preemptyield();
}
 
Line 75:
}
 
void preemptyield() {
Task *last = runningTask;
runningTask = runningTask->next;
Line 148:
void doIt() {
printk("Switching to otherTask... \n");
preemptyeild();
printk("Returned to mainTask!\n");
}