Summary

This document explores operating system functions, focusing on memory management, processor management, device management, and file management. It also details user interfaces with a discussion of various operating system services.

Full Transcript

Functions of an Operating System Memory Management The operating system manages the Primary Memory or Main Memory. Main memory is made up of a large array of bytes or words where each byte or word is assigned a certain address. Main memory is fast storage and it can be accessed directly by the CPU....

Functions of an Operating System Memory Management The operating system manages the Primary Memory or Main Memory. Main memory is made up of a large array of bytes or words where each byte or word is assigned a certain address. Main memory is fast storage and it can be accessed directly by the CPU. For a program to be executed, it should be first loaded in the main memory. An Operating System performs the following activities for Memory Management: It keeps track of primary memory, i.e., which bytes of memory are used by which user program. The memory addresses that have already been allocated and the memory addresses of the memory that has not yet been used. In multiprogramming, the OS decides the order in which processes are granted memory access, and for how long. It Allocates the memory to a process when the process requests it and deallocates the memory when the process has terminated or is performing an I/O operation. Processor Management In a multi-programming environment, the OS decides the order in which processes have access to the processor, and how much processing time each process has. This function of OS is called Process Scheduling. An Operating System performs the following activities for Processor Management. Keeps track of the status of processes. The program which performs this task is known as a traffic controller. Allocates the CPU that is a processor to a process. De-allocates processor when a process is no more required. Device Management An OS manages device communication via its respective drivers. It performs the following activities for device management. Keeps track of all devices connected to the system. designates a program responsible for every device known as the Input/Output controller. Decides which process gets access to a certain device and for how long. Allocates devices effectively and efficiently. Deallocates devices when they are no longer required. File Management A file system is organized into directories for efficient or easy navigation and usage. These directories may contain other directories and other files. An Operating System carries out the following file management activities. It keeps track of where information is stored, user access settings, the status of every file, and more. These facilities are collectively known as the file system. User Interface or Command Interpreter The user interacts with the computer system through the operating system. Hence OS act as an interface between the user and the computer hardware. This user interface is offered through a set of commands or a graphical user interface (GUI). Through this interface, the user makes interaction with the applications and the machine hardware. Booting the Computer The process of starting or restarting the computer is known as booting. If the computer is switched off completely and if turned on then it is called cold booting. Warm booting is a process of using the operating system to restart the computer. Security The operating system uses password protection to protect user data and similar other techniques. it also prevents unauthorized access to programs and user data. Control Over System Performance Monitors overall system health to help improve performance. records the response time between service requests and system response to having a complete view of the system’s health. This can help improve performance by providing important information needed to troubleshoot problems. Computing Environments : When a problem is solved by the computer, during that computer uses many devices, arranged in different ways and which work together to solve problems. This constitutes a computing environment where various number of computer devices arranged in different ways to solve different types of problems in different ways. In different computing environments computer devices are arranged in different ways and they exchange information in between them to process and solve problem. One computing environment consists of many computers other computational devices, software and networks that to support processing and sharing information and solving task. Based on the organization of different computer devices and communication processes there exists multiple types of computing environments. Now let’s know about different types of computing environments. Types of Computing Environments: They are the various types of computing environments. They are: Personal Computing Environment: In personal computing environment there is a stand-alone machine. Complete program resides on computer and executed there. Different stand-alone machines that constitute a personal computing environment are laptops, mobiles, printers, computer systems, scanners etc. That we use at our homes and offices. Time-Sharing Computing Environment : In Time Sharing Computing Environment multiple users share system simultaneously. Different users (different processes) are allotted different time slice and processor switches rapidly among users according to it. For example, student listening to music while coding something in an IDE. Windows 95 and later versions, Unix, IOS, Linux operating systems are the examples of this time sharing computing environment. Client Server Computing Environment: In client server computing environment two machines are involved i.e., client machine and server machine, sometime same machine also serve as client and server. In this computing environment client requests resource/service and server provides that respective resource/service. A server can provide service to multiple clients at a time and here mainly communication happens through computer network. Distributed Computing Environment : In a distributed computing environment multiple nodes are connected together using network but physically they are separated. A single task is performed by different functional units of different nodes of distributed unit. Here different programs of an application run simultaneously on different nodes, and communication happens in between different nodes of this system over network to solve task. Grid Computing Environment : In grid computing environment, multiple computers from different locations works on single problem. In this system set of computer nodes running in cluster jointly perform a given task by applying resources of multiple computers/nodes. It is network of computing environment where several scattered resources provide running environment for single task. Cloud Computing Environment : In cloud computing environment on demand availability of computer system resources like processing and storage are availed. Here computing is not done in individual technology or computer rather it is computed in cloud of computers where all required resources are provided by cloud vendor. This environment primarily comprised of three services i.e software-as-a-service (SaaS), infrastructure-as-a-service (IaaS), and platform-as-a-service (PaaS). Cluster Computing Environment : In cluster computing environment cluster performs task where cluster is a set of loosely or tightly connected computers that work together. It is viewed as single system and performs task parallelly that’s why also it is similar to parallel computing environment. Cluster aware applications are especially used in cluster computing environment. What are Operating System Structure? For efficient performance and implementation, an OS should be partitioned into separate subsystems, each with carefully defined tasks, inputs, outputs, and performance characteristics. These subsystems can then be arranged in various architectural configurations. Simple StructureLayered Approach Micro kernelsModules Simple Structure There are several commercial systems that don’t have a well-defined structure such operating systems begin as small, simple & limited systems and then grow beyond their original scope. MS-DOS is an example of such a system. It was not divided into modules carefully. Another example of limited structuring is the UNIX operating system. Layered Approach Another approach is to break the OS into a number of smaller layers, each of which rests on the layer below it, and relies solely on the services provided by the next lower layer. This approach allows each layer to be developed and debugged independently, with the assumption that all lower layers have already been debugged and are trusted to deliver proper services. The problem is deciding what order in which to place the layers, as no layer can call upon the services of any higher layer, and so many chicken-and-egg situations may arise. Layered approaches can also be less efficient, as a request for service from a higher layer has to filter through all lower layers before it reaches the HW, possibly with significant processing at each step. Micro kernels The basic idea behind microkernels is to remove all non-essential services from the kernel and implement them as system applications instead, thereby making the kernel as small and efficient as possible. Most microkernels provide basic process and memory management, message-passing between other services, and not much more. Security and protection can be enhanced, as most services are performed in user mode, not kernel mode. System expansion can also be easier because it only involves adding more system applications, not rebuilding a new kernel. Mach was the first and most widely known microkernel, and now forms a major component of Mac OSX. Windows NT was originally a microkernel but suffered from performance problems relative to Windows 95. NT 4.0 improved performance by moving more services into the kernel, and now XP is back to being more monolithic. Another microkernel example is QNX, a real-time OS for embedded systems. Modules Modules are similar to layers in that each subsystem has clearly defined tasks and interfaces, but any module is free to contact any other module, eliminating the problems of going through multiple intermediary layers, as well as the chicken-and-egg problems. The kernel is relatively small in this architecture, similar to microkernels, but the kernel does not have to implement message passing since modules are free to contact each other directly. For example, the Solaris operating system structure is organized around a core kernel with seven. Types of loadable kernel modules: Scheduling classesFile systemsLoadable system callsExecutable formats STREAMS modulesMiscellaneousDevice and bus drivers What are Operating System Services? An Operating System supplies different kinds of services to both the users and to the programs as well. It also provides application programs (that run within an Operating system) an environment to execute it freely. It provides users the services run various programs in a convenient manner. These operating-system services are provided for the convenience of the programmer, to make the programming task easier. User Interface Program execution I/O Operation File system manipulation Communication Error handling Resource Management Protection User Interface Usually, an Operating system comes in three forms or types. Depending on the interface their types have been further subdivided. These are: Command line interface Batch based interface Graphical User Interface A view of operating system services The command-line interface (CLI) usually deals with using text commands and a technique for entering those commands. The batch interface (BI): commands and directives are used to manage those commands that are entered into files and those files get executed. Another type is the graphical user interface (GUI): which is a window system with a pointing device (like mouse or trackball) to point to the I/O, choose from menus driven interface, and to make choices viewing from a number of lists and a keyboard to enter the texts. Program execution The operating system handles many kinds of activities from user programs to system programs like printer spooler, name servers, file server, etc. Each of these activities is encapsulated as a process. A process includes the complete execution context (code to execute, data to manipulate, registers, OS resources in use). Following are the major activities of an operating system with respect to program management. Loads a program into memory. Executes the program. Handles program’s execution. Provides a mechanism for process synchronization. Provides a mechanism for process communication. Provides a mechanism for deadlock handling I/O Operation I/O subsystem comprised of I/O devices and their corresponding driver software. Drivers hides the peculiarities of specific hardware devices from the user as the device driver knows the peculiarities of the specific device. Operating System manages the communication between user and device drivers. Following are the major activities of an: Operating system with respect to I/O Operation. I/O operation means read or write operation with any file or any specific I/O device. Program may require any I/O device while running. Operating system provides the access to the required I/O device when required. File system manipulation A file represents a collection of related information. A computer can store files on the disk (secondary storage), for long-term storage purposes. A few examples of storage media are magnetic tape, magnetic disk, and optical disk drives like CDs, DVDs. Each of these media has its own properties like speed, capacity, data transfer rate, and data access methods. A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions. Following are the major activities of an operating system with respect to file management. Program needs to read a file or write a file. The operating system gives the permission to the program for operation on file. Permission varies from read-only, read-write, denied and so on. Operating System provides an interface to the user to create/delete files. Operating System provides an interface to the user to create/delete directories. Operating System provides an interface to create the backup of file system. Communication In the case of distributed systems which are a collection of processors that do not share a memory, peripheral devices, or a clock, the operating system manages communications between processes. Multiple processes with one another through communication lines in the network. OS handles routing and connection strategies, and the problems of contention and security. Following are the major: Activities of an operating system with respect to communication. Two processes often require data to be transferred between them. The both processes can be on the one computer or on different computer but are connected through computer network. Communication may be implemented by two methods either by Shared Memory or by Message Passing. Error handling The error can occur anytime and anywhere. An error may occur in the CPU, in I/O devices, or in the memory hardware. Following are the major activities of an operating system with respect to error handling. OS constantly remains aware of possible errors. OS takes the appropriate action to ensure correct and consistent computing. Resource Management In the case of a multi-user or multi-tasking environment, resources such as main memory, CPU cycles, and files storage are to be allocated to each user or job. Following are the major activities of an operating system with respect to resource management. OS manages all kind of resources using schedulers. CPU scheduling algorithms are used for better utilization of CPU. Protection Considering computer systems have multiple users the concurrent execution of multiple processes, then the various processes must be protected from each another’s activities. Protection refers to a mechanism or a way to control the access of programs, processes, or users to the resources defined by a computer system. Following are the major activities of an operating system with respect to protection. OS ensures that all access to system resources is controlled. OS ensures that external I/O devices are protected from invalid access attempts. OS provides authentication feature for each user by means of a password. What is System Program? System programs provide an environment where programs can be developed and executed. In the simplest sense, system programs also provide a bridge between the user interface and system calls. In reality, they are much more complex. For example, a compiler is a complex system program. The system program serves as a part of the operating system. It traditionally lies between the user interface and the system calls. The user view of the system is actually defined by system programs and not system calls because that is what they interact with and system programs are closer to the user interface. The user views the operating system observed as actually the system programs and not the system calls. System programs can be divided into seven parts. These are given as follows: Status Information: The status information system programs provide required data on the current or past status of the system. This may include the system date, system time, and available memory in the system, disk space, logged-in users, etc. Communications: These system programs are needed for system communications such as web browsers. Web browsers allow systems to communicate and access information from the network as required. File Modification: System programs that are used for file modification basically change the data in the file or modify it in some other way. Text editors are a big example of file modification system programs. File Manipulation: These system programs are used to manipulate system files. This can be done using various commands like create, delete, copy, rename, print etc. These commands can create files, delete files, copy the contents of one file into another, rename files, print them etc. Application Programs: Application programs can perform a wide range of services as per the needs of the users. These include programs for database systems, word processors, plotting tools, spreadsheets, games, scientific applications etc. Programming Language Support: These system programs provide additional support features for different programming languages. Some examples of these are compilers, debuggers etc. These compile a program and make sure it is error free respectively. What are System Calls? A system call is a programming interface for an application to request service from the operating system. A system call is a method used by application programs to communicate with the system core. In modern operating systems, this method is used if a user application or process needs to pass information onto the hardware, other processes, or the kernel itself, or if it needs to read information from these sources. This makes these calls a link between user mode and kernel mode, the two key access and security modes for processing CPU commands in computer systems. Types of System Calls The system call provides an interface to the operating system services. Application developers often do not have direct access to the system calls but can access them through an application programming interface (API). The functions that are included in the API invoke the actual system calls. There are six different categories of system calls: Process Control File Management Device Management Information Maintenance Communication Protection Process Control A process or job executing one program may want to load and execute another program. This feature allows the command interpreter to execute a program as directed by, for example, a user command, the click of a mouse, or a batch command. End, abort: A running program needs to be able to has its execution either normally (end) or abnormally (abort). Load, execute: A process or job executing one program may want to load and executes another program. Create Process, terminate process: There is a system call specifying for the purpose of creating a new process or job (create process or submit job). We may want to terminate a job or process that we created (terminates process, if we find that it is incorrect or no longer needed). Get process attributes, set process attributes: If we create a new job or process we should able to control its execution. This control requires the ability to determine & reset the attributes of a job or processes (get process attributes, set process attributes). Wait time: After creating new jobs or processes, we may need to wait for them to finish their execution (wait time). Wait event, signal event: We may wait for a specific event to occur (wait event). The jobs or processes then signal when that event has occurred (signal event). File Management We first need to be able to create and delete files. Either system call requires the name of the file and perhaps some of the file’s attributes. Once the file is created, we need to open it and use it. We may also read, write, or reposition (rewinding or skipping to the end of the file, for example). Finally, we need to close the file, indicating that we are no longer using it. There is a need to determine the file attributes – get and set file attribute. Many times the OS provides an API to make these system calls. These are as follow: Create file, delete file: We first need to be able to create & delete files. Both the system calls require the name of the file & some of its attributes. Open file, close file: Once the file is created, we need to open it & use it. We close the file when we are no longer using it. Read, write, reposition file: After opening, we may also read, write or reposition the file (rewind or skip to the end of the file). Get file attributes, set file attributes: For either files or directories, we need to be able to determine the values of various attributes & reset them if necessary. Two system calls get file attribute & set file attributes are required for their purpose. Device Management A process may need several resources to execute—main memory, disk drives, access to files, and so on. These resources are also thought of as devices. Some are physical, such as a video card, and others are abstract, such as a file. User programs request the device, and when finished they release the device. Once the device has been requested and allocated to us, we can read, write, and (possibly) reposition the device, just as we can with files. Request device, release device: If there are multiple users of the system, we first request the device. After we finished with the device, we must release it. Read, write, reposition: Once the device has been requested & allocated to us, we can read, write & reposition the device. Information Maintenance The operating system keeps the information about all its processes, and system calls are used to access this information. Generally, calls are also used to reset the process information (get process attributes and set process attributes). Some system calls exist purely for transferring information between the user program and the operating system. An example of this is time or date. The OS also keeps the information about all its processes and provides system calls to report this information. Get time or date, set time or date: Most systems have a system call to return the current date & time or set the current date & time. Get system data, set system data: Other system calls may return information about the system like number of current users, version number of OS, amount of free memory etc. Get process attributes, set process attributes: The OS keeps information about all its processes & there are system calls to access this information. Communication There are two modes of communication such as: Message passing model: Information is exchanged through an inter process Communication facility provided by operating system. Each computer in a network has a name by which it is known. Similarly, each process has a process name which is translated to an equivalent identifier by which the OS can refer to it. The get host id and get processed systems calls to do this translation. These identifiers are then passed to the general purpose open & close calls provided by the file system or to specific open connection system call. Shared memory model: processes use map memory system calls to access regions of memory owned by other processes. They exchange information by reading & writing data in the shared areas. The processes ensure that they are not writing to the same location simultaneously. Protection Protection provides a mechanism for controlling access to the resources provided by a computer system. Historically, protection was a concern only on multi-programmed computer systems with several users. However, with the advent of networking and the Internet, all computer systems, from servers to PDAs, must be concerned with protection. Typically, system calls providing protection include Set permission and get permission, which manipulate the permission settings of resources such as files and disks. Allow user and deny user system calls specify whether particular users can—or cannot—be allowed access to certain resources. Operating systems and user interfaces An operating system is a collection (or suite) of programs that manages and controls the computer. Operating systems have many functions: controlling hardware components providing a platform for software to run on providing a user interface multitasking facilities managing the computer's memory managing peripherals managing files managing users Example operating systems include: Microsoft Windows Apple OS X Linux Android IOS User interfaces A user interface is a program, or suite of programs that allows a user to interact with a computer. There are three types of interface to be considered: graphical user interface (GUI) - sometimes known as WIMP (Windows, Icons, Menus, Pointers) interface mobile user interface (Mobile UI) command line interface (CLI) A graphical user interface is familiar to most users of PCs and laptops. GUIs feature a desktop where everything is displayed. Applications run in Windows, and all objects (apps, hardware and files) are represented by icons. Application features are accessible through the use of menus. Users interact with the interface by using a mouse and on-screen pointer. GUIs are powerful and easy to use, but require a lot of processing power. Mobile UIs are similar in many ways to GUIs, except that they respond to touch. Fingers are used to open programs and interact with them. Gestures such as swiping are used to scroll within documents. Pinching and stretching are used to re-size images. Mobile UIs are found on smartphones and tablets. Command line interfaces are text-based. Users control the computer by typing in commands. CLIs require little processing power and are extremely powerful, but are difficult to use. Originally most interfaces were CLIs, and they still exist within modern operating systems, for example the command prompt app in Windows, and Terminal in OS X Process A process is basically a program in execution. The execution of a process must progress in a sequential fashion. A process is defined as an entity which represents the basic unit of work to be implemented in the system. To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data. The following image shows a simplified layout of a process inside main memory − S.N. Component & Description 1 Stack The process Stack contains the temporary data such as method/function parameters, return address and local variables. 2 HeapThis is dynamically allocated memory to a process during its run time. 3 Text This includes the current activity represented by the value of Program Counter and the contents of the processor's registers. 4 DataThis section contains the global and static variables. Program A program is a piece of code which may be a single line or millions of lines. A computer program is usually written by a computer programmer in a programming language. For example, here is a simple program written in C programming language − A computer program is a collection of instructions that performs a specific task when executed by a computer. When we compare a program with a process, we can conclude that a process is a dynamic instance of a computer program. A part of a computer program that performs a well-defined task is known as an algorithm. A collection of computer programs, libraries and related data are referred to as a software. Process Life Cycle When a process executes, it passes through different states. These stages may differ in different operating systems, and the names of these states are also not standardized. In general, a process can have one of the following five states at a time. S.N. State & Description 1 Start This is the initial state when a process is first started/created. 2 Ready The process is waiting to be assigned to a processor. Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. Process may come into this state after Start state or while running it by but interrupted by the scheduler to assign CPU to some other process. 3 Running Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions. 4 Waiting Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available. 5 Terminated or Exit Once the process finishes its execution, or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory. Process Control Block (PCB) A Process Control Block is a data structure maintained by the Operating System for every process. The PCB is identified by an integer process ID (PID). A PCB keeps all the information needed to keep track of a process as listed below in the table − S.N. Information & Description 1 Process StateThe current state of the process i.e., whether it is ready, running, waiting, or whatever. 2 Process privilegesThis is required to allow/disallow access to system resources. 3 Process IDUnique identification for each of the process in the operating system. 4 PointerA pointer to parent process. 5 Program CounterProgram Counter is a pointer to the address of the next instruction to be executed for this process. 6 CPU registersVarious CPU registers where process need to be stored for execution for running state. 7 CPU Scheduling Information Process priority and other scheduling information which is required to schedule the process. 8 Memory management information This includes the information of page table, memory limits, and Segment table depending on memory used by the operating system. 9 Accounting information This includes the amount of CPU used for process execution, time limits, execution ID etc. 10 IO status informationThis includes a list of I/O devices allocated to the process. The architecture of a PCB is completely dependent on Operating System and may contain different information in different operating systems. Here is a simplified diagram of a PCB − The PCB is maintained for a process throughout its lifetime, and is deleted once the process terminates Definition The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. Process scheduling is an essential part of a Multiprogramming operating systems. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing. Process Scheduling Queues The OS maintains all PCBs in Process Scheduling Queues. The OS maintains a separate queue for each of the process states and PCBs of all processes in the same execution state are placed in the same queue. When the state of a process is changed, its PCB is unlinked from its current queue and moved to its new state queue. The Operating System maintains the following important process scheduling queues − Job queue − This queue keeps all the processes in the system. Ready queue − This queue keeps a set of all processes residing in main memory, ready and waiting to execute. A new process is always put in this queue. Device queues − The processes which are blocked due to unavailability of an I/O device constitute this queue. The OS can use different policies to manage each queue (FIFO, Round Robin, Priority, etc.). The OS scheduler determines how to move processes between the ready and run queues which can only have one entry per processor core on the system; in the above diagram, it has been merged with the CPU. Two-State Process Model Two-state process model refers to running and non-running states which are described below − S.N. State & Description 1 Running When a new process is created, it enters into the system as in the running state. 2 Not Running Processes that are not running are kept in queue, waiting for their turn to execute. Each entry in the queue is a pointer to a particular process. Queue is implemented by using linked list. Use of dispatcher is as follows. When a process is interrupted, that process is transferred in the waiting queue. If the process has completed or aborted, the process is discarded. In either case, the dispatcher then selects a process from the queue to execute. Schedulers Schedulers are special system software which handle process scheduling in various ways. Their main task is to select the jobs to be submitted into the system and to decide which process to run. Schedulers are of three types − Long-Term Scheduler Short-Term Scheduler Medium-Term Scheduler Long Term Scheduler It is also called a job scheduler. A long-term scheduler determines which programs are admitted to the system for processing. It selects processes from the queue and loads them into memory for execution. Process loads into the memory for CPU scheduling. The primary objective of the job scheduler is to provide a balanced mix of jobs, such as I/O bound and processor bound. It also controls the degree of multiprogramming. If the degree of multiprogramming is stable, then the average rate of process creation must be equal to the average departure rate of processes leaving the system. On some systems, the long-term scheduler may not be available or minimal. Time-sharing operating systems have no long term scheduler. When a process changes the state from new to ready, then there is use of long-term scheduler. Short Term Scheduler It is also called as CPU scheduler. Its main objective is to increase system performance in accordance with the chosen set of criteria. It is the change of ready state to running state of the process. CPU scheduler selects a process among the processes that are ready to execute and allocates CPU to one of them. Short-term schedulers, also known as dispatchers, make the decision of which process to execute next. Short-term schedulers are faster than long-term schedulers. Medium Term Scheduler Medium-term scheduling is a part of swapping. It removes the processes from the memory. It reduces the degree of multiprogramming. The medium-term scheduler is in-charge of handling the swapped out-processes. A running process may become suspended if it makes an I/O request. A suspended processes cannot make any progress towards completion. In this condition, to remove the process from memory and make space for other processes, the suspended process is moved to the secondary storage. This process is called swapping, and the process is said to be swapped out or rolled out. Swapping may be necessary to improve the process mix. Comparison among Scheduler S Long-Term Short-Term Medium-Ter. Scheduler Scheduler m Scheduler N. 1 It is a job It is a CPU It is a scheduler scheduler process swapping scheduler. 2 Speed is lesser Speed is fastest Speed is in than short term among other two between both scheduler short and long term scheduler. 3 It controls the It provides lesser It reduces the degree of control over degree degree of multiprogrammi of multiprogra ng multiprogramming mming. 4 It is almost It is also minimal It is a part of absent or in time sharing Time sharing minimal in time system systems. sharing system 5 It selects It selects those It can processes from processes which re-introduce pool and loads are ready to the process them into execute into memory memory for and execution execution can be continued. Context Switch A context switch is the mechanism to store and restore the state or context of a CPU in Process Control block so that a process execution can be resumed from the same point at a later time. Using this technique, a context switcher enables multiple processes to share a single CPU. Context switching is an essential part of a multitasking operating system features. When the scheduler switches the CPU from executing one process to execute another, the state from the current running process is stored into the process control block. After this, the state for the process to run next is loaded from its own PCB and used to set the PC, registers, etc. At that point, the second process can start executing. Context switches are computationally intensive since register and memory state must be saved and restored. To avoid the amount of context switching time, some hardware systems employ two or more sets of processor registers. When the process is switched, the following information is stored for later use. Program Counter Scheduling information Base and limit register value Currently used register Changed State I/O State information Accounting information Context switch occurs when: A process with a higher priority than the running process enters the ready state. An Interrupt happens The user mode and kernel-mode switch. Though context switching doesn’t usually happen in this situation. We use preemptive CPU scheduling.

Use Quizgecko on...
Browser
Browser