Describe the 3 zones of physical memory in Linux.
Zone DMA for DMA devices. Zone normal for kernel space. Zone highmem for user space.
State the purpose of the page allocator.
Allocates and frees all physical pages, can allocate ranges of physically-contiguous pages on request.
Describe the buddy-heap algorithm.
Each allocatable memory region is paired with an adjacent partner. Two free partners are combined into a larger region. If no small free region exists to satisfy a small memory request, subdivide a larger free region into two pieces to satisfy the request.
Describe the algorithm for allocating kernel memory.
The slab allocator - where freed memory is reused for objects of the same type.
How are virtual memory regions characterised?
By the backing store - from where the pages of a region come from. The region’s reaction to writes - e.g., page sharing or copy on write.
Describe what happens when a process runs a new program via exec.
An existing process is given a new, empty virtual address space. Program loading routines populate the address space with virtual-memory regions.
Describe what happens when a process creates a new process via fork.
New process is given a copy of the parent’s virtual address space, parent’s VMA and page tables. So initially, the parent and the child share the same physical pages of memory.
Describe the process of loading an ELF-format program.
An ELF-format program has a header and several page aligned sections. ELF loader reads header and maps sections of the file into various virtual memory regions.
How are devices and processes represented in the Linux filesystem?
Devices are represented by special files. The proc file system is computed on demand.
Describe the layout of an inode (index node).
Metadata of the file. Direct links to blocks of data. Single, double and triple indirect links to data blocks.
What is a directory in Linux?
It is itself an inode that maps filenames to inodes.
Define hardlink.
An instance of a file in a directory is a hardlink.
Define softlink.
It is a normal file containing a file name, interpreted by the file system.
Explain what a file descriptor is and how it can be mapped to an inode.
Each process sees files as file descriptors, which index into a process-specific open file table, which points to the system-wide open file table, which points to an inode in the inode table.
Explain what user IDs and group IDs are.
They are numeric identifiers to identify a single user/group.
Explain the access control rules for processes.
If process UID matches object UID, then process has user/owner rights. If process GID matches object GID, then process has group rights. Else process has world rights.
Describe how access control information is held in each inode.
3 bits for r/w/x of owner, group and world.
What do setuid and setgid bits do?
They allow processes to become someone else when running.
State the purpose of a buffer cache.
Maintains copies of some parts of disk in memory for speed.
Describe how reading a file through a buffer cache works.
Locate relevant blocks from inode. If not in buffer cache, read from disk into buffer cache. Return data from buffer cache.
Describe the Linux boot process.
Kernel is loaded from disk and executed, mounting root filesystem. Reads /etc/inittab, for each entry creates a terminal special file (/dev/ttyX). For each tty, initializes the terminal and waits for login. Runs /bin/login on login, checks /etc/passwd to see if password matches; if match, starts the indicated shell.
State the benefit of using CWD.
It avoids the need for fully qualified pathnames.
Describe the 3 file descriptors that every process has opened by default.
stdin for reading input, stdout where output is sent, stderr where diagnostics are sent.