-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataStructure.h
64 lines (54 loc) · 1.19 KB
/
DataStructure.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
#pragma once
#include<iostream>
#include<math.h>
using std::string;
#define MAXKVAL 16 //内存块最大级数
#define DEVICENUM 100
#define WAITINGQUEUE_SPEED 2
#define ENJOINGQUEUE_SPEED 1 //就绪队列优先级变化速度,以时间片为基本单位
//总内存
struct Memory {
int Size;
int SystemAreaSize;
int UserAreaSize;
};
//内存块
struct Block {//初始状态的Block左右指针指向自己
int kval;//级数
struct Block* rlink;
struct Block* llink;
int address;
};
enum State {
CREATED,
REDEAY,
OBSTRUCTED
};
struct RunInfo {
double RequireTime; //总共需要的时间
double OccupyTime; //占用CPU的时间
double DeviceRunInfo[2][DEVICENUM];
//0表示设备总共需要时间,1表示设备开始使用时间
};
struct PCB {
int PID;
string PName;
string UserID;
enum State State;
int Priority;
int StartAdd;
struct RunInfo PRunInfo; //进程运行信息描述
int size;
struct Block* PBlock;
struct PCB* next;
};
//PCB队列
typedef struct {
struct PCB* front;
struct PCB* rear;
}PCB_Queue;
struct interrupt {
int semaphore;
int DeviceNo;
double OccupyTime;
};