Some popular Operating Systems include Linux, Unix, Windows, MS-DOS, Android, etc.

Size: px
Start display at page:

Download "Some popular Operating Systems include Linux, Unix, Windows, MS-DOS, Android, etc."

Transcription

1 1.1 Operating System Definition An Operating System (OS) is an interface between a computer user and computer hardware. An operating system is a software which performs all the basic tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives and printers. The operating system can also be defined as a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs. Some popular Operating Systems include Linux, Unix, Windows, MS-DOS, Android, etc. 1.2 Operating system goals: 1. Make the computer system convenient to use. 2. Execute user programs and make solving user problems easier. The OS manages the execution of programs to prevent errors and improper use of computer. 3. Use the computer hardware in an efficient manner. We begin our discussion by looking at the operating system's role in the overall computer system. A computer system can be divided roughly into four components: the hardware, the operating system, the application programs, and the users as shown in figure 1. Fig. 1: The components of a computer system

2 1. User: is any person that desire work to be done by a computer. The user could be a programmer, an OS designer or an end user. The user's view of the computer varies according to the interface being used. Personal Computer (PC): most computer users sit in front of a PC consisting of a monitor/ keyboard/ mouse, and system unit. In this case, the OS is designed for ease of use (attention paid to performance but none paid to resource utilization). Mainframes: users sit at a terminal connected to mainframe where the terminal consists of a keyboard and a video display. Many users are accessing the same main computer through these terminals. These users share resources and may exchange information. In this case the OS is designed to maximize resource utilization. Workstation: users sit at workstation connected to networks of other workstations and servers. These users have dedicated resources at their disposal, but they also share resources such as print servers. Therefore, their OS is designed to compromise between individual usability and resource utilization. 2. The Hardware consists of the CPU, the memory and the input/output (I/O) devices which provides the basic computing resources for the system. These resources are used to solve the computing problems of the users and divide into sharable and non-sharable resources. Sharable resources can be used by several processes at the same time which include CPU, read only files, data protected against any modification, etc. While the use of the Non-sharable resources is restricted to one process at a time which include writeable files, data area which is subject to modification, etc. The OS is designed to acts as a manager of these resources (Resource Allocator). The OS must decide how to allocate these resources to specific user (or program) so that it can operate fairly and efficiently. 3. The Software can be divided into system software and application software. - The Application software such as (word processors, compilers, games and web browsers) define the ways in which the resources are used to solve users' computing problems. The OS manages the execution of programs to prevent errors and improper use of computer. - The system software comprises of OS and utility system. The utility system is a set of system programs which is used to assist program creation, the management of files,

3 the control of I/O devices, etc. The programmer will make use of these facilities in developing application and while the application is running, will invoke the utilities to perform certain functions. Examples of these programs are: Compiler: is a program that translate a source program written in some high level programming language (such as C) into low level language (such as assembly and machine language). In contrast, the interpreter translates and executes each line of source code in succession, without looking at entire program. Linker: is an OS utility that takes one or more object files generated by a compiler and combine them together into a single executable program. Loader: an OS utility that is responsible for loading programs from storage device into main memory, where they can be executed. Once loading is complete, the OS starts the program by passing control to the loaded program code. 1.3 Computer System Organization Figure 2 shows the organization of modern computer system which consists of: CPU - the processor that performs the actual computation I/O devices - terminal, disks, video board, printer, etc. Memory - RAM containing data and programs used by the CPU System bus - the communication medium between the CPU, memory, and peripherals Fig 2: Computer System Organization

4 1.3.1 Computer System Operation Computer Startup - When the computer is powered up, it needs an initial program to run. This initial program called bootstrap which is loaded at power up or reboot. - Typically, the bootstrap is stored in ROM or EPROM known by the general term FIRMWARE within the computer hardware. - It initializes all aspects of the system, from CPU registers to device controllers to memory contents. - The bootstrap program must know how to load the OS and how to start executing that system. To accomplish this goal, the bootstrap locates and loads the OS kernel into memory and start execution. Kernel is the lowest level of any OS and it is running at all times on the computer). Interrupt Once the kernel's loaded, the OS then starts executing the first process and waits for some event to occur. The occurrence of an event is usually signaled by an interrupt from either the hardware or the software. - An interrupt is a signal to the processor indicating that an event was occurred and needs immediate attention. - An interrupt alerts the processor to a high priority condition (i.e. requiring stop the execution of the current process and do something else). - The processor responds by suspending its current process, saving its state and executing a small program called an interrupt handler or (interrupt service routine ISR) to deal with the event. This interruption is temporary and after the interrupt handler finishes the processor resumes execution of the previous process. - For each type of interrupt, separate segments of code in the OS determine what action should be taken. Therefore, we can say that each interrupt has its own ISR. There are two types of interrupts - A hardware generated interrupt is an electronic signal sent to the processor (usually by way of the system bus) from the computer itself or from an external peripheral. Hardware generated interrupt examples: Pressing a key on the keyboard

5 Moving the mouse Disk controller will interrupt the CPU when I/O operation has completed Timer interrupt - A software generated interrupt is caused by an exceptional condition in the processor itself, or a special instruction set which causes an interrupt when it is executed. Software generated interrupt examples Division by zero System call Access to a bad memory address. Interrupts are an important part of a computer architecture. Each computer design has its own interrupt mechanism, but several functions are common such as: The interrupt transfers control to the ISR generally through the interrupt vector which contains the addresses of all the service routines. This vector is stored in low memory (the first hundred or so locations). The interrupt architecture must also save the address of the interrupted instruction. Incoming interrupt may be disabled while another interrupt is being processed to prevent a lost interrupt. After the interrupt is serviced, the saved return address is loaded into the program counter, and the interrupted computation resumes as though the interrupt had not occurred. An OS is interrupt driven Storage Structure The CPU can load instructions only from memory, so any programs to run must be loaded from secondary storage and stored in the main memory (RAM). Because the ROM cannot be changed, only static programs are stored there. EEPROM cannot be changed frequently and so contains mostly static programs. For example, smartphones have EEPROM to store their factory-installed programs. All forms of memory provide an array of words. Each word has its own address.

6 Ideally, we want the programs and data to reside in main memory permanently. This arrangement usually is not possible for the following two reasons: - Main memory is usually too small to store all needed programs and data permanently. - Main memory is a volatile storage device that loses its contents when power is turned off or otherwise lost. Most computer systems provide Secondary Storage as an extension of main memory. The main requirement for secondary storage is that it be able to hold large quantities of data permanently (non-volatile storage). The most common secondary-storage device is Magnetic disk a which provides storage for both programs and data. - Disk surface is logically divided into tracks, which are subdivided into sectors. - The disk controller determines the logical interaction between device and computer. The wide variety of storage systems in a computer system can be organized in a hierarchy (Figure 3) according to speed, cost and volatility. The higher levels are expensive, but they are fast. Figure 3. Storage Hierarchy Cache: is a very high speed temporary storage system. - Caching: copying information into faster storage system (main memory can be viewed as a last cache for secondary storage). - Caching: important principle which performed at many levels in a computer (hardware, OS and Software). - Information is copied from slower to faster storage temporary.

7 - Faster storage (cache)checked first to determine if information is there. If it is, then the information used directly from the cache (fast). If not, then data copied from the main storage to cache under the assumption that we will need it again I/O Structure One of the important jobs of an OS is to manage various I/O devices including mouse, keyboards, touch pad, disk drives, USB device, printers etc. An I/O system is required to take an application I/O request and send it to the physical device, then take whatever response comes back from the device and send it to the application. I/O devices can be divided into two categories: 1. Block devices: A block device is one with which the driver communicates by sending entire blocks of data. For example, Hard disks, USB cameras, etc. 2. Character devices: A character device is one with which the driver communicates by sending and receiving single characters. Device Controller - Device drivers are software modules that can be plugged into an OS to handle a particular device that is attached to a computer. Operating System takes help from device drivers to handle all I/O devices. When a new hardware device is added to the computer such as a printer, a camera or a scanner, its driver must be installed in order to run it. - The Device Controller works like an interface between a device and a device driver. I/O units (Keyboard, mouse, printer, etc.) typically consist of a mechanical component and an electronic component where electronic component is called the device controller. - There is always a device controller and a device driver for each device to communicate with the Operating Systems. A device controller may be able to handle multiple devices. - Any device connected to the computer is connected by a plug and socket, and the socket is connected to a device controller. - Each device controller maintain some local buffer and a set of special purpose register.

