Your technical depth starts here.
Module 1 – Operating System Fundamentals · Processes
Module 1 – Operating System Fundamentals
Operating System Fundamentals
- An Operating System (OS) is system software that manages hardware resources and provides services to application programs.
- The OS acts as an intermediary between the user/application software and computer hardware.
- Major functions of an OS include:
- Process management.
- Memory management.
- File management.
- Device management.
- Security and protection.
- Resource allocation.
- User-interface management.
- Kernel is the core component of an operating system.
- The kernel directly interacts with hardware and performs critical operations such as:
- CPU scheduling.
- Memory management.
- Device management.
- File-system management.
- Inter-process communication.
- A shell is a command interpreter that accepts user commands and passes them to the OS.
- The kernel runs in kernel mode, while normal applications generally run in user mode.
- User mode restricts applications from directly executing privileged instructions.
- Kernel mode provides complete access to system hardware and memory.
- The mode bit indicates whether the CPU is executing in user mode or kernel mode.
- A mode bit of 0 commonly represents kernel mode, while 1 commonly represents user mode, although the exact convention depends on the architecture.
- A privileged instruction can be executed only in kernel mode.
- Examples of privileged operations include:
- Direct I/O control.
- Changing the mode bit.
- Updating page tables.
- Disabling interrupts.
- Accessing hardware registers.
- A system call is the programming interface through which a user program requests a service from the OS kernel.
- System calls cause a controlled transition from user mode to kernel mode.
- After the requested service is completed, control returns to user mode.
- System calls are commonly grouped into:
- Process control.
- File management.
- Device management.
- Information maintenance.
- Communication.
- Memory management.
- fork() creates a new process by duplicating the calling process.
- The process that calls fork() is called the parent process.
- The process created by fork() is called the child process.
- exec() replaces the current process image with a new program.
- wait() makes a parent process wait for the completion of a child process.
- open() opens a file or device and returns a file descriptor.
- read() reads data from a file descriptor.
- write() writes data to a file descriptor.
- close() closes a file descriptor.
- getpid() returns the process ID of the calling process.
- pipe() creates a communication channel, usually between related processes.
- socket() creates a communication endpoint for network communication.
- mmap() maps a file or device into a process’s virtual memory.
- munmap() removes a memory mapping.
- A monolithic kernel places most OS services inside a single large kernel address space.
- Monolithic kernels generally provide high performance but have less modularity.
- A microkernel keeps only essential services in the kernel and moves other services into user space.
- Microkernels improve modularity and fault isolation but may incur IPC overhead.
- A hybrid kernel combines features of monolithic and microkernel architectures.
- An exokernel exposes low-level hardware resources to applications and gives applications more control.
- A real-time kernel is designed to provide predictable responses within specified timing limits.
- A hypervisor manages virtual machines and allows multiple operating systems to run on one physical machine.
- A batch operating system processes jobs in groups without continuous user interaction.
- A multiprogramming OS keeps multiple programs in memory and switches the CPU when one program waits for I/O.
- The main goal of multiprogramming is to increase CPU utilization.
- A multitasking OS allows multiple tasks to appear to execute concurrently.
- A time-sharing OS gives each process or user a small time slice called a quantum.
- A real-time operating system is used when timing constraints are important.
- A distributed OS manages multiple connected computers as if they form one system.
- A network operating system provides services such as file sharing, printer sharing, and network communication.
- An embedded OS is designed for specialized devices with limited resources.
- A single-user OS is designed for one user at a time.
- A multi-user OS allows multiple users to access system resources concurrently.
Processes
- A process is a program in execution.
- A program is passive, while a process is active.
- A process normally contains:
- Program code.
- Data.
- Stack.
- Heap.
- CPU registers.
- Program counter.
- The Process Control Block (PCB) stores information about a process.
- A PCB may contain:
- Process ID.
- Process state.
- Program counter.
- CPU registers.
- CPU-scheduling information.
- Memory-management information.
- I/O status information.
- Accounting information.
- A Process ID (PID) uniquely identifies a process.
- A foreground process directly interacts with the user.
- A background process runs without requiring immediate user interaction.
- A parent process creates one or more child processes.
- A child process is created by another process.
- A daemon process is a continuously running background service.
- An orphan process is a child whose parent process has terminated.
- An orphan process is generally adopted by a system or init process.
- A zombie process has completed execution but still has an entry in the process table.
- A zombie remains until its parent collects its termination status using an operation such as wait().
- A user-level process runs with restricted privileges in user space.
- A system-level process performs privileged operating-system functions.
- A preemptive process can be interrupted by the OS scheduler.
- A cooperative process voluntarily gives up the CPU.
- A process generally moves through these states:
- New.
- Ready.
- Running.
- Waiting or blocked.
- Terminated.
- In the new state, the process is being created.
- In the ready state, the process is waiting for CPU allocation.
- In the running state, the process is currently executing on the CPU.
- In the waiting state, the process is waiting for an event such as I/O completion.
- In the terminated state, the process has finished execution.
- The ready que contains processes waiting for CPU time.
- The waiting que contains processes waiting for a particular event or resource.
- A context switch occurs when the CPU changes from one process or thread to another.
- During a context switch, the OS saves the state of the current process and loads the state of another.
- Context switching is overhead because the CPU performs no useful application work during the switch.
- A dispatcher gives control of the CPU to the process selected by the scheduler.
- Dispatch latency is the time required by the dispatcher to stop one process and start another.
- A process switch may occur because:
- The process requests I/O.
- Its time quantum expires.
- A higher-priority process becomes ready.
- The process terminates.
- An interrupt occurs.
