-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPF_Manager.h
More file actions
79 lines (63 loc) · 1.64 KB
/
Copy pathPF_Manager.h
File metadata and controls
79 lines (63 loc) · 1.64 KB
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
#ifndef PF_MANAGER_H_H
#define PF_MANAGER_H_H
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <time.h>
#include <malloc.h>
#include <windows.h>
#include "RC.h"
#define PF_PAGE_SIZE ((1<<12)-4)
#define PF_FILESUBHDR_SIZE (sizeof(PF_FileSubHeader))
#define PF_BUFFER_SIZE 50//Ò³Ãæ»º³åÇøµÄ´óС
#define PF_PAGESIZE (1<<12)
typedef unsigned int PageNum;
typedef struct {
PageNum pageNum;
char pData[PF_PAGE_SIZE];
}Page;
typedef struct {
PageNum pageCount;
int nAllocatedPages;
}PF_FileSubHeader;
typedef struct {
bool bDirty;
unsigned int pinCount;
clock_t accTime;
char *fileName;
int fileDesc;
Page page;
}Frame;
typedef struct {
bool bopen;
char *fileName;
int fileDesc;
Frame *pHdrFrame;
Page *pHdrPage;
char *pBitmap;
PF_FileSubHeader *pFileSubHeader;
}PF_FileHandle;
typedef struct {
int nReads;
int nWrites;
Frame frame[PF_BUFFER_SIZE];
bool allocated[PF_BUFFER_SIZE];
}BF_Manager;
typedef struct {
bool bOpen;
Frame *pFrame;
}PF_PageHandle;
const RC CreateFile(const char *fileName);
const RC openFile(char *fileName, PF_FileHandle *fileHandle);
const RC CloseFile(PF_FileHandle *fileHandle);
const RC GetThisPage(PF_FileHandle *fileHandle, PageNum pageNum, PF_PageHandle *pageHandle);
const RC AllocatePage(PF_FileHandle *fileHandle, PF_PageHandle *pageHandle);
const RC GetPageNum(PF_PageHandle *pageHandle, PageNum *pageNum);
const RC GetData(PF_PageHandle *pageHandle, char **pData);
const RC DisposePage(PF_FileHandle *fileHandle, PageNum pageNum);
const RC MarkDirty(PF_PageHandle *pageHandle);
const RC UnpinPage(PF_PageHandle *pageHandle);
#endif