opti: memory: for loop stop iterate when not enough block is available
This commit is contained in:
parent
55037b75fa
commit
579b9ed349
@ -14,7 +14,7 @@ static uint32_t remaining_frames = MAX_FRAMES;
|
|||||||
|
|
||||||
static int32_t find_next_block(size_t nb_frames)
|
static int32_t find_next_block(size_t nb_frames)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 1; i < MAX_FRAMES; i++) {
|
for (uint32_t i = 1; i + nb_frames < MAX_FRAMES - 1; i++) {
|
||||||
uint32_t j;
|
uint32_t j;
|
||||||
for (j = 0; frame_table[i + j] == 0 && j < nb_frames; j++)
|
for (j = 0; frame_table[i + j] == 0 && j < nb_frames; j++)
|
||||||
;
|
;
|
||||||
|
@ -14,7 +14,7 @@ extern uint32_t page_table1[PT_SIZE];
|
|||||||
|
|
||||||
static int16_t find_next_block(size_t nb_pages)
|
static int16_t find_next_block(size_t nb_pages)
|
||||||
{
|
{
|
||||||
for (uint16_t i = 1; i < PT_SIZE - 1; i++) {
|
for (uint16_t i = 1; i + nb_pages < PT_SIZE - 1; i++) {
|
||||||
uint16_t j;
|
uint16_t j;
|
||||||
for (j = 0; page_table1[i + j] >> 12 == i + j && j < nb_pages;
|
for (j = 0; page_table1[i + j] >> 12 == i + j && j < nb_pages;
|
||||||
j++)
|
j++)
|
||||||
|
Loading…
Reference in New Issue
Block a user