Skip to content

Commit

Permalink
闲置任务
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Apr 26, 2016
1 parent 96ece33 commit b9768c4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 17_day/bootpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void HariMain(void)
task_b[i]->tss.fs = 1 * 8;
task_b[i]->tss.gs = 1 * 8;
*((int *) (task_b[i]->tss.esp + 4)) = (int) sht_win_b[i];
task_run(task_b[i], 2, i + 1);
/* task_run(task_b[i], 2, i + 1); */
}

/* sht_win */
Expand Down
25 changes: 23 additions & 2 deletions 17_day/mtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,21 @@ void task_switchsub(void)
return;
}

void task_idle(void)
{
for (;;) {
io_hlt();
}
}

struct TASK *task_init(struct MEMMAN *memman)
{
int i;
struct TASK *task;
struct TASK *task, *idle;
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
taskctl = (struct TASKCTL *) memman_alloc_4k(memman, sizeof (struct TASKCTL));


taskctl = (struct TASKCTL *) memman_alloc_4k(memman, sizeof (struct TASKCTL));
for (i = 0; i < MAX_TASKS; i++) {
taskctl->tasks0[i].flags = 0;
taskctl->tasks0[i].sel = (TASK_GDT0 + i) * 8;
Expand All @@ -80,6 +88,7 @@ struct TASK *task_init(struct MEMMAN *memman)
taskctl->level[i].running = 0;
taskctl->level[i].now = 0;
}

task = task_alloc();
task->flags = 2; /*活动中标志*/
task->priority = 2; /* 0.02秒*/
Expand All @@ -89,6 +98,18 @@ struct TASK *task_init(struct MEMMAN *memman)
load_tr(task->sel);
task_timer = timer_alloc();
timer_settime(task_timer, task->priority);

idle = task_alloc();
idle->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024;
idle->tss.eip = (int) &task_idle;
idle->tss.es = 1 * 8;
idle->tss.cs = 2 * 8;
idle->tss.ss = 1 * 8;
idle->tss.ds = 1 * 8;
idle->tss.fs = 1 * 8;
idle->tss.gs = 1 * 8;
task_run(idle, MAX_TASKLEVELS - 1, 1);

return task;
}

Expand Down

0 comments on commit b9768c4

Please sign in to comment.