8 Synchronous vs Asynchronous I/O - Synchronous I/O In this scheme CPU execution waits while I/O proceeds - Asynchronous I/O I/O proceeds concurrently with CPU execution Direct Memory Access (DMA) The CPU must have a way to pass information (communicate) to and from an I/O device. One of the approaches used to communicate is Direct memory access. Slow devices like keyboards will generate an interrupt to the main CPU after each byte is transferred. If a fast device such as a disk generated an interrupt for each byte, the OS would spend most of its time handling these interrupts. So a typical computer uses DMA hardware to reduce this overhead. Direct Memory Access (DMA) means CPU grants I/O module authority to read from or write to memory without involvement. DMA module itself controls exchange of data between main memory and the I/O device. CPU is only involved at the beginning and end of the transfer and interrupted only after entire block has been transferred. Direct Memory Access needs a special hardware called DMA controller (DMAC) that manages the data transfers and arbitrates access to the system bus. The controllers are programmed with source and destination pointers (where to read/write the data), counters to track the number of transferred bytes, and settings, which includes I/O and memory types, interrupts and states for the CPU cycles.

9 The OS uses the DMA hardware as follows: 1. Device driver is instructed to transfer disk data to a buffer address X. 2. Device driver then instruct disk controller to transfer data to buffer. 3. Disk controller starts DMA transfer. 4. Disk controller sends each byte to DMA controller. 5. DMA controller transfers bytes to buffer, increases the memory address, decreases the counter C until C becomes zero. 6. When C becomes zero, DMA interrupts CPU to signal transfer completion. 7. The device driver then return control to OS.

10 2.1 Operating System Components Following are some of important functions of an OS. 1. Process Management - A process is a program in execution. - We emphasizes that a program by itself is not a process; a program is a passive entity, such as contents of a file stored on disk whereas a process is an active entity (stored in memory). - Allocates certain resources that needs by a process to accomplish its task, such as CPU, memory, I/O, etc. - The OS realizes all resources allocated to a process when a process is no longer required. - A system task such as data transfer by bus is also called a process. The major activities of an OS in regard to process management are: Scheduling processes on the CPU Creation and deletion of user and system processes. Suspension and resumption of processes. A mechanism for process synchronization. A mechanism for process communication. A mechanism for deadlock handling. 2. Memory Management Memory management refers to management of Primary Memory or Main Memory. Main memory is a large array of words or bytes where each word or byte has its own address. Main memory provides a fast storage that can be accessed directly by the CPU. For a program to be executed, it must in the main memory. An OS does the following activities for memory management: Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part are not in use. In multiprogramming, the OS decides which process will get memory when and how much. Allocates the memory when a process requests it to do so. De-allocates the memory when a process no longer needs it or has been terminated.

11 3. Storage management File Management A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directories. Computer can store files on the disk (secondary storage), which provide long term storage. An OS does the following activities for file management: o The creation and deletion of files. o The creation and deletion of directories. o The support of primitives for manipulating files and directions. o The mapping of files onto secondary storage. o The backup of files on stable (non-volatile) storage media. Device Management (I/O System Management) An Operating System manages device communication via their respective drivers. It does the following activities for device management: o Keeps tracks of all devices. The program responsible for this task is known as the I/O controller. o Decides which process gets the device when and for how much time. o Allocates the device in the most efficient way. o De-allocates devices. Secondary (Mass)-Storage Management Usually disk used to store data that must be kept for a long period of time. An OS activities includes: o Free space management o Storage allocation o Disk scheduling

12 4. Other Important Activities Following are some of the important activities that an OS performs: Security -- By means of password and similar other techniques, it prevents unauthorized access to programs and data. Control over system performance -- Recording delays between request for a service and response from the system. Job accounting -- Keeping track of time and resources used by various jobs and users. Error detecting aids -- Production of dumps, traces, error messages, and other debugging and error detecting aids. Coordination between other software and users -- Coordination and assignment of compilers, interpreters, assemblers and other software to the various users of the computer systems. 2.2 Operating System Types In this section, we will discuss some of the important types of operating systems which are most commonly used. 1. Batch Operating System The users of a batch OS do not interact with the computer directly. Each user prepares his job on an off-line device like punch cards and submits it to the computer operator. To speed up processing, jobs with similar needs are batched together and run as a group. The programmers leave their programs with the operator and the operator then sorts the programs with similar requirements into batches. The problems with Batch Systems are as follows: Lack of interaction between the user and the job. CPU is often idle (inefficient), because the speed of the mechanical I/O devices is slower than the CPU. Difficult to provide the desired priority.

13 Batch Processing Batch processing is a technique in which an OS collects the programs and data together in a batch before processing starts. An OS does the following activities related to batch processing: The OS defines a job which has predefined sequence of commands, programs and data as a single unit. The OS keeps a number a jobs in memory and executes them without any manual information. Jobs are processed in the order of submission, i.e., first come first served fashion. When a job completes its execution, its memory is released and the output for the job gets copied into an output spool for later printing or processing. Advantages Batch processing takes much of the work of the operator to the computer. Increased performance as a new job get started as soon as the previous job is finished, without any manual intervention. Suitable for large jobs. Disadvantages Difficult to debug programs. A job could enter an infinite loop. Due to lack of protection scheme, one batch job can affect other pending jobs.

14 2. Multi-Programmed Batch Operating System Sharing the processor, when two or more programs reside in memory at the same time, is referred as multiprogramming. Multiprogramming assumes a single shared processor. Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute. The following figure shows the memory layout for a multiprogramming system. An OS does the following activities related to multiprogramming. The OS keeps several jobs in memory at a time. These jobs are ready to execute The OS picks and begins to execute one of the jobs in the memory while the others are waiting their turn. When that job has to wait (such as I/O operation), the OS switches the CPU to the second job and executes it. When that job needs to wait, the CPU is switched to the third and so on. The rapid switching back and forth is called Multiprogramming. Advantage High and efficient CPU utilization. User feels that many programs are allotted CPU almost simultaneously.

15 Disadvantages CPU scheduling is required. To accommodate many jobs in memory, memory management is required. 3. Time-sharing Operating Systems Time-sharing is a technique which enables many people, located at various terminals, to use a particular computer system at the same time. Time-sharing or multitasking is a logical extension of multiprogramming. Processor's time which is shared among multiple users simultaneously is termed as time-sharing. The main difference between Multi-programmed Batch Systems and Time-Sharing Systems is that in case of Multi-programmed batch systems, the objective is to maximize processor use, whereas in Time-Sharing Systems, the objective is to minimize response time. Multiple jobs are executed by the CPU by switching between them, but the switches occur so frequently. Thus, the user can interact with each job while it is running and also can receive an immediate response. When the user submits the command, the response time is in few seconds at most. As the system switches CPU rapidly from one user/program to the next, each user is given the impression that he/she has his/her own CPU, whereas actually one CPU is being shared among many users.

16 The OS uses CPU scheduling and multiprogramming to provide each user with a small portion of a time. Computer systems that were designed primarily as batch systems have been modified to time-sharing systems. This type of OS was developed to provide interactive use of a computer system at a reasonable cost. Each user has at least one separate program in memory. Interactivity Interactivity refers to the ability of users to interact with a computer system. An Operating system does the following activities related to interactivity: Provides the user an interface to interact with the system. Manages input devices to take inputs from the user. For example, keyboard. Manages output devices to show outputs to the user. For example, Monitor. The response time of the OS needs to be short, since the user submits and waits for the result. 4. Parallel System (Microprocessor Systems) Some times are called highly coupled systems. A system which has more than one CUPs that are shared the same computer buses, I/O devices, clock and memory. This type of OS is very efficiency. There are several reasons for developing this type of system: Increases throughputs (the number of processes that are completed per unit of time). Increase reliability (if one of the processes be idle, then its job will be done by the other processes that are running correctly). Save cost Speed up 5. Distributed Operating System Distributed systems use multiple central processors to serve multiple real-time applications and multiple users. Data processing jobs are distributed among the processors accordingly.

17 The processors communicate with one another through various communication lines (such as high-speed buses or telephone lines) and also each processor has its own memory and clock. These are referred as loosely coupled systems or distributed systems. Processors in a distributed system may vary in size and function. These processors are referred as sites, nodes, computers, and so on. The advantages of distributed systems are as follows: With resource sharing facility, a user at one site may be able to use the resources available at another. Speedup the exchange of data with one another via electronic mail. If one site fails in a distributed system, the remaining sites can potentially continue operating. Better service to the customers. Reduction of the load on the host computer. Reduction of delays in data processing. 6. Real-Time Operating System A real-time system is defined as a data processing system in which the time interval required to process and respond to inputs is so small that it controls the environment. The time taken by the system to respond to an input and display of required updated information is termed as the response time. So in this method, the response time is very less as compared to online processing. Real-time systems are used when there are rigid time requirements on the operation of a processor or the flow of data and real-time systems can be used as a control device in a dedicated application. A real-time operating system must have well-defined, fixed time constraints, otherwise the system will fail. For example, Scientific experiments, medical imaging systems, industrial control systems, weapon systems, robots, air traffic control systems, etc. An operating system does the following activities related to real-time system activity. In such systems, Operating Systems typically read from and react to sensor data.

