release_frames() finished. moving on to debugging.

This commit is contained in:
Alex 2017-06-19 11:23:36 -05:00
parent e655168599
commit 2d02f6f0fa

View file

@ -187,7 +187,7 @@ ContFramePool::ContFramePool(unsigned long _base_frame_no,
while(c < n_info_frames) while(c < n_info_frames)
{ {
bitmap[i] = bitmap[i] ^ mask; bitmap[i] = bitmap[i] ^ mask;
if(mask == 0x00) if(mask == 0x02)
{ {
i++; i++;
mask = 0xC0; mask = 0xC0;
@ -230,7 +230,7 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
// 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)
{ {
if(mask != 0x00) if(mask != 0x02)
{ {
j++; j++;
mask >> 2; mask >> 2;
@ -250,7 +250,7 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
c++; c++;
while(c < _n_frames) while(c < _n_frames)
{ {
if(mask != 0x00) if(mask != 0x02)
{ {
mask >> 2; mask >> 2;
} }
@ -289,7 +289,7 @@ 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)
{ {
if(mask != 0x00) if(mask != 0x02)
{ {
mask >> 2; mask >> 2;
} }
@ -335,12 +335,28 @@ void ContFramePool::mark_inaccessible(unsigned long _frame_no)
nFreeFrames--; nFreeFrames--;
} }
void ContFramePool::release_frames(unsigned long _frame_no)
void ContFramePool::release_frames(unsigned long _first_frame_no)
{ {
unsigned int i = 0;
while(i < pools.size())
{
if(_frame_no < pools[i].base_frame_no || _frame_no > (pools[i].base_frame_no + pools[i].nframes))
{
i++;
}
else
{
pools[i].release_frames_here(_frame_no);
return;
}
}
// This is the case where we fail to find the frame in any of the pools.
assert(false);
}
// Find a way to find which pool has this frame. void ContFramePool::release_frames_here(unsigned long _first_frame_no)
{
unsigned char * bitmap = this->bitmap;
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;
@ -352,12 +368,27 @@ void ContFramePool::release_frames(unsigned long _first_frame_no)
} }
bitmap[bitmap_index] ^= mask; bitmap[bitmap_index] ^= mask;
nFreeFrames++; nFreeFrames++;
if(mask != 0x02)
{
mask >> 2;
}
else
{
mask = 0x80;
bitmap_index++;
}
while(bitmap[bitmap_index] & mask == 0 && (bitmap[bitmap_index] & (mask >> 1)) == 0)
{
bitmap[bitmap_index] ^= mask;
bitmap[bitmap_index] ^= (mask >> 1);
nFreeFrames++;
}
} }
unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames) unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames)
{ {
// TODO: IMPLEMENTATION NEEEDED! return _n_frames / (FRAME_SIZE * 4);
assert(false);
} }