-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffer.h
54 lines (45 loc) · 1.16 KB
/
buffer.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
#pragma once
#include<unordered_map>
#include<vector>
using namespace std;
class bufferHeader{
public :
// bock_number of data on disk
int blk_num;
// device_number specify the file system (for this program device_num = 1)
int device_num;
/*
status :
0 - locked
1 - unlocked
2 - valid data
3 - delayed-write
4 - kernel is reading/writing
5 - process is waiting
*/
int status;
bufferHeader(int bnum, int dnum, int sts){
blk_num = bnum;
device_num = dnum;
status = sts;
}
bufferHeader(){}
};
void init();
//---------------HashQueue functions---------
void addToHQ(int blk_num,int dNum,int status);
bool searchHQ(int blk_num);
int getStatus(int blk_num);
void setStatus(int blk_num, int sts);
void displayHQ();
void deleteFromHQ(int blk_num);
bool emptyHQ();
//---------------Freelist functions---------
void addToHeadFL(int blk_num,int dNum,int status);
void addToTailFL(int blk_num,int dNum,int status);
bool searchFL(int blk_num);
bufferHeader deleteToheadFL();
bufferHeader getHeadToFL();
bufferHeader deleteAnyPositionFL(int blk_num);
void displayFL();
bool emptyFL();