kernel/param.h
Included by 26 files
kernel/bio.c, kernel/console.c, kernel/exec.c, kernel/file.c, kernel/fs.c, kernel/kalloc.c, kernel/log.c, kernel/main.c, kernel/pipe.c, kernel/plic.c, kernel/printk.c, kernel/proc.c, kernel/sleeplock.c, kernel/spinlock.c, kernel/start.c, kernel/syscall.c, kernel/sysfile.c, kernel/sysproc.c, kernel/trap.c, kernel/uart.c, kernel/virtio_disk.c, kernel/vm.c, mkfs/mkfs.c, user/grind.c, user/umalloc.c, user/usertests.cAbout this file
The kernel’s fixed limits. xv6 allocates almost all of its tables (processes, open
files, inodes, disk buffers) as fixed-size arrays at compile time instead of growing
them at run time, and these constants set their sizes. Changing one means recompiling
the kernel, and for FSSIZE and LOGBLOCKS also rebuilding the disk image with
mkfs, which includes this file too.
Each line is a #define: the C preprocessor replaces the name with its value
wherever it appears. The parentheses around the computed values keep them correct
inside larger expressions.
Compile-time limits
Most of these are maximums: exceeding one makes the operation fail (for example
fork fails when all NPROC process slots are in use) rather than allocating
more. The line notes say where each one is used.
Size of the process table proc in kernel/proc.c. It also fixes how many kernel
stacks proc_mapstacks maps at boot: one per slot, 64.
The most harts xv6 supports: it sizes the per-CPU array cpus and the boot stacks
stack0. QEMU starts CPUS harts (3 by default, see the Makefile), which must not
exceed this.
Size of each process’s file-descriptor array (ofile in struct proc, kernel/proc.h), so a process
can have at most 16 files open at once.
Size of the system-wide table of open files (ftable in kernel/file.c), shared
by all processes.
Size of the in-memory inode table (itable in kernel/fs.c): at most 50 files can
be in use at once.
Size of the device-switch table devsw: device files may have major numbers 0–9.
The device number of the disk holding the root file system, passed to fsinit and
used to look up / (kernel/fs.c:697).
The most arguments exec accepts, including the terminating null pointer; it sizes
the argv arrays in sys_exec and kexec.
An upper bound on the number of blocks one file-system operation (one system call) may
write. The log reserves this much space for each operation in progress
(begin_op), and filewrite splits large writes so that each piece stays under
it.
Room in the on-disk log for three operations’ worth of blocks (30). mkfs uses it to
lay out the log area on disk; kernel/log.c uses it as the log’s capacity.
Number of buffers in the disk block cache (bcache in kernel/bio.c), also 30.
Total size of the file system, in blocks (2000 blocks of 1024 bytes). Only mkfs
uses it, to create fs.img; the kernel reads the size from the superblock instead.
The longest path name the kernel accepts from a user program; it sizes the kernel
buffers that argstr copies paths into.
Number of pages of user stack that kexec allocates for a new program: one page
(4096 bytes), with a guard page below it. The stack does not grow.