18 The Operating system must guarantee response to events within fixed periods of time to ensure correct performance. 2.3 Operating System Services An OS provides services to both the users and to the programs. It provides programs an environment to execute. It provides users the services to execute the programs in a convenient manner. Following are a few common services provided by an operating system: Program execution I/O operations File System manipulation Communication Error Detection Resource Allocation Protection 1. Program Execution 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 OS with respect to program management: Loads a program into memory Executes the program (run it) Handles program's execution The program must be able to end its execution, either normally or abnormally (indicating error). 2. I/O Operation An I/O subsystem comprises of I/O devices and their corresponding driver software. An OS manages the communication between user and device drivers. I/O operation means read or write operation with any file or any specific I/O device. OS provides the access to the required I/O device when required.

19 3. File System Manipulation A file represents a collection of related information. Computers can store files on the disk (secondary storage), for long-term storage purpose. 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 OS with respect to file management: Program needs to read a file or write a file. The OS gives the permission to the program for operation on file. Permission varies from read-only, read-write, denied, and so on. OS provides an interface to the user to create/delete files. OS provides an interface to the user to create/delete directories. 4. Communication In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, the OS manages communications between all the processes. Multiple processes communicate with one another through communication lines in the network. Following are the major activities of an OS with respect to communication: Two processes often require data to be transferred between them. Both the processes can be on one computer or on different computers, but are connected through a computer network. Communication may be implemented by two methods, either by Shared Memory or by Message Passing. 5. Error Handling Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the memory hardware. Following are the major activities of an OS with respect to error handling: The OS constantly checks for possible errors. The OS takes an appropriate action to ensure correct and consistent computing. 6. Resource Management (Resource allocation) In case of 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 OS with respect to resource management:

20 The OS manages all kinds of resources using schedulers. CPU scheduling algorithms are used for better utilization of CPU. Protection Considering a computer system having multiple users and concurrent execution of multiple processes, the various processes must be protected from each other'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 OS with respect to protection: The OS ensures that all access to system resources is controlled. The OS ensures that external I/O devices are protected from invalid access attempts. The OS provides authentication features for each user by means of passwords.

21 3.1 Process A process is basically a program in execution. The process can be also 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: Figure 1. Process in Memory 1. Stack: The process Stack contains the temporary data such as method/function parameters, return address, and local variables. 2. Heap: This is a dynamically allocated memory to a process during its runtime. 3. Text: This includes the current activity represented by the value of Program Counter and the contents of the processor's registers. 4. Data: This section contains the global and static variables.

22 3.1.1 Process Life Cycle (Process State) When a process executes, it passes through different states (it changes state). 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. 1. Start (New): 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 OS so that they can run. Process may come into this state after Start state or while running it 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 waiting for user input, or waiting for a file to become available. Note that a process is unable to run until some external event happens. 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. Figure 2: Diagram of Process State

23 3.1.2 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: 1. Process State: The current state of the process i.e., whether it is ready, running, waiting, or whatever. 2. Process privileges: This is required to allow/disallow access to system resources. 3. Process ID: Unique identification for each of the process in the operating system. 4. Pointer: to the next PCB in a certain queue. to the process's parent and its children. 5. Program Counter: Program Counter is a pointer to the address of the next instruction to be executed for this process. 6. CPU registers: Various 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, 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 information: This includes a list of I/O devices allocated to the process. The architecture of a PCB is completely dependent on OS and may contain different information in different OS. Figure 3 illustrates a simplified diagram of a PCB. The PCB is maintained for a process throughout its lifetime, and is deleted once the process terminates.

24 Figure 3: Process Control Block (PCB) Context Switch A context switch is the mechanism to store and restore the state or context of a CPU in Process Control block (PCB) 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 OS 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, as shown in figure 4. 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.

25 Figure 4: CPU Switches from One Process to Another 3.2 Process Scheduling 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 OS. Such OS 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 (linked lists of PCBs). 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.

26 The OS maintains the following important process scheduling queues: Job queue - This queue keeps all the processes in the system (any process enters the system, it is put into a job queue). Ready queue - This queue keeps a set of all processes residing in main memory and are ready to execute. This queue is stored as a linked list. A ready queue header contains pointers to the first and final PCBs in the list. Figure 5: Ready Queue Device queues - The processes which are blocked due to unavailability of an I/O device constitute this queue. Figure 6: Process Scheduling Queues. The OS can use different techniques to manage each queue (FIFO, Priority, etc.).

27 Process Scheduling Representation A common representation of process scheduling is a queuing diagram, such as that in Figure 7. Each rectangular box represents a queue. Two types of queues are present: the ready queue and a set of device queues. The circles represent the resources that serve the queues, and the arrows indicate the flow of processes in the system. A new process is initially put in the ready queue. It waits there until it is selected for execution, or is dispatched. Once the process is allocated the CPU and is executing, one of several events could occur: The process could issue an I/O request and then be placed in an I/O queue. The process could create a new sub-process and wait for the sub-process's termination. The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue. Figure 7: Queuing-diagram representation of process scheduling 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. To put it in a simple term, the OS scheduler determines how to move processes between the ready and run queues. Schedulers are of three types:

