xv6, line by line
kernel/vm.h

kernel/vm.h

C header · 2 lines · annotated 100% · kernel · upstream

Included by 2 fileskernel/sysproc.c, user/ulib.c
About this file

Two constants that select how the sbrk system call grows a process’s memory. They are shared by both sides of the system call: the user library (user/ulib.c) passes one of them as the second argument of the sbrk system call, and the kernel’s sys_sbrk (kernel/sysproc.c) checks which one it received.

  • Eager growth allocates and maps the new pages right away (growproc → uvmalloc).
  • Lazy growth only raises the process’s size p->sz. Each new page is allocated the first time the program touches it, when the resulting page fault reaches vmfault in kernel/vm.c.

Read next: vmfault.

1#define SBRK_EAGER 1
2#define SBRK_LAZY 2