At the core of an OS is a piece of software known as the kernel. It is a program that sits between the user interface and the hardware and manages many tasks that happen within the computer. The kernel is also the defining piece of the OS: if two OS’s have the same kernel, they can run the same programs and use the same drivers. There are different kinds of kernels, but most modern OSs (such as Windows, Mac OS X, and Linux) use monolithic kernels.
Monolithic kernels provide these six general services. Individual services are itemized below this list:
- Interfacing (two services)
- System call API
- Device driver API
- File system and virtual file system
- Process and task management
- Memory management and virtual memory
Most modern kernels, like those used in Windows or MacOS, implement a level of hardware abstraction, or a set of basic operations that are universal to all devices of a certain type. The hardware abstraction provides an interface to the hardware and eliminates complexity by hiding the specific hardware details. In order to provide this set of abstractions, the kernel needs to know how to use the hardware. Since many combinations of hardware are possible, the kernel relies on device drivers to use the hardware directly.
The abstraction that the kernel provides for application developers is called the system call API. It allows software developers to easily build applications that are capable of running on different types of hardware. Each kernel provides its own APIs, which is why a Mac program doesn’t work on a Windows computer, and vice versa.
From an OS viewpoint, a file system is a piece of software that keeps track of data on a drive. Different file systems work in different ways, but they all organize related data into collections known as files and directories. Modern file systems are hierarchical – directories contain files and other directories. The kernel provides a set of system calls for dealing with the file system. Operations such as opening, closing, reading, writing, and deleting files are supported using system calls.
Since each file system has its own format, sharing files on external media can be difficult. To alleviate this problem, developers came up with the virtual file system (VFS). The VFS is similar to a driver API, in that it allows different file systems to “plug-in” to the kernel, and it tells the kernel how to access disks in a certain format. The VFS also offers a consistent interface to those files no matter what format they’re in.
A process (sometimes called a task) is an instance of a running program. Programs are stored on the disk as files containing information about the program, as well as the initial data and executable code. When you run a program, the kernel finds the program in the file system, loads it into memory (along with its context, the set of data that the program uses as it runs).
The kernel provides system calls for dealing with processes, including actions such as running or quitting a program.
A processor core can only run a single process at any given point in time. That means a dual-core processor can only run two processes simultaneously. Scheduling allows users to have more processes open, providing an illusion of multitasking by rapidly switching the processor core(s) between tasks. The kernel handles scheduling automatically, but some system calls imply that the kernel will switch to a different process, such as calls that quit a running process or wait for user input.
The kernel uses memory management to give each process its own region of memory to store code and data. The kernel keeps track of which region belongs to each process, and restricts that process to accessing its own memory. This makes the system a lot safer and more stable, since a process’s memory is protected from other (possibly malicious) processes.
The memory management system often also provides virtual memory. On a system with only 2 gigabytes of main memory, the kernel can use a part of the hard drive (known as swap space or a page file) as extra memory. A system with 2 gigabytes of main memory and sufficient swap space can utilize the full 4 gigabytes of address space (however, the swap space is much slower). The memory management system keeps track of which memory is in use by a process, and automatically “swaps” it in and out of main memory as it is needed.
Java Virtual Machine (JVM)
Java programs, run through the JVM, are similar to instructions that tell the “java” program how to run. Java use has increased significantly, both as a learning tool for entry CSC and as an online tool for having cross-platform or embedded applications.