28 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 processes should be brought from secondary storage into main memory for execution. It selects processes from the queue (ready 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 (CPU) bound. Processes can be described as either I/O-bound program (spends more time doing I/O than computation) or CPU-bound program (spends more time doing computation). If all selected processes are I/O-bound the CPU will be idle and if all selected processes are CPU-bound then the I/O device will go unused. Therefore, the system with the best performance will have a combination of CPU-bound and I/O bound processes Another objective of the job scheduler is to controls the degree of multiprogramming (the number of processes in memory). 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 OS 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 (dispatches from ready queue). CPU scheduler selects a process among the processes that are ready to execute and allocates CPU to one of them.

29 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. The key idea behind a medium-term scheduler is that sometimes it can be advantageous to remove processes from memory (and from active contention for the CPU) and thus reduce the degree of multiprogramming. Later, the process can be reintroduced into memory, and its execution can be continued where it left off. This scheme is called swapping. The process is swapped out, and is later swapped in, by the medium-term scheduler. Swapping may be necessary to improve the process mix or because a change in memory requirements has overcommitted available memory, requiring memory to be freed up. Figure 8: Addition of Medium Term Scheduling to the Queuing Diagram

30 Comparison among Schedulers

31 4.1 Basic Concepts CPU scheduling is the basis of multiprogramming systems. A Process Scheduler (CPU scheduler) schedules different processes to be assigned to the CPU based on particular scheduling algorithms. To put it in simple term, the CPU scheduler (short-term scheduler) selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. There are several popular process scheduling algorithms which we are going to discuss in this chapter: First-Come, First-Served (FCFS) Scheduling Shortest-Job-First (SJF) Scheduling Priority Scheduling Round Robin(RR) Scheduling Multiple-Level Queues Scheduling These algorithms are either non-preemptive or preemptive. Non-preemptive algorithms are designed so that once a process enters the running state, it cannot be preempted until it completes its allotted time (terminates or switches from running to wait state), whereas the preemptive scheduling is based on priority where a scheduler may preempt a low priority running process anytime when a high priority process enters into a ready state. CPU - I/O Burst Cycle The success of CPU scheduling depends on the following observed property of processes (process behavior): Process execution consists of a cycle of CPU execution (CPU burst) and I/O wait (I/O burst). Processes alternate back and forth between these two states.

32 Decisions about resource Allocation: which process gets which resources Which resources should each process receive? Space sharing: Controlled access to resource Implication: resources are not easily preemptible Scheduling: how long process keeps resource In which order should requests be serviced? Time sharing: more resources requested than can be granted Implication: Resource is preemptible Dispatcher The dispatcher gives control of the CPU to the process selected by the short-term scheduler; this involves switching context. The dispatcher needs to run as fast as possible, since it is invoked during process context switch The time it takes for the dispatcher to stop one process and start another process is called dispatch latency Role of Dispatcher vs. Scheduler Dispatcher Low-level mechanism Responsibility: context switch Scheduler High-level policy Responsibility: deciding which process to run

33 4.2 Scheduling Criteria Many criteria have been suggested to compare different algorithms of CPU-Scheduling which include: 1. CPU Utilization: keep the CPU as busy as possible and decrease the possibility of becoming idle. 2. Through put: the number of process that are completed per unit time. 3. Turnaround Time: the sum of periods that the process spent waiting in ready queue, executing in the CPU and doing I/O, or Time between submission and completion. 4. Waiting Time: the sum of periods that the process spent waiting in ready queue only. 5. Response Time: the amount of time for the process it takes to start responding, or Time between submission and first response. These criteria are used to answer the question " How do we select the next process? ". Scheduling performance metrics Min waiting time: don t have process wait long in ready queue. Max CPU utilization: keep CPU busy. Max throughput: complete as many processes as possible per unit time. Min response time: respond immediately. Fairness: give each process (or user) same percentage of CPU. 4.3 Scheduling Algorithms First Come, First Served (FCFS) Jobs are executed on first come, first served basis. It is a non-preemptive scheduling algorithm. Easy to understand and implement. Its implementation is based on FIFO queue. Poor in performance, as average wait time is high.

34 Example 1: Case 1: Suppose that the processes arrive at time 0, in order: P1, P2, P3. Draw the Gantt chart and calculate the average waiting time using the given table? Process Burst (execution) Time P 1 24 P 2 3 P With FCFS, the process that requests the CPU first is allocated the CPU first - The Gantt Chart for the schedule is: - Waiting Time = start time arrival time Waiting time for P 1 = 0 P 2 = 24 0 = 24 P 3 = 27 0 = 27 Average waiting time = ( ) / 3 = 17 - Turnaround time = waiting time + execution (burst) time Turnaround time for P 1 = = 24 P 2 = = 27 P 3 = = 30 Average Turnaround time = ( )/3 = 27 Case 2: Suppose that the processes arrive at time 0, in order: P2, P3, P1. Draw the Gantt chart and calculate the average waiting time using the given table? - The Gantt Chart for the schedule is: - Waiting Time = start time arrival time Waiting time for P 1 = 6 0 = 6 P 2 = 0 P 3 = 3 0 = 3

35 Average waiting time = ( ) / 3 = 3 (much better than case 1) - Turnaround time = waiting time + execution (burst) time Turnaround time for P 1 = = 30 P 2 = = 3 P 3 = = 6 Average Turnaround time = ( )/3 = 13 Case 1 is an example of the convoy effect; all the other processes wait for one longrunning process to finish using the CPU. This problem results in lower CPU and device utilization; Case 2 shows that higher utilization might be possible if the short processes were allowed to run first Example 2: Suppose that the processes arrive at time 0, in order: P1, P3, P2, P4. Draw the Gantt chart and calculate the average waiting time using the given table?

36 Example 3: Draw the Gantt chart and calculate the average waiting time using the given table? Process Burst Time Arrival Time P P P The Gantt Chart for the schedule is: - Waiting Time = start time arrival time Waiting time for P 1 = 3 2 = 1 P 2 = = 17 P 3 = 0 Average waiting time = ( ) / 3 = 6 - Turnaround time = waiting time + execution time Turnaround time for P 1 = = 25 P 2 = = 20 P 3 = = 3 Average Turnaround time = ( )/3 = 16 Example 4: Draw the Gantt chart and calculate the average waiting time using the given table?.

37 4.3.2 Shortest Job - First (SJF) Best approach to minimize waiting time. Two schemes: - Non-preemptive once CPU given to the process it cannot be preempted until completes its CPU burst. - Preemptive if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is known as the Shortest-Remaining-Time-First (SRTF). Easy to implement in Batch systems where required CPU time is known in advance. Impossible to implement in interactive systems where the required CPU time is not known. The processer should know in advance how much time a process will take. If two processes have the same length next CPU burst, FCFS scheduling is used. Optimal if all jobs are available simultaneously (provable). Gives the best possible AWT (average waiting time) Example 5: Draw the Gantt chart and calculate the average waiting time using the given table?

38 Example 6: Draw the Gantt chart and calculate the average waiting time using the given table? (varied arrival times) SJF (non-preemptive, varied arrival times) Average waiting time = ( (0 0) + (8 2) + (7 4) + (12 5) )/4 = ( )/4 = 4

39 Example 7: Draw the Gantt chart and calculate the average waiting time using the given table? (varied arrival times) SJF not always optimal as shown in following example: Example 8: Using the Preemptive version of the SJF algorithm (Shortest-Remaining-Time-First (SRTF)), example 8 Gantt chart will be as follows: SRTF (if a new process arrives with CPU burst length less than remaining time of current executing process, preempt). It uses to reduce the average waiting time.

40 Example 9: using the SRTF algorithm, draw the Gantt chart and calculate the average waiting time using the given table? The Gantt chart for the schedule is: Average waiting time = ( [ P 1 w 1 + P 1 w 2 ] + [ P 2 w 1 + P 2 w 2 ] + P 3 w 3 + P 4 w 4 )/4 = ( [(0 0) + (11-2)] + [(2 2) + (5 4)] + (4-4) + (7 5) )/4 = )/4 = 3 First waiting time = start execution time arrival time. e.g. P 1 w 1 = 0 0 = 0 Next waiting time = start execution time preempt time. e.g. P 1 w 2 = 11 2 = 9 Example 10: using the SRTF algorithm, draw the Gantt chart and calculate the average waiting time using the given table? Example 11: using the SRTF algorithm, draw the Gantt chart and calculate the average waiting time using the given table?

41 A Problem with SJF Starvation In some scenarios, a job may wait forever Example: SJF Process A with duration time of 1 hour arrives at time 0 But ever 1 minute, a shorter process with duration time of 2 minutes arrive Result of SJF: Process A never gets to run Priority Scheduling Each process is assigned a priority. Process with highest priority is to be executed first and so on. (smallest integer the higher or lower priorty) Processes with same priority are executed on first come first served basis. Priority scheduling can be either preemptive or non-preemptive. A non-preemptive priority will simply put the new highest priority process at the head of the ready queue. A preemptive priority will preempt the CPU if the newly arrived process is higher than the priority of the currently running process. a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems. Priority can be decided based on memory requirements, time requirements or any other resource requirement. Problem: Starvation low priority processes may never execute. Solution: Aging increase the priority of processes that wait in the ready queue for a long time Example 12: using the priority scheduling algorithm (non-preemptive), draw the Gantt chart and calculate the average waiting time using the given table? (all processes arrived at the same time)

42 Average waiting time = ( ) / 5 = 8.2

43 5.1 Definition In a multiprogramming system, processes request resources. If those resources are being used by other processes then the process enters a waiting state. However, if other processes are also in a waiting state, we have deadlock. The formal definition of deadlock is as follows: Definition: A set of processes is in a deadlock state if every process in the set is waiting for an event (release) that can only be caused by some other process in the same set. Example 1 Process P 1 requests the printer, gets it. Process P 2 requests the tape unit, gets it. Process P 1 requests the tape unit, waits. Process P 2 requests the printer, waits. P 1 and P 2 are deadlocked. In this chapter, the deadlocks will be analyzed with the following assumptions: A process must request a resource before using it. It must release the resource after using it. So the process may utilize a resource in only the following sequence. Request a resource (suspend until available if necessary ). Use the resource. (the resource is allocated to the process) Release the resource. A process cannot request a number more than the total number of resources available in the system. Resource State, Type and Instance The state of resource can be busy (not available which be used by another process). free (idle which ready to be used by any process). broken which cannot be used by any process.

44 Resource type: the resources are partitioned into several types R 1, R 2,.,R n CPU, memory space, I/O devices, files Resource instance: is the number of resources in the system of that type. Each resource type R i has Wi instance. for example, if the system has two CPUs and five printers, then the resource type CPU has two instances and the resource type printer has five instances. 5.2 Deadlock Characterization Deadlock Necessary Conditions A deadlock occurs if and only if the following four conditions hold in a system simultaneously: 1. Mutual Exclusion: At least one of the resources is non-sharable (that is; only a limited number of processes can use it at a time and if it is requested by a process while it is being used by another one, the requesting process has to wait until the resource is released.). 2. Hold and Wait: There must be at least one process that is holding at least one resource and waiting for other resources that are being hold by other processes. 3. No Preemption: No resource can be preempted before the holding process completes its task with that resource. 4. Circular Wait: There exists a set of processes: {P1, P2,..., Pn} such that P1 is waiting for a resource held by P2 P2 is waiting for a resource held by P3... Pn-1 is waiting for a resource held by Pn Pn is waiting for a resource held by P1.

45 5.2.2 Resource Allocation Graph Deadlocks can be described more precisely in terms of a directed graph called a resource allocation graph. It is a visual ( mathematical ) way to determine if a deadlock has, or may occur. This graph consists of : A set of vertices V and a set of edges E. V is partitioned into two types: P = {P1, P2,, Pn}, the set consisting of all the processes in the system. R = {R1, R2,, Rm}, the set consisting of all resource types in the system. E partitioned into two types P i R j, (P i, R j ) An arrow from the process to resource indicates the process is requesting an instance of the resource and is currently waiting for that resource (called request edge). R j P i, ( R i, P j ) An arrow from resource to process shows an instance of the resource has been allocated to the process (called assignment edge). In these graphs, each component can be represented as follows: Process Resource Type R j as a square and dots represent number of instances of resource in type. Resource type with four instances. A request edge (P i requests instance of R j ) An assignment edge (P i is holding an instance of R j )

