Permalink
Browse files

Part 6, Putting processes to sleep

  • Loading branch information...
singpolyma committed Aug 16, 2012
1 parent 43a43fa commit 762bbd0ed64d7d7c9c349a901c8052471fef448a
Showing with 8 additions and 2 deletions.
  1. +8 −2 kernel.c
View
@@ -26,6 +26,10 @@ void task(void) {
while(1);
}
#define TASK_READY 0
#define TASK_WAIT_READ 1
#define TASK_WAIT_WRITE 2
void first(void) {
bwputs("In user mode 1\n");
if(!fork()) task();
@@ -60,6 +64,7 @@ int main(void) {
while(1) {
tasks[current_task] = activate(tasks[current_task]);
tasks[current_task][-1] = TASK_READY;
switch(tasks[current_task][2+7]) {
case 0x1: /* fork */
@@ -91,8 +96,9 @@ int main(void) {
}
}
current_task++;
if(current_task >= task_count) current_task = 0;
/* Select next TASK_READY task */
while(TASK_READY != tasks[current_task =
(current_task+1 >= task_count ? 0 : current_task+1)][-1]);
}
return 0;

0 comments on commit 762bbd0

Please sign in to comment.