-
Notifications
You must be signed in to change notification settings - Fork 3
/
pcb.h
41 lines (33 loc) · 1.3 KB
/
pcb.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
#define RUNNING 0
#define READY 1
#define WAIT 2
#define TERMINATED 3
typedef struct
{
//int29 LDTBaseAddress;
segmentTableInfo* LDTPointer;
int pid;
int state;
FILE *LinearAddrInputFile;
FILE *SegNumAddrFile;
int4 GDTindex;
long long swapStartTime; // Time at which swapping starts when page fault occurs.
long long runTime; // Amount of time the process has spent executing in CPU.
int numContextSwitches;
int numPageFaults;
}
PCB;
//Initializes ADT of PCB and calls method to initialize LDT of the process
void initPCB(int pid, char* LinearAddrInputFileName, char* segInputFileName);
//Returns pid of the process
int getpid(PCB pcbObj);
//returns state of process
int getState(PCB pcbObj);
//Takes ADT of PCB and state as input and sets the process state
int setState(PCB* pcbObj, int state);
//Returns reference to level 3 page table given pid and segment number
pageTable* getLevel3PageTablePointer(PCB pcbObj,int segNum);
//Deallocates Process pages and page table
int deleteProcess(unsigned int pid);
//calculates the limit of both the gdt_segment and the ldt_segment of the process, and stores it in variables gdtSeg_limi, ldtSeg_limit respectively
void findSegmentLimits(int* gdtSeg_limit, int* ldtSeg_limit, FILE* LinearAddrInputFile, FILE* SegNumAddrInputFile);