-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe_pool.H
executable file
·89 lines (69 loc) · 3.14 KB
/
frame_pool.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
/*
File: frame_pool.H
Author: R. Bettati
Department of Computer Science
Texas A&M University
Date : 09/03/05
Description: Management of the Free-Frame Pool.
*/
#ifndef _FRAME_POOL_H_ // include file only once
#define _FRAME_POOL_H_
/*--------------------------------------------------------------------------*/
/* DEFINES */
/*--------------------------------------------------------------------------*/
#define MB * (0x1 << 20)
#define KB * (0x1 << 10)
#define START_OFFSET ((2 MB) / (4 KB))
/*--------------------------------------------------------------------------*/
/* INCLUDES */
/*--------------------------------------------------------------------------*/
/* -- (none) -- */
/*--------------------------------------------------------------------------*/
/* DATA STRUCTURES */
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* F r a m e P o o l */
/*--------------------------------------------------------------------------*/
class FramePool {
private:
/* -- DEFINE YOUR FRAME POOL DATA STRUCTURE(s) HERE. */
unsigned long base_frame_number;
unsigned long number_of_frames_managed;
unsigned long managament_frame_number;
/*
* Since dynamic allocation is not possible now, we create an array of frame structures for
* holding the free frames*/
static unsigned long* frame_map;
public:
static const unsigned int FRAME_SIZE = 4096;
/* Size of a frame in bytes */
FramePool(unsigned long _base_frame_no,
unsigned long _nframes,
unsigned long _info_frame_no);
/* Initializes the data structures needed for the management of this
frame pool. This function must be called before the paging system
is initialized.
_base_frame_no is the frame number at the start of the physical memory
region that this frame pool manages.
_nframes is the number of frames in the physical memory region that this
frame pool manages.
e.g. If _base_frame_no is 16 and _nframes is 4, this frame pool manages
physical frames numbered 16, 17, 18 and 19
_info_frame_no is the frame number (within the directly mapped region) of
the frame that should be used to store the management information of the
frame pool. However, if _info_frame_no is 0, the frame pool is free to
choose any frame from the pool to store management information.
*/
unsigned long get_frame();
/* Allocates a frame from the frame pool. If successful, returns the frame
* number of the frame. If fails, returns 0. */
void mark_inaccessible(unsigned long _base_frame_no,
unsigned long _nframes);
/* Mark the area of physical memory as inaccessible. The arguments have the
* same semanticas as in the constructor.
*/
static void release_frame(unsigned long _frame_no);
/* Releases frame back to the given frame pool.
The frame is identified by the frame number. */
};
#endif