46 Example of a Resource Allocation Graph P = {P 1, P 2, P 3 } R = {R 1, R 2, R 3, R 4 } E = {(Request Edge) P 1 R 1, P 2 R 3, (Assignment Edge) R 1 P 2, R 2 P2, R 2 P 1, R 3 P 3 } Resource Instances One instance of R 1, Two instances of R 2, One instance of R 3 and Three instances of R 4 Process states P 3 is holding an instance of R 3 (R 3 assigned to P 3 ). P 2 is holding an instance of R 1 and R 2, and is Waiting for an instance of resource type R 3 (P 2 requests R 3 ). P1 is holding an instance of R 2 (R 2 assigned to P 1 ) and is Waiting for an instance of resource type R 1 (P 1 requests R 1 ). Basic Facts If the graph contains no cycles, then no process is deadlocked. If there is a cycle, then: a) If resource types have multiple (several) instances, then deadlock MAY exist. b) If each resource type has 1 instance, then deadlock has occurred.

47 Example of a resource allocation graph with a deadlock Case 1: Before P 3 requested Case 2: After P 3 requested an instance of R 2 an instance of R 2 In case 1, there is a cycle, however there is no deadlock. If P3 releases R3, R3 may be allocated to P2, which breaks the cycle. While in case 2, P 3 requested an instance of R 2. At this point, two cycle exist in the system P 1, R 1, P 2, R 3, P 3, R 2, P 1 P 2, R 3, P 3, R 2, P 2 In this case, the processes P 1, P 2 and P 3 are deadlocked.

48 Example of a resource allocation graph with a cycle but no deadlock There is a cycle, however there is no deadlock. If P 4 releases R 2, R 2 may be allocated to P 3, which breaks the cycle 5.3 Methods for Handling Deadlocks 1. Prevention Ensure that the system will never enter a deadlock state by Preventing any one of the 4 necessary conditions from happening. 2. Avoidance Ensure that the system will never enter an unsafe state by giving additional information (in advance) concerning which resources a process will request during its lifetime. 3. Detection Allow the system to enter a deadlock state and then recover. This requires using both: a) Detection Know a deadlock has occurred. b) Recovery Regain the resources.

49 4. Do Nothing Ignore the problem and let the user or system administrator respond to the problem; used by most operating systems, including Windows and UNIX 5.4 Deadlock Prevention To prevent the system from deadlocks, one of the four discussed conditions that may create a deadlock should be discarded. The methods for those conditions are as follows: Mutual Exclusion not required for sharable resources Mutual Exclusion must hold for non-sharable resources Hold and Wait One protocol to ensure that hold-and-wait condition never occurs says each process must request and get all of its resources before it begins execution. Another protocol is Each process can request resources only when it does not occupies any resources. (i.e. before it can request any additional resources, however, it must release all the resources that it currently allocated). Both protocols cause low resource utilization, starvation and reduce system throughput. Many resources are allocated but most of them are unused for a long period of time. A process that requests several commonly used resources causes many others to wait indefinitely. No Preemption If a process that is holding some resources and requests another resource, we first check whether they are available. If they are not available (busy), we can use one of the following protocols: all resources currently being held by the process are released. The Preempted resources are added to the list of resources for which the process is waiting.

50 we check whether they are being used or they are allocated to some other process waiting for other resources. If so then the OS preempts the desired resources from the waiting process and allocate them to the requesting process. These protocols can be applied to resources whose states can easily be saved and restored (CPU registers, memory space). It cannot be applied to resources like printers. Circular Wait One protocol to ensure that the circular wait condition never holds is Impose a linear ordering of all resource types. Then, each process can only request resources in an increasing order of priority. For example, set priorities for R 1 = 1, R 2 = 2, R 3 = 3, and R 4 = 4. With these priorities, if process P wants to use R 1 and R 3, it should first request R 1, then R 3. Another protocol is Whenever a process requests a resource R j, it must have released all resources R k with priority(r k ) priority (R j ).

51 5.5 Deadlock Avoidance Deadlock avoidance approach requires that the system has some additional (a priori) information on how each process will request and release resources, it is possible to construct an algorithm that will avoid deadlock states. Simplest and most useful method requires that each process declare in advance the maximum number of resources of each type that it may need. Initially, we consider that the system in a safe state. The idea is simply to ensure that the system will always remain in a safe state. Safe state: A state is safe if the system can allocate resources to each process (up to maximum) in some order and still avoid a deadlock. The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition (unsafe state). A resource-allocation state is defined by the number of available (free) and allocated (busy) resources, and the maximum demands of the processes. When a process requests a resource that is already available, the OS must decide whether that resource can immediately be allocated or whether the process must wait to avoid a possible unsafe state. The resource is immediately allocated only if it leaves the system in a safe state Safe State When a process requests an available resource, the system must decide if immediate allocation leaves the system in a safe state. A system is in a safe state only if there exists a safe sequence. A sequence of processes <P 1, P 2,, P n > is a safe sequence for the current allocation state if, for each P i, the resource requests that P i can still make, can be satisfied by currently available resources plus resources held by all P j, with j < i. That is: If the P i resource needs are not immediately available, then P i can wait until all P j have finished When P j is finished, P i can obtain needed resources, execute, return allocated resources, and terminate. When P i terminates, P i +1 can obtain its needed resources, and so on

52 Possible states are: Deadlock No forward progress can be made. Unsafe state A state that may allow deadlock. Safe State Avoidance No deadlock. Ensure that a system will never enter an unsafe state. Example 1: Consider a system with 12 tape drives. Assume there are three processes : p0, p1, p2 at a time T 1. In this example, there are two free tape drives and the sequence < p1, p2, p0 > is a workable sequence (safe state). Example 2: Suppose P2 requests and is given one more resource. The system is no longer in a safe state (why). (the allocated resources will be 11 and only one resource is free so the processes will be in a deadlock state) Avoidance Algorithms 1. For a single instance of a resource type, use a resource-allocation graph 2. For multiple instances of a resource type, use the banker s algorithm

53 1. Resource-Allocation Graph Scheme Introduce a new kind of edge called a claim edge. Claim edge P i R j indicates that process P j may request resource R j ; which is represented by a dashed line. A claim edge converts to a request edge when a process requests a resource. A request edge converts to an assignment edge when the resource is allocated to the process. When a resource is released by a process, an assignment edge reconverts to a claim edge. Resources must be claimed a priori in the system. Resource-Allocation Graph with Claim Edges Unsafe State In Resource-Allocation Graph

54 Suppose that process Pi requests a resource Rj The request can be granted only if converting the request edge to an assignment edge does not result in the formation of a cycle in the resource allocation graph. 2. Banker s Algorithm The name was chosen because the algorithm could be used in a banking system to ensure that the bank never allocates its available cash such that it can no longer satisfy the needs of all its customers. Used when there exists multiple instances of a resource type. Each process must a priori claim maximum use. When a process requests a resource, it may have to wait. When a process gets all its resources, it must return them in a finite amount of time Data Structures for the Banker s Algorithm Let n = number of processes, and m = number of resources types. Available: Vector of length m. If available [j] = k, there are k instances of resource type R j available. Max: n x m matrix. If Max [i,j] = k, then process P i may request at most k instances of resource type R j. Allocation: n x m matrix. If Allocation[i,j] = k then P i is currently allocated k instances of R j. Need: n x m matrix. If Need[i,j] = k, then P i may need k more instances of R j to complete its task. Need [i,j] = Max[i,j] Allocation [i,j]

55 Safety Algorithm 1. "Let Work and Finish be vectors of length m and n, respectively. Initialize:" Work = Available! Finish [i] = false for i - 1,3,, n." 2. "Find and i such that both: " (a) Finish [i] = false" (b) Need i Work! If no such i exists, go to step 4." 3. "Work = Work + Allocation i Finish[i] = true go to step 2." 4. "If Finish [i] == true for all i, then the system is in a safe state." Resource-Request Algorithm for Process Pi This algorithm is used to determine whether a request can be safely granted. Let Request = request vector for process Pi. If Request i [j] = k then process Pi wants k instances of resource type Rj. When a request is made by process P i the following actions are taken: 1. If Request i Need i go to step 2. Otherwise, raise error condition, since process has exceeded its maximum claim. 2. If Request i Available, go to step 3. Otherwise Pi must wait, since resources are not available. 3. Pretend to allocate requested resources to Pi by modifying the state as follows: Available = Available - Request i Allocation i = Allocation i + Request i Need i = Need i Request i If the resulting state is safe (using safety algorithm) the resources are allocated to Pi. If new state is unsafe Pi must wait, and the old resource-allocation state is restored.

