Every topic starts at New. Sign in and your practice counts.
An operating system (OS) is essential software that manages a computer's memory, processes, hardware, and software, enabling user interaction. It loads into RAM when the computer is turned on and is necessary to run any programs. OS has evolved since the first computer generation and is present in all devices like desktops, tablets, and smartphones, with common examples being Windows, Mac OS, Linux, iOS, and Android.
Operating system performs the following main tasks or functions.
Process Management
A process is a program in execution, and process management in an operating system allocates resources like CPU time to various processes in memory. For example, with three processes (A, B, and C ), each having different CPU cycles ( ), the OS manages execution times. In Case 1 (ABC order), the total time is 6.67 ms , while in Case 2 (BCA order), it's 4.33 ms , showing that Case 2 is more efficient.
Memory management is the part of operating system that controls and manages the operation of main memory during the operation of computer. It allocates space to programs that are loaded in main memory for execution. It keeps track of freed memory when a program is closed and updates the memory status.
Example: In this example the OS is
managing memory for two processes PC and . is being loaded (swap in) and PO is being taken out (swap out) from the main memory (RAM). The whole process is shown in Fig 1.5.
File management is the part of operating system that manages files and folders on storage devices such as hard disk, USB flash drive and DVD. It allows computer user to perform operations such as creating, copying, moving, renaming, deleting, and searching files and folders. It also allows the user to perform read, write, open and close operations on files and folders. Fig 1.6 shows the management of files in various folders by OS.
Device management is the part of operating system that controls input and output devices, such as keyboards, mouse, printers, and network interfaces. Efficient I/O management improves the performance of the computer. As shown in Fig. 1.7.
Example: There are three programs A , B and C which are using the printer. Now the OS will decide which program to use the printer first. A queue will be set by the and each program will get the printer by its turn.
Network management is the part of network operating system that monitors and manages the resources of a network. It allows to create user groups and assigns privileges to them. It shares the network resources among users and detects and fixes network problems.
This figure is being prepared.
Network management
Security management in an operating system ensures resources are used according to user privileges set by the system administrator. It creates user accounts, enforces security policies, controls access to resources, and protects the system from unauthorized access and malware.
The following are the important types of operating systems that are commonly used on various computer systems.
A batch processing operating system groups similar tasks into batches and executes them sequentially. It is ideal for repetitive tasks, such as payroll processing or generating bank statements, where the same operation is applied to multiple users or jobs. While this system provides efficiency in handling large volumes of similar tasks, it may introduce delays as jobs are processed one after another.
A multiprogramming operating system allows multiple programs to be loaded into the main memory simultaneously. Although the CPU can execute only one program at a time, it switches between programs when one is waiting for input or output, thus maximizing CPU utilization. This system is designed to improve the efficiency of the computer by ensuring that the CPU is rarely idle.
A multitasking operating system enables multiple tasks to be performed concurrently on a single CPU. The system rapidly switches between tasks, creating the impression that all tasks are running simultaneously. This capability is essential for modern personal computers and mobile devices, where users often run several programs at once.
A time-sharing operating system divides CPU time into short intervals, known as time slices, and allocates each program a time slice in turn. This method allows multiple users or programs to interact with the system simultaneously, giving the appearance that all are being processed at the same time. Time-sharing systems are commonly used in environments such as banks, universities, and large organizations that require multiple users to access the
This figure is being prepared.
Time-sharing Operating System
system concurrently.
A real-time operating system is designed to process data and provide immediate responses. It is used in environments where timing is critical, such as medical equipment, traffic control systems, and industrial automation. Real-time systems must operate within strict time constraints to ensure that tasks are completed within a specified deadline, making them highly reliable and responsive.
A multiprocessor operating system controls the operation of multiple CPUs within a single computer system. By distributing tasks among several processors, the system can handle large amounts of data more efficiently and increase the overall processing speed. Multiprocessor systems are used in environments requiring high performance, such as data centers, servers, and scientific research applications.
A distributed operating system manages a network of computers, allowing programs to run on multiple machines simultaneously. In a distributed system, the operating system distributes tasks across different computers in the network, balancing the load and providing fast execution of application software. Users do not need to know which machine is processing their tasks, as the distributed OS manages this transparently. This system is widely used in cloud computing and other networked environments.
An embedded operating system is integrated into the hardware of a specific device, such as a microwave oven, TV, or camera. It is designed to perform specialized tasks and operates automatically when the device is turned on. Embedded operating systems are optimized for the specific functions of the device and provide reliable performance with minimal resource requirements. They are commonly used in consumer electronics and industrial machines.
Application programs run on top of operating systems by utilizing the resources and services provided by the operating system. The operating system serves as an intermediary between the hardware and the application programs, managing tasks such as memory allocation, process scheduling, and device management.
For example, when a user opens a word processing program such as Microsoft Word, the operating system allocates memory for the program to run, manages input/output operations such as reading and writing files, and schedules the program to run on the CPU. The operating system also provides access to system resources such as printers and network connections that the application program may need to use.
Overall, the operating system acts as a platform on which application programs can run, providing a layer of abstraction that allows programs to interact with the hardware without needing to know the specific details of the underlying hardware. As shown in Fig 1.18.
Process management is an important task of operating system. It allocates systems resources to various processes so that they can run efficiently.
A process is a program in execution. For example, when we write a program in C or and compile it, the compiler creates a binary code. The original code and Binary code, both are programs. When we actually run the binary code, it becomes a process. Process is a part of program under execution
that is scheduled and controlled by operating system. When a program is loaded in memory for execution, it becomes a process. A program is an executable code that is stored in disk as a text file whereas a process is a dynamic instance of a program during its execution in RAM. It represents basic unit of work. It uses various resources of computer such as CPU time, files, I/O devices, memory, etc.
There are five states of a process which are start, ready, running, waiting and terminated as shown in Figure.
Start/New State: This is the first state of a process when it is created. Any new operation or service that is requested by a program for execution by the processor is known as new state of process.
Ready State: A process is said to be in ready state when it is ready for execution but it is waiting to be assigned to the processor by the operating system.
Running State: A process is said to be in running state when it is being executed by the processor. A process is assigned to a processor for execution by operating system.
Blocked State/Waiting State: A process is in blocked or waiting state when it is not under execution. It is waiting for a resource to become available.
Terminated State: A process is in terminated state when it completes its execution.
In programming, there are two basic units of execution: processes and threads. They both execute a series of instructions. A Process is an instance of a program that is being executed. A process may be made up of multiple threads. A Thread is a basic ordered sequence of instructions within a process that cannot be executed independently. The threads are made of and exist within a process; every process has at least one thread. Multiple threads can also exist in a process and share resources.
Comparison between Process and Thread
Comparison between Process and Thread
| Process | Thread | |
|---|---|---|
| 1 | An executing instance of a program is called a process. | A thread is a subset of the process. |
| 2 | It has its own copy of the data segment of the parent process. | It has direct access to the data segment of its process. |
| 3 | Any change in the process does not affect other processes. | Any change in the thread may affect the behavior of the other threads of the process. |
| 4 | Processes run in separate memory spaces. | Threads run in shared memory spaces. |
| 5 | Process is controlled by the operating system. |
A process scheduler is part of the operating system that manages the execution order of processes by the CPU. It ensures efficient and fair use of CPU time by allocating processing time based on specific scheduling algorithms.
This figure is being prepared.
This figure is being prepared.
Shared Resource
Fig.1.22: Process Synchronization
Process synchronization is a method used to coordinate multiple processes or threads that share resources. It prevents issues like race conditions, which occur when processes try to access the same memory at the same time. The operating system controls the execution order to avoid conflicts.
Interrupts are signals that alert the CPU to events that need immediate attention. When an interrupt occurs, the CPU stops its current task, saves its state, and runs a special program called an Interrupt Service Routine (ISR) to handle the event. For example, when you receive an email, the system interrupts the CPU to process the email quickly.
A deadlock happens when two or more processes are stuck, each waiting for a resource held by the other. For example, as shown in Fig. 1.23, if Process P1 needs Resource R2 held by Process P2, while P2 needs Resource R1 held by P1, neither can proceed. The operating system must detect and resolve these deadlocks to keep processes running smoothly.
The four main computer system resources managed by an operating system are:
The operating system manages the CPU by scheduling processes, ensuring efficient utilization of the CPU, and prioritizing tasks. This involves process scheduling algorithms, deadlock resolution, and handling interrupts.
The operating system is responsible for managing the system's memory, which includes RAM. This involves allocation and deallocation of memory spaces to various programs, managing memory hierarchy, and ensuring that each process has adequate memory while optimizing the use of available memory.
The operating system manages data storage, including hard drives, SSDs, and other storage
devices. This involves file system management, managing read/write operations, ensuring data integrity, and providing an interface for file and directory management.
The operating system manages input and output devices such as keyboards, mice, printers, and network interfaces. This includes managing device communication, buffering, and handling device drivers to ensure that the I/O operations are carried out smoothly and efficiently.
The file system is a critical component of an operating system, responsible for organizing, storing, retrieving, and managing data on storage devices like hard drives, SSDs, and USB drives. Here's a detailed explanation of the structure and organization of a file system:
A file system is composed of several key components:
Files: The smallest unit of data storage, representing a collection of bytes stored on a disk. Files can be of various types, such as text files, executables, images, etc.
Directories/Folders: Also known as folders, directories are containers that hold files and other directories, providing a hierarchical structure.
Metadata: Information about files and directories, such as their names, sizes, types, permissions, and timestamps (creation, modification, and access times).
The directory/folder structure can be organized in different ways, commonly used directory/folder structures are shown in Fig. 1.24.
This figure is being prepared.
Directory/Folder Structure
Single-Level Directory/Folder: All files are contained in a single directory/folder. This structure is simple but becomes inefficient as the number of files grows. Figure A shows single level directory/folder structure.
Two-Level Directory/Folder: Each user has their own directory under the root directory, solving some of the limitations of the single-level structure. Figure B shows two level directory/folder structure.
Tree-Structured Directory/Folder: The most common structure, allowing a hierarchy of directories and subdirectories, resembling a tree. This structure is flexible and scalable. Figure Cshows tree-structured directory/folder structure.
Files can be stored in different ways:
Contiguous Allocation: Files occupy consecutive blocks, which speeds up access but can cause fragmentation.
Linked Allocation: Files are stored in linked lists, allowing flexibility but possibly slower access due-to pointer traversal.
Indexed Allocation: Uses an index to point to the actual data blocks, allowing faster access while balancing storage efficiency.
Various file systems are designed to meet different needs and have unique features. Some common file systems include:
FAT (File Allocation Table): An older file system used by DOS and Windows. Simple but limited in features and scalability.
File systems provide various operations to manage files and directories. Common file operations are:
Create: Making new files and directories.
Open: Accessing files for reading or writing.
Read: Retrieving data from files.
Write: Adding or modifying data in files.
Delete: Removing files and directories.
Rename: Changing the names of files and directories.
| Threads are controlled by programmer in a program. |
| 6 | Processes are independent. | Threads are dependent. |