OS_Study_Notes
OS_Study_Notes
An Operating System (OS) is system software that manages computer hardware, software
resources, and provides common services for computer programs. The primary functions of
an OS include:
1. **Batch Operating Systems**: These systems do not interact with the user directly. They
collect jobs and process them in batches.
2. **Time-sharing Systems**: These systems allow multiple users to share system resources
simultaneously, giving the illusion of parallel execution.
3. **Real-time Operating Systems (RTOS)**: RTOS systems guarantee a certain level of
performance within a defined time frame.
4. **Distributed Operating Systems**: These OSs manage a group of independent computers
and make them appear as a single system to the user.
5. **Network Operating Systems**: These OSs provide services to the devices connected
over a network.
6. **Embedded Operating Systems**: These OSs are designed to run on specialized
hardware and perform specific functions within devices.
Operating System Structure
An operating system’s structure defines how different components of the OS interact. It can
be classified into:
The operating system provides several services to enable user-level processes to execute
smoothly:
1. **Process Scheduling**: The OS schedules processes for execution based on priority and
availability of resources.
2. **Memory Management**: The OS allocates memory resources and ensures isolation
between processes.
3. **I/O Management**: The OS manages input and output operations and coordinates
communication with peripheral devices.
4. **File System Management**: Provides access to files and directories, and handles file
creation, deletion, reading, and writing.
5. **Security and User Authentication**: Provides mechanisms to protect against
unauthorized access.
6. **Network Services**: Enables communication between processes and devices across
networks.
System Call
A **System Call** is a programmatic way a computer program requests a service from the
kernel of the operating system. They provide an interface between user-level applications
and the OS kernel. Examples include file management operations (open, read, write) and
process management operations (fork, exec).
System Program
System programs are utility programs that assist in the functioning of the operating system.
They help manage resources, troubleshoot issues, and perform operations on the OS level,
such as compilers, assemblers, editors, and debuggers.
Process Concept
Process State
A **Process Control Block (PCB)** is a data structure used by the OS to store information
about a process. It contains:
Context Switching
**Context Switching** is the process of storing the state of a running process so that it can
be resumed later and switching to another process. It is an essential part of multitasking
systems where multiple processes share the CPU.
Operation on Process
1. **Process Creation**: A new process is created when a program is loaded into memory.
2. **Process Scheduling**: The OS determines which process to run next.
3. **Process Termination**: When a process completes its task, it terminates and releases
resources.
A **Thread** is a smaller unit of a process that can run independently. It shares the same
memory space but has its own execution flow. Threads are used to improve performance in
multitasking environments.
**Layer Management**: Refers to how the OS handles different layers of abstraction, such as
the hardware layer, kernel layer, and user application layer.
Benefits of Multi-Threading
1. **Better CPU Utilization**: Multiple threads can execute while waiting for I/O operations
to complete.
2. **Improved Application Performance**: Tasks are executed in parallel, improving
efficiency.
3. **Responsive Applications**: Multi-threading can keep applications responsive by
performing tasks in the background.
Type of Threads
1. **User Threads**: These threads are managed by user-level libraries and are not known
to the OS.
2. **Kernel Threads**: Managed by the OS and scheduled by the kernel.
3. **Hybrid Threads**: A combination of user and kernel threads that leverage both user-
level libraries and kernel management.
Threading Issues
Threading issues arise when multiple threads access shared resources or data. These
include:
1. **Race Conditions**: Occurs when two or more threads try to modify shared data
simultaneously.
2. **Deadlocks**: Occurs when two or more threads are waiting for each other to release
resources.
3. **Starvation**: A thread is indefinitely delayed because other threads consume all
resources.
CPU Scheduling
**CPU Scheduling** is the method by which the OS decides which process will be executed
by the CPU. The objective is to optimize CPU utilization and process throughput.