56 Example of Banker s Algorithm consider a system with 5 processes and 3 resources. Total: [10, 5, 7]. Snapshot at time T 1 : Is the system in a safe state? We claim that the system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies safety criteria (applying safety algorithm). Example P 1 Request (1,0,2) Check that Request Available (that is, (1,0,2) (3,3,2) true. Executing safety algorithm shows that sequence <P 1, P 3, P 4, P 0, P 2 > satisfies safety requirement. So the request (1, 0, 2) can be granted to process P 1. Can request for (3,3,0) by P4 be granted? Can request for (0,2,0) by P0 be granted?

57 5.6 Deadlock Detection If a system has no deadlock prevention and no deadlock avoidance scheme, then it needs a deadlock detection scheme with recovery from deadlock capability. Detection and recovery algorithm allows deadlock to occur then, detect and recover the state. In this environment the system must provide: - An algorithm (detection algorithm) that examine the state of the system to determine whether a deadlock has occurred. - An algorithm to recover from the deadlock Deadlock Detection Algorithm The detection algorithm is nearly similar to safety algorithm with some modification in some of the steps Data Structure is as: Available [m] Allocation [n, m] as in Banker's Algorithm Request [n, m] indicates the current requests of each process. Let Work and Finish be vectors of length m and n, as in the safety algorithm. The algorithm is as follows: 1. Initialize Work = Available For i = 1 to n do If Allocation(i) = 0 then Finish[i] = true else Finish[i] = false 2. Search an i such that Finish[i] = false and Request(i) Work If no such i can be found, go to step For that i found in step 2 do: Work = Work + Allocation(i) Finish[i] = true Go to step If Finish[i] true for a some i then the system is in deadlock state else the system is safe

58 Example Examine whether the system whose resource allocation graph is given below is deadlocked or not. First, let s form the required structures p1 p2 p3 p4 Allocation Request Available = [0 0 0] r1 r3 r2 r1 r3 r2 Work = [0 0 0] Request(4) Work i = 4: Work = Work + Allocation(4) = [0 0 0] + [0 0 1] = [0 0 1] ; Finish[4] = True Request(2) Work i = 2: Work = Work + Allocation(2) = [0 0 1] + [0 1 0] = [0 1 1] ; Finish[2] = True Request(1) Work i = 1: Work = Work + Allocation(1) = [0 1 1] + [1 0 0] = [1 1 1] ; Finish[1] = True

59 Request(3) Work i = 3: Work = Work + Allocation(3) = [1 1 1] + [0 0 1] = [1 1 2] ; Finish[3] = True Since Finish[i] = true for all i, there is no deadlock in the system. Example Five processes P 0 through P 4 ; three resource types A (7 instances), B (2 instances), and C (6 instances). Snapshot at time T 0 : Allocation Request Available A B C A B C A B C P P P P P Determine whether deadlock occurs in the state? Finish (P 0 ) = true Finish (P 2 ) = true

60 = (7, 2, 6) Finish (P 1 ) = true The system is not in a deadlock state. Sequence <P 0, P 2, P 3, P 4, P 1 > will result in Finish[i] = true for all i. Also this sequence result in safe state. Question: suppose now the process P 2 requests an additional instance of type C. Is the system will be no deadlock state anymore? Execute the detection algorithm, the safety sequence. What is the new state condition for the system? The request matrix is modified as follows With this request the system is in a deadlock state. Even P0 returns its resource, the number of available resources still insufficient for other processes. The processes that are deadlock are P 1, P 2, P 3, and P 4.

Table of Contents 1. OPERATING SYSTEM OVERVIEW OPERATING SYSTEM TYPES OPERATING SYSTEM SERVICES Definition...

Table of Contents 1. OPERATING SYSTEM OVERVIEW OPERATING SYSTEM TYPES OPERATING SYSTEM SERVICES Definition... Table of Contents 1. OPERATING SYSTEM OVERVIEW... 1 Definition... 1 Memory Management... 2 Processor Management... 2 Device Management... 2 File Management... 2 Other Important Activities... 3. OPERATING

More information

Operating System - Overview

Operating System - Overview Unit 37. Operating System Operating System - Overview An Operating System (OS) is an interface between a computer user and computer hardware. An operating system is a software which performs all the basic

More information

Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400, AIX, z/os, etc.

Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400, AIX, z/os, etc. Operating System Quick Guide https://www.tutorialspoint.com/operating_system/os_quick_guide.htm Copyright tutorialspoint.com Operating System Overview An Operating System OS is an interface between a computer

More information

Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400, AIX, z/os, etc.

Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400, AIX, z/os, etc. An Operating System (OS) is an interface between computer user and computer hardware. An operating system is software which performs all the basic tasks like file management, memory management, process

More information

UNIT 1 JAGANNATH UNIVERSITY UNIT 2. Define Operating system and its functions. Explain different types of Operating System

UNIT 1 JAGANNATH UNIVERSITY UNIT 2. Define Operating system and its functions. Explain different types of Operating System JAGANNATH UNIVERSITY BCAII OPERATING SYSTEM MODEL TEST PAPER (SOLVED) UNIT 1 Q1 Q2 Q3 Q4 Q5 Define Operating system and its functions Explain different types of Operating System Describe different types

More information

Process- Concept &Process Scheduling OPERATING SYSTEMS

Process- Concept &Process Scheduling OPERATING SYSTEMS OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne PROCESS MANAGEMENT Current day computer systems allow multiple

More information

7/20/2008. What Operating Systems Do Computer-System Organization

7/20/2008. What Operating Systems Do Computer-System Organization Introduction to Operating Systems Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Chapter 1: Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management

More information

Chapter 1: Introduction. Chapter 1: Introduction

Chapter 1: Introduction. Chapter 1: Introduction Chapter 1: Introduction Chapter 1: Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management

More information

Unit 3 : Process Management

Unit 3 : Process Management Unit : Process Management Processes are the most widely used units of computation in programming and systems, although object and threads are becoming more prominent in contemporary systems. Process management

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2016 Lecture 2 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 2 System I/O System I/O (Chap 13) Central

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Slides based on the book Operating System Concepts, 9th Edition, Abraham Silberschatz, Peter B. Galvin and Greg Gagne,

More information

Batch processing is a technique in which Operating System collects programs and data together in

Batch processing is a technique in which Operating System collects programs and data together in OPERATING SYSTEM PROPERTIES Following are few of very important tasks that Operating System handles. 1.1 Batch Processing Batch processing is a technique in which Operating System collects programs and

More information

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management Memory Management Storage Management

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Chapter 1: Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System Operations Process Management

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Silberschatz, Galvin and Gagne 2009 Chapter 1: Introduction What Operating Systems Do Computer-System Organization Computer-System Architecture Operating-System Structure Operating-System

More information

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems Processes CS 475, Spring 2018 Concurrent & Distributed Systems Review: Abstractions 2 Review: Concurrency & Parallelism 4 different things: T1 T2 T3 T4 Concurrency: (1 processor) Time T1 T2 T3 T4 T1 T1

More information

OPERATING SYSTEMS. P. PRAVEEN Asst.Prof, CSE

OPERATING SYSTEMS. P. PRAVEEN Asst.Prof, CSE OPERATING SYSTEMS By P. PRAVEEN Asst.Prof, CSE P. Praveen Asst Prof, Department of Computer Science and Engineering Page 1 P. Praveen Asst Prof, Department of Computer Science and Engineering Page 2 1

More information

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU BCA-3 rd Semester 030010304-Fundamentals Of Operating Systems Unit: 1 Introduction Short Answer Questions : 1. State two ways of process communication. 2. State any two uses of operating system according

More information

HANDOUTS/ NOTES/ STUDY MATERIAL. Jagannath Institute of Management Sciences Lajpat Nagar OPERATING SYSTEM

HANDOUTS/ NOTES/ STUDY MATERIAL. Jagannath Institute of Management Sciences Lajpat Nagar OPERATING SYSTEM HANDOUTS/ NOTES/ STUDY MATERIAL Jagannath Institute of Management Sciences Lajpat Nagar OPERATING SYSTEM UNIT 1 Introduction/Definition An operating system act as an intermediary between the user of a

More information

CHAPTER-1: INTRODUCTION TO OPERATING SYSTEM:

CHAPTER-1: INTRODUCTION TO OPERATING SYSTEM: CHAPTER-1: INTRODUCTION TO OPERATING SYSTEM: TOPICS TO BE COVERED 1.1 Need of Operating System 1.2 Evolution of os 1.3 operating system i. Batch ii. iii. iv. Multiprogramming Time sharing Real time v.

More information

Lecture 1 Introduction (Chapter 1 of Textbook)

Lecture 1 Introduction (Chapter 1 of Textbook) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 1 Introduction (Chapter 1 of Textbook) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides

More information

CS3733: Operating Systems

CS3733: Operating Systems CS3733: Operating Systems Topics: Process (CPU) Scheduling (SGG 5.1-5.3, 6.7 and web notes) Instructor: Dr. Dakai Zhu 1 Updates and Q&A Homework-02: late submission allowed until Friday!! Submit on Blackboard

More information

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100 GATE- 2016-17 Postal Correspondence 1 Operating Systems Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts,

More information

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems

OPERATING SYSTEMS: Lesson 1: Introduction to Operating Systems OPERATING SYSTEMS: Lesson 1: Introduction to Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Why study? a) OS, and its internals, largely

More information

OPERATING SYSTEM. Functions of Operating System:

OPERATING SYSTEM. Functions of Operating System: OPERATING SYSTEM Introduction: An operating system (commonly abbreviated to either OS or O/S) is an interface between hardware and user. OS is responsible for the management and coordination of activities

More information

Introduction to Operating System

