PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include <stddef.h>
Go to the source code of this file.
Enumerations | |
enum | palloc_flags { PAL_ASSERT = 001 , PAL_ZERO = 002 , PAL_USER = 004 } |
How to allocate pages. More... | |
Functions | |
void | palloc_init (size_t user_page_limit) |
Initializes the page allocator. More... | |
void * | palloc_get_page (enum palloc_flags) |
Obtains a single free page and returns its kernel virtual address. More... | |
void * | palloc_get_multiple (enum palloc_flags, size_t page_cnt) |
Obtains and returns a group of PAGE_CNT contiguous free pages. More... | |
void | palloc_free_page (void *) |
Frees the page at PAGE. More... | |
void | palloc_free_multiple (void *, size_t page_cnt) |
threads/palloc.h More... | |
enum palloc_flags |
void palloc_free_multiple | ( | void * | pages, |
size_t | page_cnt | ||
) |
Definition at line 118 of file palloc.c.
References ASSERT, pool::base, bitmap_all(), bitmap_set_multiple(), memset(), NOT_REACHED, NULL, page_from_pool(), pg_no(), pg_ofs(), PGSIZE, pool::used_map, and user_pool.
Referenced by free(), and palloc_free_page().
void palloc_free_page | ( | void * | page | ) |
Frees the page at PAGE.
Definition at line 146 of file palloc.c.
References palloc_free_multiple().
Referenced by free(), fsutil_cat(), load_segment(), pagedir_destroy(), process_execute(), setup_stack(), start_process(), and thread_schedule_tail().
void * palloc_get_multiple | ( | enum palloc_flags | flags, |
size_t | page_cnt | ||
) |
Obtains and returns a group of PAGE_CNT contiguous free pages.
If PAL_USER is set, the pages are obtained from the user pool, otherwise from the kernel pool. If PAL_ZERO is set in FLAGS, then the pages are filled with zeros. If too few pages are available, returns a null pointer, unless PAL_ASSERT is set in FLAGS, in which case the kernel panics.
Definition at line 71 of file palloc.c.
References pool::base, BITMAP_ERROR, bitmap_scan_and_flip(), pool::lock, lock_acquire(), lock_release(), memset(), NULL, PAL_ASSERT, PAL_USER, PAL_ZERO, PANIC, PGSIZE, pool::used_map, and user_pool.
Referenced by malloc(), and palloc_get_page().
void * palloc_get_page | ( | enum palloc_flags | flags | ) |
Obtains a single free page and returns its kernel virtual address.
If PAL_USER is set, the page is obtained from the user pool, otherwise from the kernel pool. If PAL_ZERO is set in FLAGS, then the page is filled with zeros. If no pages are available, returns a null pointer, unless PAL_ASSERT is set in FLAGS, in which case the kernel panics.
Definition at line 111 of file palloc.c.
References palloc_get_multiple().
Referenced by fsutil_cat(), load_segment(), lookup_page(), malloc(), pagedir_create(), paging_init(), process_execute(), setup_stack(), thread_create(), and tss_init().
void palloc_init | ( | size_t | user_page_limit | ) |
Initializes the page allocator.
At most USER_PAGE_LIMIT pages are put into the user pool.
Definition at line 46 of file palloc.c.
References init_pool(), init_ram_pages, PGSIZE, ptov(), user_page_limit, and user_pool.
Referenced by pintos_init().