priority is always defined and executed before a task INTRODUCTION TO OPERATING SYSTEM with a lower priority. • Operating System – operating system is the most important software that runs on a computer. It PRINCIPLE OF OPERATING SYSTEMS manages the computer's memory and processes, as • Process – a program in execution which then forms well as all of its software and hardware. It also allows the basis of all computation. The process is not as you to communicate with the computer without same as program code but a lot more than it. A knowing how to speak the computer's language. process is an 'active' entity as opposed to the program Without an operating system, a computer is useless. which is considered to be a 'passive' entity. – it offers a UI through a CLI or GUI; it launches and • Process Memory: manages the application execution; and it identifies 1. The Text section is made up of the compiled and expose system hardware resources to those program code, read in from non-volatile storage applications -- typically, through a standardized API. when the program is launched. • System Software – provides a consistent and 2. The Data section is made up of the global and repeatable way for applications to interact with the static variables, allocated and initialized prior to hardware without the applications needing to know executing the main. any details about the hardware. 3. The Heap is used for the dynamic memory • UI (User Interface) – enabling users and allocation and is managed via calls to new, delete, administrators to interact with the OS in order to set malloc, free, etc. up, configure and even troubleshoot the operating 4. The Stack is used for local variables. Space on the system and its underlying hardware: stack is reserved for local variables when they are • GUI – lets you use your mouse to click icons, buttons, declared. and menus, and everything is clearly displayed on the • Process States: screen using a combination of graphics and text. 1. NEW – The process is being created. • Types of Desktop Operating Systems: 2. READY – The process is waiting to be assigned to 1. Microsoft Windows – created the Windows a processor. operating system in the mid-1980s. comes pre- 3. RUNNING – Instructions are being executed. loaded on most new PCs, which helps to make it 4. WAITING – The process is waiting for some event the most popular operating system in the world. to occur (such as an I/O completion or reception 2. macOS – (previously called OS X) is a line of of a signal). operating systems created by Apple. It comes 5. TERMINATED – The process has finished preloaded on all Macintosh computers, or Macs. execution. Accounts for the 10% of computer users. • Process Control Block: 3. Linux – is a family of open-source operating 1. Process State: It can be running, waiting, etc. systems, which means they can be modified and 2. Process ID and the parent process ID. distributed by anyone around the world. 3. CPU registers and Program Counter. Program Accounts for the 2% of computer users. Counter holds the address of the next instruction • Types of Mobile Operating Systems: to be executed for that process. 1. General-Purpose Operating System – tend to 4. CPU Scheduling information: Such as priority work in concert with processors where each core information and pointers to scheduling queues. runs a single thread of execution at a time. Here, 5. Memory Management information: For example, the operating system’s scheduler decides which page tables or segment tables. program to run and when, rapidly switching 6. Accounting information: The User and kernel between each program. This results in the illusion CPU time consumed, account numbers, limits, of simultaneous execution. etc. 2. Embedded Operating System – a computer 7. I/O Status information: Devices allocated, open operating system designed for use in embedded file tables, etc. computer systems. It has limited features. The • Process Scheduling – there are two or more runnable term "embedded operating system" also refers to processes then it is decided by the Operating system a "real-time operating system". which one to run first. • Types of Embedded Operating System: • Good Scheduling Properties: 1. Real-Time Operating System – is a deterministic 1. Response time should be minimum for the users. operating system with limited functionalities that 2. The number of jobs processed per hour should be allow multi-threaded applications by giving maximum i.e., good scheduling algorithm should processed outputs within set time limitations. give maximum throughput. 2. Multi-Tasking Operating System – multiple tasks 3. The utilization of the CPU should be 100%. and processes run at the same time. If the system 4. Each process should get a fair share of the CPU. contains more than one processor, it may • Memory Management – deals with the usage of the perform a wide range of functions. primary memory of the computer system. Its purpose is to move processes between primary memory IPC are creating, sending, receiving messages, (R.A.M.) and secondary memory (R.O.M.). deleting communication connections, etc. • Fragmentation – when processes are moved to and • System Program – the act of creating System from the main memory, the available free space in Software by using the System Programming primary memory is broken into smaller pieces. This Languages. A system program offers an environment happens when memory cannot be allocated to in which programs may be developed and run. In processes because the size of available memory is less simple terms, the system programs serve as a link than the amount of memory that the process between the user interface (UI) and system calls. requires. Such blocks of memory stay unused. • Types of System Program: • Types of Fragmentation: 1. File Management – a collection of specific 1. External Fragmentation – The total amount of information saved in a computer system's free available primary is sufficient to reside a memory. File management is described as process, but cannot be used because it is non- manipulating files in a computer system, including contiguous. the creation, modification, and deletion of files. 2. Internal Fragmentation – occurs when the 2. Status Information – is information about the memory block assigned to the process is larger input, output process, storage, and CPU than the amount of memory required by the utilization time, how the process will be process. computed in how much memory is necessary to • Memory Management Technique: execute a task. 1. Segmentation – a method of dividing the primary 3. File Modification – utilized to change files on memory into multiple blocks. Each block is called hard drives or other storage media. Besides a segment and has a specific length. Every modification, these programs are also utilized to segment has a starting address referred to as its search for content within a file or to change base address. content within a file. 2. Paging – is a technique of memory management 4. Programming-Language Support – includes in which the process address space is broken into certain standard system programs that allow blocks. All the blocks are of the same size and are programming languages such as C, Visual Basic, referred to as “pages”. C++, Java, and Pearl. There are various system 3. Swapping – includes two tasks, swapping in, and programs, including compilers, debuggers, swapping out. Swapping in means placing the assemblers, interpreters, etc. blocks or pages of data from the secondary 5. Program Loading and Execution - After memory to the primary memory. Swapping out is Assembling and Compiling, the program must be removing blocks/pages of data from the main loaded into the memory for execution. A loader is memory to the Read-Only Memory (R.O.M.). a component of an operating system responsible for loading programs and libraries, and it is one of SYSTEM CALL AND SYSTEM PROGRAM the most important steps to starting a program. • System Call – a method of interaction with the OS The system includes linkage editors, relocatable through the system programs. It is a technique in loaders, Overlay loaders, and loaders. which a computer system program requests a service 6. Communication - System program offers virtual from the OS kernel. links between processes, people, and computer • Types of System Call: systems. Users may browse websites, log in 1. Process Control - It is responsible for file remotely, communicate messages to other users manipulation jobs, including creating files, via their screens, send emails, and transfer files deleting files, reading, opening, writing, closing, from one user to another. etc. • Key Differences between System Call and System 2. File Management - It is responsible for file Program: manipulation jobs, including creating files, 1. A user may request access to the operating opening files, deleting files, closing files, etc. system's services by using the system call. In 3. Device Management - These are responsible for contrast, the system program fulfils a common device manipulation, including reading from user request and provides a compatible device buffers, writing into device buffers, etc. environment for a program to create and run 4. Information Maintenance - These are used to effectively. manage the data and its share between the OS 2. The programmer creates system calls using high- and the user program. Some common instances level languages like C and C++. Assembly level of information maintenance are getting time or language is used to create the calls that directly date, getting system data, setting time or date, interact with the system's hardware. On the other setting system data, etc. hand, a programmer solely uses a high-level 5. Communication - These are used for inter- language to create system programs. process communication (IPC). Some examples of 3. System call defines the interface between the services and the user process provided by the OS. In contrast, the system program defines the 2. CPU Scheduling: This layer deals with scheduling operating system's user interface. the processes for the CPU. Many scheduling 4. The system program satisfies the user program's queues are used to handle processes. When the high-level request. It converts the request into a processes enter the system, they are put into the series of low-level requests. In contrast, the job queue. The processes that are ready to system call fulfils the low-level requests of the execute in the main memory are kept in the ready user program. queue. This layer is responsible for managing how 5. The user process requests an OS service using a many processes will be allocated to the CPU and system call. In contrast, the system program how many will stay out of the CPU. transforms the user request into a set of system 3. Memory Management: Memory management calls needed to fulfil the requirement. deals with memory and moving processes from 6. The system call may be categorized into file disk to primary memory for execution and back manipulation, device manipulation, again. All memory management is associated with communication, process control, information this layer. There are various types of memories in maintenance, and protection. On the other hand, the computer like RAM, ROM. If you consider a System program may be categorized into file RAM, then it is concerned with swapping in and management, program loading and execution, swapping out of memory. programming-language support, status 4. Process Management: This layer is responsible information, communication, and file for managing the processes, i.e., assigning the modification. processor to a process and deciding how many processes will stay in the waiting schedule. The LAYERED STRUCTURE OF OPERATING SYSTEM different algorithms used for process scheduling • Layered Structure – breaks up the operating system are FCFS (first come, first served), SJF (shortest into different layers and retains much more control on job first), priority scheduling, round-robin the system. The bottom layer (layer 0) is the scheduling, etc. hardware, and the topmost layer (layer N) is the user 5. I/O Buffer: This layer handles the buffers for the interface. I/O devices and makes sure that they work • Why Layering in Operating System? correctly. 1. All the layers can be defined separately and 6. User Programs: This layer deals with the many interact with each other as required. Also, it is user programs and applications that run in an easier to create, maintain and update the system operating system, such as word processors, if it is done in the form of layers. games, browsers, etc. You can also call this an 2. Each of the layers in the operating system can application layer. only interact with the above and below layers. • Advantages of Layered Structure: The lowest layer handles the hardware, and the 1. Modularity – each layer performs only the tasks it uppermost layer deals with the user applications. is scheduled to perform. • Architecture of Layered Structure 2. Easy Debugging – the layers are discrete so it is 1. A particular layer can access all the layers present very easy to debug. below it, but it cannot access them. That is, layer 3. Easy Update – modification made in a particular n-1 can access all the layers from n-2 to 0, but it layer will not affect the other layers. cannot access the nth. 4. No direct access to hardware – a user can use the 2. Layer 0 deals with allocating the processes, services of hardware but cannot directly modify switching between processes when interruptions or access it. occur or the timer expires. It also deals with the 5. Abstraction – the functions and implementations basic multiprogramming of the CPU. of the other layers are abstract to it. 3. Thus, if the user layer wants to interact with the • Disadvantages of Layered Structure: hardware layer, the response will be traveled 1. Complex and careful implementation – the through all the layers from n-1 to 1. Each layer arrangement of the layers must be done carefully. must be designed and implemented such that it 2. Slower Execution – increases response time, will need only the services provided by the layers unlike the Monolithic system, which is faster than below it. this. • The Six Layers of Layered Operating System: 3. Functionality – not always possible to divide the 1. Hardware: This layer interacts with the system functionalities. hardware and coordinates with all the peripheral 4. Communication – No communication between devices used, such as a printer, mouse, keyboard, non-adjacent layers. scanner, etc. These types of hardware devices are managed in the hardware layer. The hardware layer is the lowest and most authoritative layer in the layered operating system architecture. It is attached directly to the core of the system. FAULT TOLERANCE know if components are performing to the expected level because failures do not • Fault Tolerance: automatically result in the system going down. - a process that enables an operating system to respond to a failure in hardware or software. This fault-tolerance definition refers to the system’s ability to continue operating despite failures or malfunctions. - can be built into a system to remove the risk of it having a single point of failure. To do so, the system must have no single component that, if it were to stop working effectively, would result in the entire system failing. • Fault Tolerance Two Core Models: 1. Normal Functioning – describes a situation when a fault-tolerant system encounters a fault but continues to function as usual. This means the system sees no change in performance metrics like throughput or response time. 2. Graceful Degradation – the impact the fault has on the system’s performance is proportionate to the fault severity. a small fault will only have a small impact on the system’s performance rather than causing the entire system to fail or have major performance issues. • Components of a Fault Tolerance System: 1. Diversity – In this event, fault tolerance can be sourced through diversity, which provides electricity from sources like backup generators that take over when a main power failure occurs. 2. Redundancy – system is equipped with one or more power supply units (PSUs), which do not need to power the system when the primary PSU functions as normal. 3. Replication – involves using multiple identical versions of systems and subsystems and ensuring their functions always provide identical results. If the results are not identical, then a democratic procedure is used to identify the faulty system. • Elements of Fault Tolerant Systems: 1. Hardware Systems – can be backed up by systems that are identical or equivalent to them. 2. Software Systems – common example is backing up a database that contains customer data to ensure it can continuously replicate onto another machine. • Factors to Consider in Fault Tolerance: 1. Cost – The biggest disadvantage of adopting a fault-tolerant approach is the cost of doing so. Organizations must think carefully about the cost elements of a fault-tolerant or highly available system. 2. Quality Degradation – one way around the cost of fault tolerance is to opt for more cost-effective but lower-quality redundant components. This approach can inadvertently increase maintenance and support costs and make the system less reliable. 3. Testing and Fault-detection Difficulties – Fault tolerance inevitably makes it more difficult to