The Kernel & I-nodes

Kernel

The kernel is the main program that controls the computer's physical and logical components. The kernel have three main parts:

Accesses file data using a buffering mechanism that regulates data flow between kernel and storage devices. The buffering mechanism interacts with block I/O device drivers to initiate / control data transfer to and from kernel. Performs memory management. If there is not enough physical memory, the kernel swaps processes in and out between main memory and swap space. The swapper schedules the allocation of memory. The scheduler allocates the CPU to the processes. Handles I/O and interrupts through device drivers. Minidisk & File System

A minidisk is a logical drive usually located on a portion of a physical drive. A file system is a directory structure confined to a minidisk.

Bootstrap Block

This is the first block (block 0) of an active partition which contains the boot0, the first 512 bytes, and bootstrap. Boot0 contains Volume Table Of Contents (VTOC) which describe the basic minidisk information, backup VTOC, and bootstrap. Bootstrap, which contains more minidisk information, locates the kernel to load into memory.

Superblock

The first block (usually 4096 bytes) in a filesystem which contains all information about the filesystem, i.e. how large, how many files, free block list, name volume ID of minidisk, and list of free i-nodes.

I-nodes

After the superblock, the next group of blocks contain structures or i-nodes which are file descriptions and pointers to data blocks. An i-node is typically 512 bytes. Every file contains an i-node; therefore, if a file is less than 512 bytes minus the file description, then the i-node contains the file. If a file is larger than that, the i-node uses it's thirteen 4 byte disk addresses for pointing to additional data blocks. The first ten point directly to data blocks. If the file is larger than 10 blocks, then address eleven points to a first level indirect block. This indirect block contains (block size4 ( the 4 byte disk addresses) in this case 1024) disk addresses or pointers to additional data blocks. If the file is still larger, address 12 points to a second level indirect block which contain addresses of first level indirect blocks. Address 13 points to a third level indirect block.

Processes

Once the unix kernel is found on disk, it is loaded into memory. The kernel then builds the first process, process 0 or swapper. It is responsible for scheduling. Process 0 creates the init process (process 1) and the pager process (process 2). The pager is responsible for maintaining free memory pages. All other processes are descendants of init by either fork() or exec().