Introduction to Operating System Introduction to Operating System An operating system is a program which manages all the computer hardware. It provides the base for application program and acts as an intermediary between a user and the

More information

Operating system Dr. Shroouq J.

Operating system Dr. Shroouq J. 2.2.2 DMA Structure In a simple terminal-input driver, when a line is to be read from the terminal, the first character typed is sent to the computer. When that character is received, the asynchronous-communication

More information

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections )

CPU Scheduling. CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections ) CPU Scheduling CSE 2431: Introduction to Operating Systems Reading: Chapter 6, [OSC] (except Sections 6.7.2 6.8) 1 Contents Why Scheduling? Basic Concepts of Scheduling Scheduling Criteria A Basic Scheduling

More information

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5) Announcements Reading Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) 1 Relationship between Kernel mod and User Mode User Process Kernel System Calls User Process

More information

CHAPTER 2: PROCESS MANAGEMENT

CHAPTER 2: PROCESS MANAGEMENT 1 CHAPTER 2: PROCESS MANAGEMENT Slides by: Ms. Shree Jaswal TOPICS TO BE COVERED Process description: Process, Process States, Process Control Block (PCB), Threads, Thread management. Process Scheduling:

More information

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31

CPU scheduling. Alternating sequence of CPU and I/O bursts. P a g e 31 CPU scheduling CPU scheduling is the basis of multiprogrammed operating systems. By switching the CPU among processes, the operating system can make the computer more productive. In a single-processor

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 Lecture 2 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 2 What is an Operating System? What is

More information

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on Chapter 1: Introduction Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Objectives To describe the basic organization of computer systems To provide a grand tour of the major

More information

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications concurrently on all computers in the cluster. Disadvantages:

More information

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int Operating Systems Lecture 1 Introduction Agenda: What Operating Systems Do Computer System Components How to view the Operating System Computer-System Operation Interrupt Operation I/O Structure DMA Structure

More information

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs:

OPERATING SYSTEMS. UNIT II Sections A, B & D. An operating system executes a variety of programs: OPERATING SYSTEMS UNIT II Sections A, B & D PREPARED BY ANIL KUMAR PRATHIPATI, ASST. PROF., DEPARTMENT OF CSE. PROCESS CONCEPT An operating system executes a variety of programs: Batch system jobs Time-shared

More information

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5 OPERATING SYSTEMS CS3502 Spring 2018 Processor Scheduling Chapter 5 Goals of Processor Scheduling Scheduling is the sharing of the CPU among the processes in the ready queue The critical activities are:

More information

Operating System Review

Operating System Review COP 4225 Advanced Unix Programming Operating System Review Chi Zhang czhang@cs.fiu.edu 1 About the Course Prerequisite: COP 4610 Concepts and Principles Programming System Calls Advanced Topics Internals,

More information

Lecture 2 Process Management

Lecture 2 Process Management Lecture 2 Process Management Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks The terms job and process may be interchangeable

More information

1.1 Introduction. Fig.1.1 Abstract view of the components of a computer system.

1.1 Introduction. Fig.1.1 Abstract view of the components of a computer system. 1.1 Introduction An operating system is a program that manages the computer hardware. It also provides a basis for application programs and acts as an intermediary between a user of a computer and the

More information

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5 Process Management A process can be thought of as a program in execution. A process will need certain resources such as CPU time, memory, files, and I/O devices to accomplish its task. These resources

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction What is an operating system? Simple Batch Systems Multiprogramming Batched Systems Time-Sharing Systems Personal-Computer Systems Parallel Systems Distributed Systems Real -Time

More information

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [CPU SCHEDULING] Shrideep Pallickara Computer Science Colorado State University L14.1 Frequently asked questions from the previous class survey Turnstiles: Queue for threads blocked

More information

Operating System Concepts Ch. 5: Scheduling

Operating System Concepts Ch. 5: Scheduling Operating System Concepts Ch. 5: Scheduling Silberschatz, Galvin & Gagne Scheduling In a multi-programmed system, multiple processes may be loaded into memory at the same time. We need a procedure, or

More information

Chapter 5: CPU Scheduling

Chapter 5: CPU Scheduling Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating Systems Examples Algorithm Evaluation Chapter 5: CPU Scheduling

More information

European University of Lefke. Instructor: Dr. Arif SARI

European University of Lefke. Instructor: Dr. Arif SARI European University of Lefke CIS 105 Operating Systems Instructor: Dr. Arif SARI Email: asari@eul.edu.tr Introduction 1.1 Silberschatz, Galvin and Gagne 2009 Chapter 1: Introduction, Silberschatz, Galvin

More information

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition Chapter 6: CPU Scheduling Silberschatz, Galvin and Gagne 2013 Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Real-Time

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

Operating Systems. Figure: Process States. 1 P a g e

Operating Systems. Figure: Process States. 1 P a g e 1. THE PROCESS CONCEPT A. The Process: A process is a program in execution. A process is more than the program code, which is sometimes known as the text section. It also includes the current activity,

More information

Operating System Services

Operating System Services CSE325 Principles of Operating Systems Operating System Services David Duggan dduggan@sandia.gov January 22, 2013 Reading Assignment 3 Chapter 3, due 01/29 1/23/13 CSE325 - OS Services 2 What Categories

More information

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering) A. Multiple Choice Questions (60 questions) Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering) Unit-I 1. What is operating system? a) collection of programs that manages hardware

More information

FCM 710: Architecture of Secure Operating Systems

FCM 710: Architecture of Secure Operating Systems FCM 710: Architecture of Secure Operating Systems Practice Exam, Spring 2010 Email your answer to ssengupta@jjay.cuny.edu March 16, 2010 Instructor: Shamik Sengupta Multiple-Choice 1. operating systems

More information

OPERATING SYSTEMS UNIT - 1

OPERATING SYSTEMS UNIT - 1 OPERATING SYSTEMS UNIT - 1 Syllabus UNIT I FUNDAMENTALS Introduction: Mainframe systems Desktop Systems Multiprocessor Systems Distributed Systems Clustered Systems Real Time Systems Handheld Systems -

More information

Ch 4 : CPU scheduling

Ch 4 : CPU scheduling Ch 4 : CPU scheduling It's the basis of multiprogramming operating systems. By switching the CPU among processes, the operating system can make the computer more productive In a single-processor system,

More information

Operating Systemss and Multicore Programming (1DT089)

Operating Systemss and Multicore Programming (1DT089) Operating Systemss and Multicore Programming (1DT089) Introduction to Operating Systemss (Chapter 1) Wednesday january 23 Uppsala University 2013 karl.marklund@it.uu.se Chapter 1: Introduction Chapter

More information

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles

