From 4673d709e1774d4db6f11eb076ed7547d3103591 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 29 Nov 2023 22:14:09 -0500 Subject: [PATCH] mesa want you to work, so mesa can sleep... --- Part3/09_memory/kernel/kernel.c | 46 ++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/Part3/09_memory/kernel/kernel.c b/Part3/09_memory/kernel/kernel.c index c0a7c51..aafa88a 100644 --- a/Part3/09_memory/kernel/kernel.c +++ b/Part3/09_memory/kernel/kernel.c @@ -240,23 +240,57 @@ void begin_output_example() { static node* holes_head = NULL; holes_head = get_holes(umem_head); + // Display 1 kprint("Jonathan Turner - S02\n"); kprint("Current Allocation: \n"); print_memory(umem_head, holes_head); - umem_head = add_node( umem_head, 0x10000, 0x3FF, true, global_id++); - umem_head = add_node( umem_head, 0x11000, 0x1FF, true, global_id++); - umem_head = add_node( umem_head, 0x12000, 0x3FF, true, global_id++); - umem_head = add_node( umem_head, 0x15000, 0x7FF, true, global_id++); - umem_head = add_node( umem_head, 0x22000, 0x1FFF, true, global_id++); + umem_head = add_node( umem_head, 0x10000, 0x3FF, true, 0); + umem_head = add_node( umem_head, 0x11000, 0x1FF, true, 1); + umem_head = add_node( umem_head, 0x12000, 0x3FF, true, 2); + umem_head = add_node( umem_head, 0x15000, 0x7FF, true, 3); + umem_head = add_node( umem_head, 0x22000, 0x1FFF, true, 4); + + // Display 2 print_memory(umem_head, holes_head); node* temp = umem_head->next; free_node(umem_head); umem_head = temp; umem_head->previous = NULL; print_memory(umem_head, holes_head); + print_list(umem_head); + print_list(get_holes(umem_head)); + + // Display 3 temp = get_tail(umem_head); - temp->previous = NULL; free_node(temp); print_memory(umem_head, holes_head); + print_list(umem_head); + print_list(get_holes(umem_head)); + // Display 4 + umem_head = add_node( umem_head, 0x23000, 0x1FFF, true, 5); + umem_head = add_node( umem_head, 0x25000, 0x3FFF, true, 6); + print_memory(umem_head, holes_head); + print_list(umem_head); + print_list(get_holes(umem_head)); + + // Display 5 + temp = find_id(4); + node* previous = temp->previous; + previous->next = temp->next; + free_node(temp); + print_memory(umem_head, holes_head); + print_list(umem_head); + print_list(get_holes(umem_head)); + + // Display 6 + while (umem_head != NULL) { + temp = umem_head->next; + free_node(umem_head); + umem_head = temp; + } + print_memory(umem_head, holes_head); + print_list(umem_head); + print_list(get_holes(umem_head)); + kprint("Jonathan Turner - S02"); } \ No newline at end of file