From 83e17e29456ec9b6d45f4d9f2634eb280c6f414f Mon Sep 17 00:00:00 2001 From: stefan Date: Wed, 19 Apr 2023 20:50:10 -0400 Subject: ticket locks --- sys/kern/mm/kalloc.c | 66 ---------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 sys/kern/mm/kalloc.c (limited to 'sys/kern/mm') diff --git a/sys/kern/mm/kalloc.c b/sys/kern/mm/kalloc.c deleted file mode 100644 index bfd4f3f..0000000 --- a/sys/kern/mm/kalloc.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include -#include -#include - -extern uint64_t HEAP_START; - -typedef struct freenode { - struct freenode *next; -} freenode_t; - -freenode_t *head = NULL; - -void * -kalloc(void) -{ - freenode_t *p = head; - - if (p == NULL) - return NULL; - - head = p->next; - return p; -} - -void * -kzalloc(void) -{ - freenode_t *p = kalloc(); - memset(p, 0, PAGE_SIZE); - return p; -} - -void -kfree(void *p) -{ - if (p == NULL) - return; - - freenode_t *tmp = head; - head = p; - head->next = tmp; -} - -void -kalloc_init(void) -{ - freenode_t *p = (freenode_t*)HEAP_START; - for (;(unsigned long)p + PAGE_SIZE <= (HEAP_START + 0x100000); p += PAGE_SIZE) { - kfree(p); - } -} - -void -walkfree(void) -{ - freenode_t *node = head; - int nfree = 0; - while (node) { - printf("freenode at %p\n", node); - node = node->next; - nfree++; - } - printf("found and printed %d free pages!\n", nfree); -} -- cgit v1.2.3