Test completes. The source of my frustration was moving pools[nPools] = *this to the end of the constructor.
This commit is contained in:
parent
e8bb8088a7
commit
00c5f4867f
3 changed files with 5 additions and 28 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@ Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
|
||||||
DevEnv/
|
DevEnv/
|
||||||
*.o
|
*.o
|
||||||
*.bin
|
*.bin
|
||||||
|
dev_kernel_grub.img
|
||||||
|
bochsout.txt
|
||||||
|
|
|
@ -149,9 +149,6 @@ ContFramePool::ContFramePool(unsigned long _base_frame_no,
|
||||||
info_frame_no = _info_frame_no;
|
info_frame_no = _info_frame_no;
|
||||||
n_info_frames = _n_info_frames;
|
n_info_frames = _n_info_frames;
|
||||||
|
|
||||||
pools[nPools] = *this;
|
|
||||||
nPools += 1;
|
|
||||||
|
|
||||||
// If _info_frame_no is zero then we keep management info in the first
|
// If _info_frame_no is zero then we keep management info in the first
|
||||||
// frame(s), else we use the provided frame(s) to keep management info
|
// frame(s), else we use the provided frame(s) to keep management info
|
||||||
// NOTE: bitmap needs to be allocated with n_info_frames if specified.
|
// NOTE: bitmap needs to be allocated with n_info_frames if specified.
|
||||||
|
@ -205,6 +202,9 @@ ContFramePool::ContFramePool(unsigned long _base_frame_no,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pools[nPools] = *this;
|
||||||
|
nPools += 1;
|
||||||
|
|
||||||
Console::puts("Frame Pool initialized\n");
|
Console::puts("Frame Pool initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,16 +229,10 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
//Console::puts("Entered first loop");
|
|
||||||
unsigned char mask = 0x80 >> (j*2);
|
unsigned char mask = 0x80 >> (j*2);
|
||||||
// check every 2 bits for a free frame in the bitmap
|
// check every 2 bits for a free frame in the bitmap
|
||||||
while((mask & bitmap[i]) == 0 || ((mask >> 1) & bitmap[i]) == 0)
|
while((mask & bitmap[i]) == 0 || ((mask >> 1) & bitmap[i]) == 0)
|
||||||
{
|
{
|
||||||
//Console::puti(i);
|
|
||||||
//Console::puts("\n");
|
|
||||||
//Console::puti(j);
|
|
||||||
//Console::puts("\n");
|
|
||||||
//Console::puts("Entered second loop");
|
|
||||||
if(mask != 0x02)
|
if(mask != 0x02)
|
||||||
{
|
{
|
||||||
j++;
|
j++;
|
||||||
|
@ -256,7 +250,6 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||||
c++;
|
c++;
|
||||||
while(c < _n_frames)
|
while(c < _n_frames)
|
||||||
{
|
{
|
||||||
//Console::puts("Entered sequence check");
|
|
||||||
if(mask != 0x02)
|
if(mask != 0x02)
|
||||||
{
|
{
|
||||||
mask = mask >> 2;
|
mask = mask >> 2;
|
||||||
|
@ -294,7 +287,6 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||||
unsigned int temp = i;
|
unsigned int temp = i;
|
||||||
while(c < _n_frames)
|
while(c < _n_frames)
|
||||||
{
|
{
|
||||||
//Console::puts("Entered bitmap update");
|
|
||||||
if(mask != 0x02)
|
if(mask != 0x02)
|
||||||
{
|
{
|
||||||
mask = mask >> 2;
|
mask = mask >> 2;
|
||||||
|
@ -362,19 +354,9 @@ void ContFramePool::release_frames_here(unsigned long _first_frame_no)
|
||||||
{
|
{
|
||||||
unsigned char * bitmap = this->bitmap;
|
unsigned char * bitmap = this->bitmap;
|
||||||
|
|
||||||
Console::puti(_first_frame_no);
|
|
||||||
Console::puts("\n");
|
|
||||||
Console::puti(base_frame_no);
|
|
||||||
|
|
||||||
unsigned int bitmap_index = (_first_frame_no - base_frame_no) / 4;
|
unsigned int bitmap_index = (_first_frame_no - base_frame_no) / 4;
|
||||||
unsigned char mask = 0x80 >> ((_first_frame_no - base_frame_no) % 4) * 2;
|
unsigned char mask = 0x80 >> ((_first_frame_no - base_frame_no) % 4) * 2;
|
||||||
|
|
||||||
//
|
|
||||||
Console::puts("\n");
|
|
||||||
Console::puti(bitmap[bitmap_index]);
|
|
||||||
Console::puts("\n");
|
|
||||||
Console::puti(bitmap[bitmap_index + 1]);
|
|
||||||
//
|
|
||||||
if(!((bitmap[bitmap_index] & mask) == 0 && (bitmap[bitmap_index] & (mask >> 1)) != 0))
|
if(!((bitmap[bitmap_index] & mask) == 0 && (bitmap[bitmap_index] & (mask >> 1)) != 0))
|
||||||
{
|
{
|
||||||
if((bitmap[bitmap_index] & mask) != 0 && (bitmap[bitmap_index] & (mask >> 1)) != 0)
|
if((bitmap[bitmap_index] & mask) != 0 && (bitmap[bitmap_index] & (mask >> 1)) != 0)
|
||||||
|
@ -401,11 +383,6 @@ void ContFramePool::release_frames_here(unsigned long _first_frame_no)
|
||||||
|
|
||||||
while(bitmap[bitmap_index] & mask == 0 && (bitmap[bitmap_index] & (mask >> 1)) == 0)
|
while(bitmap[bitmap_index] & mask == 0 && (bitmap[bitmap_index] & (mask >> 1)) == 0)
|
||||||
{
|
{
|
||||||
Console::puts("\n");
|
|
||||||
Console::puti(bitmap_index);
|
|
||||||
Console::puts("\n");
|
|
||||||
Console::puti(mask);
|
|
||||||
Console::puts("\n");
|
|
||||||
bitmap[bitmap_index] ^= mask;
|
bitmap[bitmap_index] ^= mask;
|
||||||
bitmap[bitmap_index] ^= (mask >> 1);
|
bitmap[bitmap_index] ^= (mask >> 1);
|
||||||
if(mask != 0x02)
|
if(mask != 0x02)
|
||||||
|
|
|
@ -110,8 +110,6 @@ void test_memory(ContFramePool * _pool, unsigned int _allocs_to_go) {
|
||||||
Console::puts("alloc_to_go = "); Console::puti(_allocs_to_go); Console::puts("\n");
|
Console::puts("alloc_to_go = "); Console::puti(_allocs_to_go); Console::puts("\n");
|
||||||
if (_allocs_to_go > 0) {
|
if (_allocs_to_go > 0) {
|
||||||
int n_frames = _allocs_to_go % 4 + 1;
|
int n_frames = _allocs_to_go % 4 + 1;
|
||||||
Console::puti(n_frames);
|
|
||||||
Console::puts("\n");
|
|
||||||
unsigned long frame = _pool->get_frames(n_frames);
|
unsigned long frame = _pool->get_frames(n_frames);
|
||||||
int * value_array = (int*)(frame * (4 KB));
|
int * value_array = (int*)(frame * (4 KB));
|
||||||
for (int i = 0; i < (1 KB) * n_frames; i++) {
|
for (int i = 0; i < (1 KB) * n_frames; i++) {
|
||||||
|
|
Reference in a new issue