# FreeBSD and Memory



## synack (May 13, 2009)

Hi,

I am currently studying computer science at university and am looking at computer memory in one of my subjects. I would like to know which area of the FreeBSD source code (/usr/src) do I need to look at to get an idea of how FreeBSD handles memory, both physical and virtual.

thanks for any help,

synack.


----------



## synack (May 13, 2009)

just a quick note.. I have ordered a copy of "Design and Implementation of the FreeBSD Operating System" which seems to be dealing with FreeBSD 5.2. Is this code still available for download?

synack.


----------



## Oko (May 13, 2009)

synack said:
			
		

> just a quick note.. I have ordered a copy of "Design and Implementation of the FreeBSD Operating System" which seems to be dealing with FreeBSD 5.2. Is this code still available for download?
> 
> synack.


Yes it is available. Check the ftp server. I assume you do know 
by heart Lion's Commentary on Unix and Design of the UNIX Operating System by Maurice J. Bach when you want to read 
"Design and Implementation of the FreeBSD Operating System"


----------



## synack (May 15, 2009)

so... is someone going to point me in the direction of the code that deals with memory? or am I going to have to wait for the book to arrive in the mail?.


----------



## vivek (May 15, 2009)

You can find memory manager and kernel related files in /usr/src directory if you installed kernel source code. I'm not aware of memory manager functions or files. But one can use grep command to locate specific functions:

```
grep  -R 'function_name' *
```


----------



## hydra (May 15, 2009)

For source files browsing I recommend devel/cscope.


----------



## Maledictus (May 16, 2009)

Or start here:
http://fxr.watson.org/fxr/source/vm/


----------



## rwatson@ (May 16, 2009)

Maledictus said:
			
		

> Or start here:
> http://fxr.watson.org/fxr/source/vm/



This is the best starting spot for the kernel VM system and kernel slab allocator (UMA) -- here are a few other places to start reading:

 - Kernel malloc, a thin wrapper around UMA - http://fxr.watson.org/fxr/source/kern/kern_malloc.c
 - User malloc, a thicker wrapper around VM (and especially mmap(2)) - http://www.freebsd.org/cgi/cvsweb.c...alloc.c?rev=1.147.2.7;content-type=text/plain


----------

