This presentation cover detail about System software
Size: 18.25 MB
Language: en
Added: Aug 27, 2024
Slides: 144 pages
Slide Content
System software introduction
VIRTUAL MACHINES A virtual machine (VM) is a software-based emulation of a physical computer. It allows multiple operating systems to run on a single physical machine (host Emulation is the use of an app/device to imitate the behavior of another program/device; for example, running an OS on a computer which is not normally compatible.
VIRTUAL MACHINES a virtual machine runs the existing OS (called the host operating system ) and oversees the virtual hardware using a guest operating system –
VIRTUAL MACHINES The emulation engine is referred to as a hypervisor ; this handles the virtual hardware (CPU, memory, HDD and other devices) and maps them to the physical hardware on the host computer
VIRTUAL MACHINES; how it is done? First, virtual machine software is installed on the host computer. When starting up a virtual machine, the chosen guest operating system will run the emulation in a window on the host operating system. The emulation will run as an app on the host computer. The guest OS has no awareness that it is on an ‘alien machine’; it believes it is running on a compatible system. It is actually possible to run more than one guest OS on a computer. This section summarizes the features of host and guest operating systems, as well as the benefits and limitations of virtual machines.
VIRTUAL MACHINES vs virtual memory In computing, virtual memory is a memory management technique that uses a combination of physical RAM and storage (like a hard drive) to simulate a larger memory space. It allows running applications to use more memory than is physically available Virtual machines are software-based emulations of physical computers. They allow multiple operating systems to run on a single physical machine, providing isolation and flexibility for running different software environments
Features of VIRTUAL MACHINES Guest operating system • This is the OS running in a virtual machine. • It controls the virtual hardware during the emulation. • This OS is being emulated within another OS (the host OS). • The guest OS is running under the control of the host OS software. Host operating system • This is the OS that is controlling the actual physical hardware. • It is the normal OS for the host/physical computer. gg• The OS runs/monitors the virtual machine software.
Benefits of VIRTUAL MACHINES The guest OS hosted on a virtual machine can be used without impacting anything outside the virtual machine It is possible to run apps which are not compatible with the host computer/OS by using a guest OS which is compatible with the app. Virtual machines are useful if you have old/legacy software which is not compatible with a new computer system/hardware Virtual machines are useful for testing a new OS or new app s
LIMITATIONS of VIRTUAL MACHINES You do not get the same performance running as a guest OS as you do when running the original system Building an in-house virtual machine can be quite expensive for a large company They can also be complex to manage and maintain
Applications of VIRTUAL MACHINES Application Compatibility : Running legacy applications on VMs to maintain compatibility with older operating systems and software. Server Virtualization: Running multiple virtual servers on a single physical host. This optimizes hardware usage and simplifies server management.
Applications of VIRTUAL MACHINES Software and Operating System Testing : Testing software or operating systems in different environments to ensure compatibility and stability Sandboxes : Providing secure environments for running potentially harmful code or testing suspicious software without risking the host system
System software It provides essential services and functions to support the execution of application software and the management of hardware resources System software includes several components: Operating System (OS) Device Drivers Utilities Compiler and Assembler Library Programs
Operating system The operating system, manages hardware resources, provides a user interface, and ensures the proper execution of application programs.
Purpose of Operating system Process Management Memory Management File System Management Device Management User Interface Security and Access Control Error Handling and Logging Backup and Recovery System Monitoring and Performance Analysis Updates and Maintenance
How an operating system can maximize the use of computer resources A computer is first switched on the basic input/output system (BIOS) – which is often stored on the ROM chip – starts off a bootstrap program The bootstrap program loads part of the operating system into main memory (RAM) from the hard disk/SSD
How an operating system can maximize the use of computer resources initiates the start-up procedures. This process is less obvious on tablets and mobile phones – they also use RAM, but their main internal memory is supplied by flash memory; (this explains why the start-up of tablets and mobile phones is almost instantaneous. )
How an operating system can maximize the use of computer resources The flash memory is split into two parts. The part where the OS resides. It is read only
How an operating system can maximize the use of computer resources The RAM is where the apps are executed and where data currently in use is stored
How an operating system can maximise the use of computer resources One operating system task is to maximise the utilization of computer resources. Resource management can be split into three areas the CPU memory the input/output (I/O) system
How an operating system can maximise the use of computer resources Resource management of the CPU involves the concept of scheduling to allow for better utilization of CPU time and resources
How an operating system can maximise the use of computer resources Regarding input/output operations, the operating system will need to deal with • any I/O operation which has been initiated by the computer user • any I/O operation which occurs while software is being run and resources, such as printers or disk drives, are requested.
How an operating system can maximise the use of computer resources The direct memory access (DMA) controller is needed to allow hardware to access the main memory independently of the CPU.
How an operating system can maximise the use of computer resources When the CPU is carrying out a programmed I/O operation, it is fully utilised during the entire read/write operations
How an operating system can maximise the use of computer resources When the CPU is carrying out a programmed I/O operation, it is fully utilised during the entire read/write operations
How an operating system can maximise the use of computer resources the DMA frees up the CPU to allow it to carry out other tasks while the slower I/O operations are taking place
How an operating system can maximise the use of computer resources The DMA initiates the data transfers. The CPU carries out other tasks while this data transfer operation is taking place. Once the data transfer is complete, an interrupt signal is sent to the CPU from the DMA
How an operating system can maximize the use of computer resources The figure shows how slow some I/O devices are when compared with a typical computer’s clock speed of 2.7 GHz.
Operating system; The Kernel The kernel is part of the operating system. It is the central component responsible for communication between hardware, software and memory. It is responsible for process management, device management, memory management, interrupt handling and input/output file communications
How an operating system can maximise the use of computer resources The DMA initiates the data transfers. The CPU carries out other tasks while this data transfer operation is taking place. Once the data transfer is complete, an interrupt signal is sent to the CPU from the DMA
How an operating system can maximize the use of computer resources One of the most important tasks of an operating system is to hide the complexities of the hardware from the users. This can be done by : using GUI interfaces rather than CLI using device drivers (which simplifies the complexity of hardware interfaces) simplifying the saving and retrieving of data from memory and storage devices carrying out background utilities, such as virus scanning which the user can ‘leave to its own devices’.
Purpose of Operating system Process Management Memory Management File System Management Device Management User Interface Security and Access Control Error Handling and Logging Backup and Recovery System Monitoring and Performance Analysis Updates and Maintenance
Process management Multitasking It allows computers to carry out more than one task (known as a process) at a time. (A process is a program that has started to be executed.) To ensure multitasking operates correctly (for example, making sure processes do not clash), scheduling is used to decide which processes should be carried out
Process management Multitasking ensures the best use of computer resources by monitoring the state of each process It should give the appearance that many processes are being carried out at the same time . the kernel overlaps the execution of each process based on scheduling algorithms
Process management Multitasking ensures the best use of computer resources by monitoring the state of each process It should give the appearance that many processes are being carried out at the same time . the kernel overlaps the execution of each process based on scheduling algorithms
Process management There are two types of multitasking operating systems preemptive (processes are pre-empted after each time quantum) non-preemptive (processes are pre-empted after a fixed time interval)
Process management Time Quantum is the period of time for which a process is allowed to run in a pre-emptive multitasking system is generally called the time slice or quantum. Each process is assigned a fixed timeÂ
Process management In a preemptive operating system, the operating system can interrupt or preempt a running process to allocate the CPU to another process. This means that a process may not run for its entire time slice, and the OS can forcefully stop it
Process management Consider an air traffic control system at a busy airport. The air traffic controller's primary job is to ensure the safe and efficient landing and takeoff of aircraft. If a critical situation arises, such as a sudden change in weather conditions or an emergency with an aircraft, the controller will immediately divert their attention to address the emergency, even if they were currently guiding another plane. This is an example of a preemptive approach, as the critical task takes priority over the ongoing task.
Process management In a non-preemptive operating system, a running process retains the CPU until it willingly gives it up or finishes its execution. The operating system cannot forcefully interrupt a process.
Think of a physical queue at a bank. Customers stand in line, and they are served in the order they arrive. Once a customer reaches the teller's window and begins a transaction The bank teller will complete the customer's transaction before moving on to the next person in the queue. In this scenario, the bank teller does not preempt the current customer; they must complete their transaction before the next customer can be served . This is akin to how non-preemptive operating systems handle processes.
Process management; Scheduling The goal of process scheduling is to allocate CPU time fairly, efficiently, and according to specific priorities, while minimizing the wait time and maximizing system throughput.
Process management; Scheduling Low-level scheduling and High-level scheduling are two different levels of process scheduling in an operating system
Process management; Scheduling High-level scheduling , also known as job scheduling , operates at a broader level than CPU scheduling.
Process management; Scheduling It deals with long-term decisions about which processes are allowed into the system, often from the job queue (a pool of processes waiting to be admitted).
Process management; Scheduling Low level scheduling decides which process should next get the use of CPU time (in other words, following an OS call, which of the processes in the ready state can now be put into a running state based on their priorities). It
Process management; Scheduling Its objectives are to maximize the system throughput, ensure response time is acceptable and ensure that the system remains stable at all times (has consistent behavior in its delivery)
Process management; Scheduling For example, low level scheduling resolves situations in which there are conflicts between two processes requiring the same resource
Process management; Scheduling Suppose two apps need to use a printer; the scheduler will use interrupts, buffers and queues to ensure only one process gets printer access – but it also ensures that the other process gets a share of the required resources.
Process SCHEDULER Process priority depends on: its category (is it a batch, online or real time process?) whether the process is CPU-bound (for example, a large calculation such as finding 10 000! (10 000 factorial) would need long CPU cycles and short I/O cycles) or I/O bound (for example, printing a large number of documents would require short CPU cycles but very long I/O cycles)
Process SCHEDULER resource requirements (which resources does the process require, and how many?) the turnaround time, waiting time and response time for the process whether the process can be interrupted during running.
Process SCHEDULER Once a task/process has been given a priority, it can still be affected by the deadline for the completion of the process how much CPU time is needed when running the process
Process SCHEDULER the wait time and CPU time the memory requirements of the process.
Process states A process control block (PCB) is a data structure which contains all of the data needed for a process to run; this can be created in memory when data needs to be received during execution time
Process states A process state refers to the following three possible conditions: 1 running 2 ready 3 blocked.
Process states The PCB will store : • current process state (ready, running or blocked) • process privileges (such as which resources it is allowed to access) • register values (PC, MAR, MDR and ACC) • process priority and any scheduling information • the amount of CPU time the process will need to complete • a process ID which allows it to be uniquely identified.
Process states
Process states To investigate the concept of a READY QUEUE and a BLOCKED QUEUE a little further, we will consider what happens during a round robin process, in which each of the processes have the same priority.
Process states Supposing two processes, P1 and P2, have completed. The current status is shown in figure
Process states The term "low-level scheduler" can refer to the component within the operating system responsible for making decisions about which process currently in memory gets access to the CPU.
Process states The term "low-level scheduler" can refer to the component within the operating system responsible for making decisions about which process currently in memory gets access to the CPU. It's essentially the same concept as "low-level scheduling."
Process states The mid-term scheduler operates at a medium level. It focuses on managing the number of processes in memory.
Process states The mid-term scheduler decides which processes should be swapped in and out of memory, helping to maintain system performance
Process states It is responsible for deciding when to move processes between the ready queue and the waiting queue, or to/from secondary storage
Process scheduling The term "high-level scheduler" can refer to a higher-level entity responsible for system-level management and resource allocation decisions. It's essentially the same concept as "high-level scheduling."
Process states
Process states
Scheduling routine algorithms It is important to consider how we manage the ready queue to minimize the waiting time for a process to be processed by the CPU.
Scheduling routine algorithms These are some of the most common strategies used by schedulers to ensure the whole system is running efficiently and in a stable condition at all times.
Scheduling routine algorithms; First come first served scheduling (FCFS) This is similar to the concept of a queue structure which uses the first in first out (FIFO) principle
Scheduling routine algorithms We will consider four examples of scheduling routines : first come first served scheduling ( FCFS ) shortest job first scheduling ( SJF ) shortest remaining time first scheduling ( SRTF ) round robin.
first come first served scheduling ( FCFS ) First-Come, First-Served (FCFS) is a simple scheduling algorithm used in operating systems, where the process that arrives first is the first to be served. It's a non-preemptive algorithm, meaning that once a process starts execution, it continues until it completes.
first come first served scheduling ( FCFS ) This is similar to the concept of a queue structure which uses the first in first out (FIFO) principle.
first come first served scheduling ( FCFS ) Suppose we have four processes, P1 , P2 , P3 and P4 , which have burst times of 23 ms , 4 ms , 9 ms and 3 ms respectively. The ready queue will be
first come first served scheduling ( FCFS ) This will give the average waiting time for a process as:
first come first served scheduling ( FCFS ) The total amount of time required by the CPU to execute the whole process is called the Burst Time
first come first served scheduling ( FCFS ) Imagine a small restaurant with a single dining area and a single waiter. In this restaurant, customers arrive and are seated in a first-come, first-served manner
first come first served scheduling ( FCFS ) The dining process works as follows: Customer Arrival Seating Order (FCFS) Dining Completion
first come first served scheduling ( FCFS ) This restaurant's seating process is a real-life example of FCFS scheduling. It's a straightforward and fair way to manage customer seating, similar to how the FCFS scheduling algorithm works in operating systems.
first come first served scheduling ( FCFS ) FCFS scheduling may not always be the most efficient scheduling algorithm, and it doesn't take into account the length of time each customer will spend at the restaurant, which can lead to less-than-optimal resource utilization in some situations.
Shortest job first scheduling ( SJF ) and shortest remaining time first scheduling ( SRTF ) These are the best approaches to minimize the process waiting times. SJF is non-preemptive and SRTF is preemptive.
Shortest job first scheduling ( SJF ) and shortest remaining time first scheduling ( SRTF ) Waiting time (WT) is defined as the total time that is spent by the process while staying in a ready queue before it reaches the CPU. The difference between turnaround time and burst time is called the waiting time of a process
Shortest job first scheduling ( SJF ) and shortest remaining time first scheduling ( SRTF ) We will consider the same four processes and burst times as the above example (P1 = 23 ms , P2 = 4 ms , P3 = 9 ms , P4 = 3 ms ).
Shortest job first scheduling ( SJF ) With SJF, the process requiring the least CPU time is executed first. P4 will be first, then P2, P3 and P1. The ready queue will be: The average waiting time for a process will be:
shortest remaining time first scheduling ( SRTF ) With SRTF, the processes are placed in the ready queue as they arrive; but when a process with a shorter burst time arrives, the existing process is removed (pre-empted) from execution. shorter process is then executed first.
shortest remaining time first scheduling ( SRTF ) Let us consider the same four processes, including their arrival times
shortest remaining time first scheduling ( SRTF ) The ready queue will be: The average waiting time for a process will be:
Shortest job first scheduling ( SJF ) Imagine you are at a supermarket with multiple checkout lanes. The supermarket employs the SJF scheduling algorithm to decide which customer to serve next.
Shortest job first scheduling ( SJF ) Here's how it works: Customer Arrival Shortest Queue (SJF) Customer Service Completion
Shortest job first scheduling ( SJF ) This supermarket checkout process exemplifies SJF scheduling, where the checkout lanes represent processes (jobs) with varying execution times (items to purchase).
Shortest job first scheduling ( SJF ) By serving customers with the shortest shopping lists first, the supermarket aims to minimize waiting times, optimize resource utilization, and ensure efficient customer service.
Shortest job first scheduling ( SJF ) SJF scheduling is particularly useful when there are varying processing times for different tasks, and it helps ensure that shorter tasks are completed before longer ones, leading to reduced waiting times and improved overall system performance.
shortest remaining time first scheduling ( SRTF ) Consider an airport security checkpoint where passengers are waiting in line to go through security screening. The security checkpoint is equipped with multiple screening lanes, and airport staff employ an SRTF scheduling approach to determine which passenger to screen next.
shortest remaining time first scheduling ( SRTF ) Here's how it works: Passenger Arrival Remaining Screening Time SRTF Scheduling Preemption Completion
shortest remaining time first scheduling ( SRTF ) In this example, SRTF scheduling at the airport security checkpoint aims to minimize passenger waiting times and improve the efficiency of the screening process. By prioritizing passengers with the shortest remaining screening times, the security checkpoint can respond quickly to changing conditions, reduce delays, and maintain a smooth and efficient flow of passengers through the security screening process.
round robin A fixed time slice is given to each process; this is known as a quantum.
round robin Once a process is executed during its time slice, it is removed and placed in the blocked queue; then another process from the ready queue is executed in its own time slice
round robin for the same four processes, P1–P4, we get this ready queue:
round robin The average waiting time for a process is calculated as follows: P1: (39 – 23) = 16 ms P2: (9 – 4) = 5 ms P3: (26 – 9) = 17 ms P4: (17 – 3) = 14 ms
round robin average waiting time the average waiting times for the four scheduling routines, for P1–P4, are:
round robin In agricultural settings, irrigation systems can be designed to distribute water resources in a manner inspired by the Round Robin concept:
round robin Multiple Crop Fields Water Distribution System Allocation Time Quanta Round Robin Distribution Continuous Rotation Fair Resource Distribution
Scheduling routine algorithms
Interrupt handling and OS kernels Interrupt handling is a fundamental concept in operating systems, and it plays a crucial role in the operation of the OS kernel
Interrupt handling and OS kernels Interrupts are events or signals generated by hardware or software that require the immediate attention of the CPU. They can be triggered by various sources, including hardware devices (e.g., keyboard input, disk I/O, timer), system calls, and exceptions (e.g., division by zero, page faults)
Interrupt handling and OS kernels Interrupts serve as a mechanism for asynchronous events that need to be handled promptly.
Role of os kernel? The OS kernel is responsible for managing and responding to interrupts. It sets up interrupt handling routines and determines how to react when specific types of interrupts occur.
Interrupt Handling Process When an interrupt occurs, the CPU temporarily stops executing the current instruction and transfers control to a specific interrupt handler routine.
Interrupt Handling Process The interrupt handler, part of the kernel, processes the interrupt
Interrupt Handling Process It may involve tasks like saving the context of the interrupted program, servicing the interrupt (e.g., reading data from a device, handling a system call), and restoring the program's context.
Interrupt Handling Process After handling the interrupt, the CPU resumes execution from where it left off in the interrupted program
Types of Interrupts There are several types of interrupts, including hardware interrupts , software interrupts (system calls), and exceptions. Each type of interrupt has its own dedicated handler in the kernel.
Interrupt Priorities Some interrupts may have higher priorities than others. For example, a hardware error interrupt might take precedence over user input from a keyboard. The kernel must manage these priorities to ensure critical events are handled promptly.
Multiprocessing and Interrupts In multiprocessor systems, the kernel must coordinate interrupt handling across multiple CPUs. This involves distributing interrupt requests and ensuring that each CPU handles interrupts efficiently
Interrupt Vector Table The kernel maintains an interrupt vector table, which is a data structure that maps interrupt numbers to their corresponding interrupt service routines (handlers). When an interrupt occurs, the CPU looks up the appropriate handler in this table.
Device Drivers Device drivers, which are typically part of the kernel or closely integrated with it, play a critical role in handling hardware interrupts. They manage the communication between the OS and hardware devices, ensuring that data is transferred correctly and timely.
Synchronization and Protection The kernel must use synchronization mechanisms (e.g., locks, semaphores) to protect shared resources and data structures during interrupt handling. This is essential to prevent data corruption and race conditions.
Interrupt handling and OS kernels The CPU will check for interrupt signals. The system will enter the kernel mode if any of the following type of interrupt signals are sent: Device interrupt (for example, printer out of paper, device not present, and so on). Exceptions (for example, instruction faults such as division by zero, unidentified op code, stack fault, and so on). Traps/software interrupt (for example, process requesting a resource such as a disk drive).
Interrupt handling and OS kernels When an interrupt is received, the kernel will consult the interrupt dispatch table (IDT) – this table links a device description with the appropriate interrupt routine.
Interrupt handling and OS kernels IDT will supply the address of the low level routine to handle the interrupt event received. The kernel will save the state of the interrupt process on the kernel stack and the process state will be restored once the interrupting task is serviced.
Interrupt handling and OS kernels Interrupts will be prioritized using interrupt priority levels (IPL) (numbered 0 to 31). A process is suspended only if its interrupt priority level is greater than that of the current task.
Interrupt handling and OS kernels The process with the lower IPL is saved in the interrupt register and is handled (serviced) when the IPL value falls to a certain level. Examples of IPLs include: 31: power fail interrupt 24: clock interrupt 20-23: I/O devices
Interrupt handling and OS kernels
Memory management System software
Memory management As with the storage of data on a hard disk, processes carried out by the CPU may also become fragmented.
Memory management To overcome this problem, memory management will determine which processes should be in main memory and where they should be stored (this is called optimization);
Memory allocation methods Various memory allocation methods are used to achieve efficient use of available memory
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory In contiguous memory allocation, each process is allocated a contiguous block of memory. This method is simple but can lead to fragmentation issues, both external and internal. It's commonly used in early operating systems.
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory Paging divides physical memory and logical memory (used by processes) into fixed-size blocks or pages. Each page can be assigned to any available frame in physical memory . This method helps reduce external fragmentation and simplifies memory management
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory When a process is executed, process pages from logical memory are loaded into frames in physical memory . A page table is used; it uses page number as the index. Each process has its own separate page table that maps logical addresses to physical addresses .
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory The page table will show: page number flag status page frame address the time of entry (for example, in the form 08:25:55:08). The time of entry is important when considering page replacement algorithms
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory The goal of page replacement algorithms is to minimize the number of page faults and improve system performance.
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory Segmentation divides memory into logical segments, where each segment represents a different type of data or code. Processes can be allocated one or more segments. It provides better protection and flexibility but may still suffer from fragmentation
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory In segmented memory, logical address space is broken up into variable-size memory blocks/partitions called segments. Each segment has a name and size
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory For execution to take place, segments from logical memory are loaded into physical memory
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory The address is specified by the user which contains the segment name and offset value. The segments are numbered (called segment numbers) rather than using a name and this segment number is used as the index in a segment map table. T
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory The offset value decides the size of the segment: address of segment in physical memory space = segment number + offset value
Memory allocation methods Contiguous Memory Allocation Paging Segmentation Virtual Memory Virtual memory allows processes to use more memory than physically available. It combines paging and demand paging techniques to store parts of a process in secondary storage (e.g., disk) when not in use. This method increases memory utilization but introduces page faults.
Memory allocation Disk thrashing is a phenomenon in computer systems where there is excessive paging or swapping of pages between physical memory (RAM) and secondary storage (usually a hard disk) due to an inadequate amount of available physical memory. This results in a severe degradation of system performance.