-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dispatcher.c
49 lines (38 loc) · 1.07 KB
/
Dispatcher.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Dispatcher.c
*
* Created on: Oct 10, 2016
* Author: T440
*/
#include "global.h"
#include "syscalls.h"
#include "protos.h"
#include "string.h"
#include <stdlib.h>
#include <ctype.h>
#include "Process.h"
#include "Dispatcher.h"
#include "WasteTime.h"
void Dispatcher(){
MEMORY_MAPPED_IO mmio;
struct ready_PCB *runningPCB;
int runnningPID;
// runningPcb = FindCurrent(runningProcessPid);
runningPCB=Get_R_Head();
while(runningPCB==NULL) {
// if(GetHead(&pcb_timer_queue)!= NULL || GetHead(&pcb_disk_queue!=NULL)) {
// mmio.Mode=Z502Action;
// mmio.Field1=mmio.Field2=mmio.Field3=0;
// MEM_WRITE(Z502Idle, &mmio);
//
// }
CALL(WasteTime());
}
//pcb not null, start PCB if pcb is null call idle
runnningPID = runningPCB->pid;
Queue_R_Dequeue();
mmio.Mode = Z502StartContext;
mmio.Field1 =runningPCB->context.Field1;
mmio.Field2 = START_NEW_CONTEXT_AND_SUSPEND;
MEM_WRITE(Z502Context, &mmio);
}