Operating system interview questions and answers
What is an operating system?
An operating system is the core software that contains a collection of services essential for the machine to run programs. Think of this as the manager of a computer’s memory and processes. An OS is how we can communicate with a computer without understanding the same language. Without an OS, a user would need to know dozens of command-line statements to manually control each part of a computer.
What is a kernel?
The kernel is the central core of an operating system that allows programs to access hardware resources. A kernel is how a system starts up, translates input, and outputs requests to the central processing unit
Resource management
Resource management is one of the most important services of a kernel. The kernel delegates computer resources like memory and CPU to each process being executed. By regulating processes, the kernel prevents greedy programs from starving the system and slowing down other concurrent programs.
What is a process?
A process is the basic unit of work in an executing program. The developer doesn’t write processes. Instead, they write programs that become processes when executed by the machine.
Each process moves through 5 steps:
- Start: The process is first created from a program.
- Ready: The process is waiting to be assigned to a processor by the operating system scheduler.
- Running: The process’ instructions are executed by the processor.
- Waiting: The process is set to waiting if it requires additional resources like user input or file access.
- Terminated: After code execution, the process is moved to a terminated state where it will eventually be removed from the main memory.
What is a service?
The kernel is our platform to run programs while services provide tools to the program to do its job. A service is a built-in set of functions that programs can use to implement common behaviors, like saving files or sharing data. Without services, developers would have to write the code for these behaviors in each program that needs them.
- Program execution:
This service allows the computer to load, execute, and produce the output of a program. - Input/Output operations:
This service provides the ability to communicate with standard devices like printers and keyboards. The device can use this to make requests of the kernel or vice versa. Software to handle specific devices is called a driver, which instructs the I/O operations service on how to interface with the new device. - File System manipulation:
This service includes a standardized method of navigating memory so we can create and place files within directories. Programs can then navigate these directories, alter properties, or access/create files. It also provides the interface for users to interact with files through requests like creating/delete and move . - Communication:
The communication service enables links between individual processes to share data or results. It also includes the framework for distributed systems of multiple machines working together. - Error Detection:
Error detection allows computers to scan all processes for errors by monitoring progress and expected outcomes. This service can also correct minor errors without user interference. - Resource Allocation:
This kernel service allows the computer to grant and free up resources dynamically as processes are added or completed. It also allows the computer to create process sequences using CPU schedulers. - Protection:
This service provides basic cybersecurity protection through controlling system access, limiting I/O access to unrelated resources, and password authentication.