So far. Next: scheduling next process from Wait to Run. 1/31/08 CSE 30341: Operating Systems Principles So far. Firmware identifies hardware devices present OS bootstrap process: uses the list created by firmware and loads driver modules for each detected hardware. Initializes internal data structures (PCB,

More information

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015

Operating Systems. Lecture Course in Autumn Term 2015 University of Birmingham. Eike Ritter. September 22, 2015 Lecture Course in Autumn Term 2015 University of Birmingham September 22, 2015 Course Details Overview Course Details What is an Operating System? OS Definition and Structure Lecture notes and resources:

More information

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University Frequently asked questions from the previous class survey CS 370: SYSTEM ARCHITECTURE & SOFTWARE [CPU SCHEDULING] Shrideep Pallickara Computer Science Colorado State University OpenMP compiler directives

More information

Introduction. CS3026 Operating Systems Lecture 01

Introduction. CS3026 Operating Systems Lecture 01 Introduction CS3026 Operating Systems Lecture 01 One or more CPUs Device controllers (I/O modules) Memory Bus Operating system? Computer System What is an Operating System An Operating System is a program

More information

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals EECS 3221 Operating System Fundamentals Instructor: Prof. Hui Jiang Email: hj@cse.yorku.ca Web: http://www.eecs.yorku.ca/course/3221 General Info 3 lecture hours each week 2 assignments (2*5%=10%) 1 project

More information

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System? Lecture Course in Autumn Term 2013 University of Birmingham Lecture notes and resources: http://www.cs.bham.ac.uk/ exr/teaching/lectures/opsys/13_14 closed facebook group: UoBOperatingSystems anyone registered

More information

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals General Info EECS 3221 Operating System Fundamentals Instructor: Prof. Hui Jiang Email: hj@cse.yorku.ca Web: http://www.eecs.yorku.ca/course/3221 3 lecture hours each week 2 assignments (2*5%=10%) 1 project

More information

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009

Lecture 17: Threads and Scheduling. Thursday, 05 Nov 2009 CS211: Programming and Operating Systems Lecture 17: Threads and Scheduling Thursday, 05 Nov 2009 CS211 Lecture 17: Threads and Scheduling 1/22 Today 1 Introduction to threads Advantages of threads 2 User

More information

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science CPU Scheduling Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS, Lahore Pakistan Operating System Concepts Objectives To introduce CPU scheduling, which is the

More information

Processes, PCB, Context Switch

Processes, PCB, Context Switch THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering EIE 272 CAOS Operating Systems Part II Processes, PCB, Context Switch Instructor Dr. M. Sakalli enmsaka@eie.polyu.edu.hk

More information

LECTURE 3:CPU SCHEDULING

LECTURE 3:CPU SCHEDULING LECTURE 3:CPU SCHEDULING 1 Outline Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time CPU Scheduling Operating Systems Examples Algorithm Evaluation 2 Objectives

More information

Process Scheduling Part 2

Process Scheduling Part 2 Operating Systems and Computer Networks Process Scheduling Part 2 pascal.klein@uni-due.de Alexander Maxeiner, M.Sc. Faculty of Engineering Agenda Process Management Time Sharing Synchronization of Processes

More information

Course Syllabus. Operating Systems

Course Syllabus. Operating Systems Course Syllabus. Introduction - History; Views; Concepts; Structure 2. Process Management - Processes; State + Resources; Threads; Unix implementation of Processes 3. Scheduling Paradigms; Unix; Modeling

More information

Course: Operating Systems Instructor: M Umair. M Umair

Course: Operating Systems Instructor: M Umair. M Umair Course: Operating Systems Instructor: M Umair Process The Process A process is a program in execution. A program is a passive entity, such as a file containing a list of instructions stored on disk (often

More information

Following are a few basic questions that cover the essentials of OS:

Following are a few basic questions that cover the essentials of OS: Operating Systems Following are a few basic questions that cover the essentials of OS: 1. Explain the concept of Reentrancy. It is a useful, memory-saving technique for multiprogrammed timesharing systems.

More information

Announcement. Exercise #2 will be out today. Due date is next Monday

Announcement. Exercise #2 will be out today. Due date is next Monday Announcement Exercise #2 will be out today Due date is next Monday Major OS Developments 2 Evolution of Operating Systems Generations include: Serial Processing Simple Batch Systems Multiprogrammed Batch

More information

Module 1. Introduction:

Module 1. Introduction: Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system.

More information

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou (  Zhejiang University Operating Systems (Fall/Winter 2018) CPU Scheduling Yajin Zhou (http://yajin.org) Zhejiang University Acknowledgement: some pages are based on the slides from Zhi Wang(fsu). Review Motivation to use threads

More information

UNIT 2. OPERATING SYSTEM STRUCTURES

UNIT 2. OPERATING SYSTEM STRUCTURES This document can be downloaded from www.chetanahegde.in with most recent updates. 1 UNIT 2. OPERATING SYSTEM STRUCTURES 2.1 INTRODUCTION An OS provides the environment within which the programs are executed.

More information

CS420: Operating Systems

CS420: Operating Systems OS Overview James Moscola Department of Engineering & Computer Science York College of Pennsylvania Contents of Introduction slides are courtesy of Silberschatz, Galvin, Gagne Operating System Structure

More information

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1 ITS 225: Operating Systems Operating Systems Lecture 1 Introduction & Overview Jan 15, 2004 Dr. Matthew Dailey Information Technology Program Sirindhorn International Institute of Technology Thammasat

More information

Four Components of a Computer System

Four Components of a Computer System Four Components of a Computer System Operating System Concepts Essentials 2nd Edition 1.1 Silberschatz, Galvin and Gagne 2013 Operating System Definition OS is a resource allocator Manages all resources

More information

OPERATING SYSTEMS. COMS W1001 Introduction to Information Science. Boyi Xie

OPERATING SYSTEMS. COMS W1001 Introduction to Information Science. Boyi Xie 1 OPERATING SYSTEMS COMS W1001 Introduction to Information Science Boyi Xie 2 Announcement Homework 1 is available Grace days A total of 5 days for 5 HWs If all grace days have been used, 50% of the points

More information

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.)

Chapter 3 Processes. Process Concept. Process Concept. Process Concept (Cont.) Process Concept (Cont.) Process Concept (Cont.) Process Concept Chapter 3 Processes Computers can do several activities at a time Executing user programs, reading from disks writing to a printer, etc. In multiprogramming: CPU switches from program to

More information

8th Slide Set Operating Systems

8th Slide Set Operating Systems Prof. Dr. Christian Baun 8th Slide Set Operating Systems Frankfurt University of Applied Sciences SS2016 1/56 8th Slide Set Operating Systems Prof. Dr. Christian Baun Frankfurt University of Applied Sciences

More information

Operating Systems Course 2 nd semester 2016/2017 Chapter 1: Introduction

Operating Systems Course 2 nd semester 2016/2017 Chapter 1: Introduction Operating Systems Course 2 nd semester 2016/2017 Chapter 1: Introduction Lecturer: Eng. Mohamed B. Abubaker Note: Adapted from the resources of textbox Operating System Concepts, 9 th edition What is an

More information

CSC 453 Operating Systems

CSC 453 Operating Systems CSC 453 Operating Systems Lecture 3: Operating-System Structures Operating System Components Operating systems are large and complex - the only way to manage such a project is to divide it into smaller

More information

UNIT I OPERATING SYSTEMS OVERVIEW

UNIT I OPERATING SYSTEMS OVERVIEW UNIT I OPERATING SYSTEMS OVERVIEW Computer System Overview-Basic Elements, Instruction Execution, Interrupts, Memory Hierarchy, Cache Memory, Direct Memory Access, Multiprocessor and Multicore Organization.

More information

Last Class: Processes

Last Class: Processes Last Class: Processes A process is the unit of execution. Processes are represented as Process Control Blocks in the OS PCBs contain process state, scheduling and memory management information, etc A process

More information

Introduction to Computer Systems and Operating Systems

Introduction to Computer Systems and Operating Systems Introduction to Computer Systems and Operating Systems Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr Topics Covered 1. Computer History 2. Computer System

More information

Operating-System Structures

Operating-System Structures Operating-System Structures System Components Operating System Services System Calls System Programs System Structure System Design and Implementation System Generation 1 Common System Components Process

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication

More information

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation Comp 104: Operating Systems Concepts Management Scheduling & Resource Allocation Today OS evolution Introduction to processes OS structure 1 2 Evolution of OS Largely driven by desire to do something useful

More information

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to: F2007/Unit5/1 UNIT 5 OBJECTIVES General Objectives: To understand the process management in operating system Specific Objectives: At the end of the unit you should be able to: define program, process and

More information

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms

Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts. Scheduling Criteria Scheduling Algorithms Operating System Lecture 5 / Chapter 6 (CPU Scheduling) Basic Concepts Scheduling Criteria Scheduling Algorithms OS Process Review Multicore Programming Multithreading Models Thread Libraries Implicit

More information

Process Scheduling. Copyright : University of Illinois CS 241 Staff

Process Scheduling. Copyright : University of Illinois CS 241 Staff Process Scheduling Copyright : University of Illinois CS 241 Staff 1 Process Scheduling Deciding which process/thread should occupy the resource (CPU, disk, etc) CPU I want to play Whose turn is it? Process

More information

DM510 Operating Systems. Jacob Aae Mikkelsen

DM510 Operating Systems. Jacob Aae Mikkelsen DM510 Operating Systems Jacob Aae Mikkelsen DM510 2014 DM510 Course Introduction Teacher: Jacob Aae Mikkelsen ( jamik@imada.sdu.dk ) Teaching Assistant: Daniel Fentz Johansen ( dfjohansen@gmail.com ) Course

More information

Operating System Review Part

Operating System Review Part Operating System Review Part CMSC 602 Operating Systems Ju Wang, 2003 Fall Virginia Commonwealth University Review Outline Definition Memory Management Objective Paging Scheme Virtual Memory System and

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 9 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 CPU Scheduling: Objectives CPU scheduling,

More information

Introduction. What is an Operating System? A Modern Computer System. Computer System Components. What is an Operating System?

Introduction. What is an Operating System? A Modern Computer System. Computer System Components. What is an Operating System? Introduction CSCI 315 Operating Systems Design Department of Computer Science What is an Operating System? A Modern Computer System Computer System Components Disks... Mouse Keyboard Printer 1. Hardware

More information

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1

More information

CS3600 SYSTEMS AND NETWORKS

CS3600 SYSTEMS AND NETWORKS CS3600 SYSTEMS AND NETWORKS NORTHEASTERN UNIVERSITY Lecture 1: Overview and Introduction Prof. Alan Mislove (amislove@ccs.neu.edu) What is an Operating System? 2 What is an Operating System? A program

More information

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013) CPU Scheduling Daniel Mosse (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013) Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU I/O Burst Cycle Process

More information

TDIU25: Operating Systems II. Processes, Threads and Scheduling

TDIU25: Operating Systems II. Processes, Threads and Scheduling TDIU25: Operating Systems II. Processes, Threads and Scheduling SGG9: 3.1-3.3, 4.1-4.3, 5.1-5.4 o Process concept: context switch, scheduling queues, creation o Multithreaded programming o Process scheduling

More information