This repository has been archived by the owner on Nov 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queue.h
97 lines (72 loc) · 2.11 KB
/
Queue.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#pragma once
#ifndef _QUEUE_H_
#define _QUEUE_H_
//#include "base.c" This line must be DELETED
#include "global.h"
#include "z502.h"
#include "syscalls.h"
#include "DiskManagement.h"
#include <stdlib.h>
//
#define DO_LOCK 1
#define DO_UNLOCK 0
#define SUSPEND_UNTIL_LOCKED TRUE
#define DO_NOT_SUSPEND FALSE
#define TERMINATED 1
#define DISK_WRITE 1
#define DISK_READ 2
typedef struct
{
long processID;
long priority;
char name[20];
long address;
long wakeUpTime;
void *context;
//Disk Data
long DiskID;
long Sector;
long disk_buffer_write;
long disk_buffer_read;
int DiskStatus;
char disk_buffer_write_new[16];
char disk_buffer_read_new[16];
long* PageTable; //mmio.Field3
DISK_DATA Disk_data_written;
DISK_DATA Disk_data_read;
//Current Directory
Header CurrentDirectory;
}PCB;
typedef struct node
{
PCB PCBdata;
long time;
long pid;
int priority;
char name[20];
INT32 wakeuptime;
//MMIO for each process , use long type because the definition are using the long type
void *context; // mmio.Field1, it should be a context pointer, not a definite data type
long ContextID; //mmio.Field1
long ContextAddress; //mmio.Field2
void *PageTable; //mmio.Field3, used in the second half of the project
//Disk Read and Write
struct node *next;
}Node, *PCBNode;
typedef struct
{
PCBNode front;
PCBNode rear;
int size;
}PCBQueue;
// on the following is the definition of the Disk Queue
PCBQueue *initialQueue();
PCBNode EnQueueByPriority(PCBQueue *queue, PCB *pcb);
INT32 IsEmpty(PCBQueue *queue);
PCBNode EnQueueByWakeUpTime(PCBQueue *queue, PCB *pcb);
PCBNode DeQueueFirstElement(PCBQueue *queue);
PCBNode DeQueueByName(PCBQueue *queue,PCB *pcb);
void TerminateSelf(PCBQueue *queue, PCB *pcb);
//On the following is the operation of the Queue
#endif // !_QUEUE_H_