2
Which kernel memory routine(s) would i use for --> 1) Allocating memory in an interrupt handler ? The kernel memory routine would be kmem_malloc(). It allocates wired-down memory in the kernel's address map.This routine has 2 important components-- >a private kernel submap (kmem_map) and an object(kmem_object). 2) Allocating memory at a fixed address ? The kernel memory routine would be kmem_alloc().It is used to all ocate wired memory in the kernel's address map or a submap..It will return a failure if no address space is available in indicated map.It may block if insufficient physical memory is available . 3) Freeing memory when a process might be blocked waiting for the address space? The kernel memory routine would be kmem_free_wakeup().This routine returns memory to a submap of the kernel,and wakes up any processes waiting for memory in that map. 4)Allocating memory at an arbitrary address? The kernel memory routine would be the g eneral memory allocator malloc(). It can be used to allocate memory requests of arbitrary alignment or size. 5)Allocating memory of a fixed size? The kernel memory routine would be uma_zalloc().This routine allocates the memory for fixed sized items.These items belong to a particular zone.The uma_zalloc() routine takes the parameter as a zone identifier(returned by the zone allocator uma_zalloc() ).Zone has a collection of fixed sized i tems. Actually the zone is created using uma_zcreate() function. 6)Allocating aligned memory? The kernel memory routine would be kmem_alloc_pag eable(). Page Replacement In class, I mentioned that pages can be paged out if they appear on the free, inactive, or active lists. Explain how a page on the inactive or active lists might come to be paged out. If the page-count targets have not been met, the swap-out daemon is started (see next subsection) to try to clear additional memory. The FreeBSD 5.2 kernel does not impose any limits on the amount of virtual memory that it will grant. If it finds that it has nearly filled its memory and swap space, it avoids going into deadlock by killing off the largest process. One day virtual-memory accounting and limits will be added to the system so as to avoid this crude resource-control mechanism.

os_mid_term

Embed Size (px)

Citation preview

Page 1: os_mid_term

8/8/2019 os_mid_term

http://slidepdf.com/reader/full/osmidterm 1/2

Which kernel memory routine(s) would i use for -->

1) Allocating memory in an interrupt handler ?

The kernel memory routine would be kmem_malloc().

It allocates wired-down memory in the kernel's address map.This routine has 2 important components--

>a private kernel submap (kmem_map) and an

object(kmem_object).

2) Allocating memory at a fixed address ?

The kernel memory routine would be kmem_alloc().It is used to allocate wired memory in the kernel's

address map or a submap..It will return a failure

if no address space is available in indicated map.It may block if insufficient physical memory is available .

3) Freeing memory when a process might be blocked waiting for the address space?

The kernel memory routine would be kmem_free_wakeup().This routine returns memory to a submap

of the kernel,and wakes up any processes waiting for memory

in that map.

4)Allocating memory at an arbitrary address?

The kernel memory routine would be the general memory allocator malloc(). It can be used to allocate

memory requests of arbitrary alignment or size.

5)Allocating memory of a fixed size?

The kernel memory routine would be uma_zalloc().This routine allocates the memory for fixed sized

items.These items belong to a particular zone.The

uma_zalloc() routine takes the parameter as a zone identifier(returned by the zone allocator

uma_zalloc() ).Zone has a collection of fixed sized items.

Actually the zone is created using uma_zcreate() function.

6)Allocating aligned memory?

The kernel memory routine would be kmem_alloc_pageable().

Page Replacement In class, I mentioned that pages can be paged out if theyappear on the free, inactive, or active lists. Explain how a page on the inactive or activelists might come to be paged out.

If the page-count targets have not been met, the swap-out daemon is started (see next subsection) to tryto clear additionalmemory.

The FreeBSD 5.2 kernel does not impose any limits on the amount of virtual memory that it will grant. If itfinds that it has nearlyfilled its memory and swap space, it avoids going into deadlock by killing off the largest process. One dayvirtual-memoryaccounting and limits will be added to the system so as to avoid this crude resource-control mechanism.

Page 2: os_mid_term

8/8/2019 os_mid_term

http://slidepdf.com/reader/full/osmidterm 2/2

The FreeBSD 5.2 kernel does not impose any limits on the amount of virtual memory that it will grant. If itfinds that it has nearlyfilled its memory and swap space, it avoids going into deadlock by killing off the largest process. One dayvirtual-memoryaccounting and limits will be added to the system so as to avoid this crude resource-control mechanism.

swapping a process. In general, the swap-scheduling mechanism does not do well under heavy load;

system performance is muchbetter when memory scheduling can be done by the page-replacement algorithm than when the swap

algorithm is used.

Memory Management At boot time, a vm page structure is allocated for eachframe of memory not allocated to the kernel. Explain how a vm page can simlutaneouslybelong to many processes, yet will only appear once in the system.

155

Objects to PagesWhen the system is first booted, the kernel looks through the physical memory on the machine to find out how many pages are

available. After the physical memory that will be dedicated to the kernel itself has been deducted, all the remaining pages of physical memoryaredescribed by vm_page structures. These vm_page structures are all initially placed on the memory free list. As the system starts

runningand processes begin to execute, they generate page faults. Each page fault is matched to the object that covers the faulting piece of 

address space. The first time that a piece of an object is faulted, it must allocate a page from the free list and must initialize thatpage either by zero-filling it or by reading its contents from the filesystem. That page then becomes associated with the object. Thus, eachobject hasits current set of vm_page structures linked to it. A page can be associated with at most one object at a time. Although a file may be

mapped into several processes at once, all those mappings reference the same object. Having a single object for each file ensuresthat all

processes will reference the same physical pages.If memory becomes scarce, the paging daemon will search for pages that have not been used actively. Before these pages can beused by

a new object, they must be removed from all the processes that currently have them mapped, and any modified contents must besavedby the object that owns them. Once cleaned, the pages can be removed from the object that owns them and can be placed on the

free listfor reuse. The details of the paging system are described in Section 5.12.

Copy-on-write finds its main use in virtual memory operating systems; when

a process creates a copy of itself, the pages in memory that might be modified by

either the process or its copy are marked copy-on-write. When one process

modifies the memory, the operating system's kernel intercepts the operation and

copies the memory so that changes in one process's memory are not visible to

the other.