Posts

Showing posts from June, 2024

Types of OS

Image
 1. Single process OS In this OS only one process can be executed at one time. This is a very old type of OS. Imagine there are 3 processes, then P1 will be executed first, once the first process is executed then only P2 will be executed followed by P3. In this process there are various drawbacks such as no maximum CPU utilization , process starvation, and no high priority process will be executed first.  Example: MS DOS 2. Multiprogramming OS: As we populate the ready queue with multiple jobs, let's consider when job J1 is actively using the CPU. If J1 enters an I/O operation, like copying and pasting, to maintain CPU utilization and prevent idle time, we promptly schedule job J2 for execution. This approach ensures that the CPU stays engaged and productive while J1 handles its I/O task. Context-switching plays a major role here. Context switching refers to the operating system's technique for managing multiple processes on a single CPU. Imagine a scenario where there are ma...

Goals of OS

Image
 1. Maximum CPU utilization The task of an operating system (OS) is to ensure that CPU utilization is maximized at all times. For example, consider processes P1, P2, and P3, with the CPU currently processing P1. If P1 needs to perform an input/output (I/O) operation, such as a copy-paste task, the CPU shouldn't remain idle during this time. Idle CPU not only consumes power unnecessarily but also reduces efficiency and speed by making other processes wait. Instead, the OS can switch the CPU to process P2 while P1 is handling its I/O operations, thereby maintaining continuous CPU utilization. 2. It ensures there is no process starvation For example, if a CPU is executing a very large process like P1, it could cause other processes to wait indefinitely for their turn. If someone writes an infinite loop (e.g., while(1) ), it could run endlessly, preventing other processes from executing. This situation is known as process starvation. 3. Ensures the execution of high-priority  Imag...

Introduction to OS

Image
  Why do we need an operating system? For example, when we use the TikTok app, it requires basic components such as the CPU, GPU, memory, and disk space. These components are the essentials of a basic computer. If we imagine a scenario where there's no operating system managing these resources, TikTok would consume all available CPU, GPU, memory, and disk space. As a result, if we then try to play a resource-intensive game like PUBG, it wouldn't run properly because TikTok has already taken up all the necessary resources. What is an OS? We add an operating system (OS) as a management layer to prevent such issues. The OS helps allocate and manage resources efficiently. It ensures that resources like CPU, GPU, memory, and disk space are divided based on the requirements of different apps, preventing any single app from monopolizing them. This allows multiple applications, such as TikTok and PUBG, to run smoothly simultaneously. An operating system (OS) functions similarly to a b...