Unit 1: Operating System Chapter 1 – Operating System Introduction Introduction : Operating system and functions, Classification of Operating systems- Batch, Interactive, Time sharing, Real Time System, Multiprocessor Systems, Multiuser Systems, Multiprocessor Systems, Multithreaded Systems, 1.1 Operating System- Definition An Operating System (OS) is a collection of programs that acts as an interface between a user of a computer and the computer hardware. The purpose of an operating system is to provide an environment in which a user may execute the programs. Operating Systems are viewed as resource managers. The main resource is the computer hardware in the form of processors, storage, input/output devices, communication devices, and data. A computer’s operating system is a group of programs designed to serve two basic purposes: To control the allocation and use of the computing system’s resources among the various users and tasks. To provide an interface between the computer hardware and the programmer that simplifies and makes feasible the creation, coding, debugging, and maintenance of application programs The abstract view of the components of a computer system and the positioning of OS is shown in the Figure 1. Fig1. Abstract View of Operating System Following is the conceptual view of operating system: Fig. 2: Conceptual View of Operating System The positioning of operating system in overall computer system is given below: Fig3. Positioning of Operating System in Computer 1.2. Functions of Operating System: The main functions of an operating system are as follows: Process Management Memory Management Secondary Storage Management I/O Management File Management Protection Networking Management Command Interpretation. 1.2.1 Process Management The CPU executes a large number of programs. A process is a program in execution. The operating system is responsible for the following activities in connection with processes management: The creation and deletion of both user and system processes The suspension and resumption of processes. The provision of mechanisms for process synchronization The provision of mechanisms for deadlock handling. 1.2.2. Memory Management Memory is the most expensive part in the computer system. Memory is a large array of words or bytes, each with its own address. Interaction is achieved through a sequence of reads or writes of specific memory address. The CPU fetches from and stores in memory. The operating system is responsible for the following activities in connection with memory management. Keep track of which parts of memory are currently being used and by whom. Decide which processes are to be loaded into memory when memory space becomes available. Allocate and de allocates memory space as needed. 1.2.3 Secondary Storage Management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory during execution. Since the main memory is too small to permanently accommodate all data and program, the computer system must provide secondary storage to backup main memory. Most modem computer systems use hard disk as the primary storage of information, of both programs and data. Most programs, like compilers, assemblers, sort routines, editors, formatters, and so on, are stored on the disk until loaded into memory. Hence the proper management of disk storage is of central importance to a computer system. The operating system is responsible for the following activities in connection with disk management: Free space management Storage allocation Disk Scheduling 1.2.4 I/O Management One of the purposes of an operating system is enables the user to use various kinds of I/O devices on computer and hide the complexities of using hardware devices from the user. The operating system is responsible for the following activities in connection to I/O management: A buffer caching system To activate a general device driver code To run the driver software for specific hardware devices as and when required. 1.2.5 File Management File management is one of the most visible services of an operating system. Files are mapped, by the operating system, onto physical devices. A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. Data files may be numeric, alphabetic or alphanumeric, sound or video. The operating system is responsible for the following activities in connection to the file management: The creation and deletion of files. The creation and deletion of directory. The support for manipulating files and directories. The mapping of files onto disk storage. Backup of files on stable (nonvolatile) storage. Protection and security of the files. 1.2.6 Protection The various processes in an operating system must be protected from each other’s activities. For that purpose, various mechanisms which can be used to ensure that the files, memory segment, CPU and other resources can be operated on only by those processes and users that have gained proper authorization from the operating system. The operating system is responsible for the following activities in connection to the protection: Provides a mechanism for controlling the access of programs, processes, or users to the resources defined by a computer controls. Improve reliability by detecting latent errors at the interfaces between component subsystems. Early detection of interface errors to prevent healthy subsystem by a subsystem that is malfunctioning. Provide a mean of authentication and authorization 1.2.7 Networking With the advancement in technology need of distributed system and sharing or accessing information from remote computer has becomes the order of day. Almost every organization is dependent of Intranet or Internet. So there is a need of networking protocols and there implementation. The operating system is responsible for the following activities in connection to the networking: Setup of a networking connection (Wireless & LAN) Mechanism for maintaining IP Address (Manual & by using DHCP) Managing networking protocol Security of network connection Firewall management for blocking unauthorized access of computer 1.2.8 Command Interpretation One of the most important components of an operating system is its command interpreter. The command interpreter is the primary interface between the user and the rest of the system. The command statements themselves deal with process management, I/O handling, secondary storage management, main memory management, file system access, protection, and networking. The operating system is responsible for the following activities in connection to the Command Interpretation: Provides a mechanism to read command from user or process. Interpret command into low level language Interact with required hardware, resource or file. Generate output defined in the class. Fig 4: Functions performed by Operating System 1.3. Classification of Operating System 1.3.1 Batch Processing: “Batch is defined as a group of job with similar needs and similar resource requirements”. The operating systems that allow users to create batches and execute each batch sequentially, processing all jobs of a batch considering them as a single process is called Batch Processing System. In a batch processing operating system environment users submit jobs to a central place where these jobs are collected into a batch, and subsequently placed on an input queue at the computer where they will be run. Advantages of Batch Processing Once the data process is started, the computer can be left running without supervision. Batch processing allows an organization to increase efficiency because a large amount of transactions can be combined into a batch rather than processing them each individually. Disadvantages of Batch Processing With batch processing there is a time delay before the work is processed and returned. It is very difficult to maintain the priority between the batches. There is no direct interaction of user with computer. 1.3.2 Interactive Operating System: In an interactive operating system, the user interacts directly with the operating system to supply commands and data as the application program executes and the user receives the results of processing immediately. The user is in direct two way communication with the computer The use can interact with computer by commands typed through keyboard or by invoking command using mouse, touch screen, light pen etc. The computer process command immediately and interact with user through dialog boxes for asking additional details. Fig. 5: Character User Interface Fig. 6: Graphical User Interface Advantages of Interactive System User has the option of controlling his job from its submission to completion. Delay time can be reduced by terminating jobs taking long time. Job processing and system can be monitored for vulnerabilities. Disadvantages of Interactive System User interaction can affect other job that are running on current system. Extra resources and cost is involved in interactive system. 1.3.3 Time Sharing Operating System: A time sharing system allows many users to share the computer resources simultaneously. In other words, time sharing refers to the allocation of computer resources in time slots to several programs simultaneously. For example a mainframe computer that has many users logged on to it. Each user uses the resources of the mainframe i.e. memory, CPU etc. The users feel that they are exclusive user of the CPU, even though this is not possible with one CPU i.e. shared among different users. As the system switches rapidly from one user to the other, a short time slot is given to each user for their executions. In above figure the user 5 is active but user 1, user 2, user 3, and user 4 are in waiting state whereas user 6 is in ready status. As soon as the time slice of user 5 is completed, the control moves on to the next ready user i.e. user 6. In this state user 2, user 3, user 4, and user 5 are in waiting state and user 1 is in ready state. The process continues in the same way and so on. Advantages of Time Sharing System More than one user can execute their task simultaneously. CPU Idle time is reduced and better utilization of resources. Disadvantages of Time Sharing System Question of securing the secutiy and integrity of user’s data and programs. Since multiple processes are managed simultaneously, so it requires an adequate management of main memory. 1.3.4 Multi Programmed Operating System A multiprogramming operating system is a system that allows more than one active user program (or part of user program) to be stored in main memory simultaneously. The operating system picks one of the programs and starts executing. Memory layout in Multiprogramming Operating System in given in following figure( In Multi Programming during execution of any program if it need some I/O operation to complete then unlike sitting idle for input as the case in a sequential execution environment the operating system will simply switch over to the next program. Advantages of Multi Programming Operating System Increase CPU untilization and reduce CPU idle time. It decreases total read time needed to execute a job as the jobs are in main memory. Disadvantages of Multi Programming Operating System It is fairly sophisticated and more complex as compared to Uniprogramming system. Process can consume more than available memory. In such case system slows down or it may hang some time. 1.3.5 Real Time Operating System (RTOS) It is an operating system (OS) intended to serve real-time application requests. It must be able to process data as it comes in, typically without buffering delays. These operating system handles those application where response time is of extreme importance. These operating systems are used to control machinery, scientific instruements and industrial systems. There are two types of real time systems Soft Real Time Systems: If certain deadlines are missed then system continues working with no failures and it doesn’t cause any severe disaster but its performance will degrade. It is less restrictive type of Real Time System. Example of Soft Real Time system is MP3 players on mobile. Hard Real Time Systems: If any deadlines are missed then then the system will not work and it will result in severe disasters. It is completely restrictive type of Real Time System. Example of Soft Real Time system is brakes in auto mobile, rocket launching, flight controls etc. Advantages of Real Time Operating System Better task scheduling as compared to manual process and time deadlines achievement is guaranteed in most of the cases. Accelerate the process by automanaging the system resources as in the case of Autopilot airplanes and railway e-ticket booking system. Disadvantages of Real Time Operating System If time dead lines are missed it may result in severe disastrous situation. Complex and need additional kernel, Memory and other resources are required. More vulnerable to security breaches like virus and unauthorized access. 1.3.6 Multiprocessing Operating System A multiprocessing system is a computer hardware configuration that includes more than one independent processing unit. Ther term multiprocessing is generally used to refer to a large cmputer hardware complexes found in major scientific and commercial applications. User can view the operating system as powerful uniprocessor system. CPU 1 CPU 2 CPU 3 CPU n Memory Advantages of Multiprocessing Operating System Due to multiplicity of processors, multiprocessor systems have better performance (shorter responses times and higher throughput) than single processor systems. In a properly designed multiprocessor system, if one of the processors breaks down, the other processor(s) automatically takes over the system workload until repairs are made. Hence, a complete breakdown of such systems can be avoided. Disadvantages of Real Time Operating System Expensive to procure and maintain so these systems are not suited to daily use. Requires immense overhead to schedule, balance, and coordinate the input, output, and processing activities of multiple processors. 1.3.7 Multitasking Operating System Multitasking operating systems allow more than one program to run at a time. An operating system that gives you the perception of 2 or more tasks/jobs/processes running at the same time. It does this by dividing system resources amongst these tasks/jobs/processes. And switching between the tasks/jobs/processes while they are executing very fast over and over again. There are two basic types of multitasking: preemptive and cooperative. In preemptive multitasking, the operating system parcels out CPU time slices to each program. In cooperative multitasking, each program can control the CPU for as long as it needs it. If a program is not using the CPU, however, it can allow another program to use it temporarily. Advantages of Multitasking Operating System Multitasking increases CPU untilization. Multiple tasks can be handled at a given time. Disadvantages of Multitasking Operating System To perform multitasking the speed of processor must be very high.to daily use. There are chances that the computer might hang while handling multiple process, but the Multitasking is one of the best feature of Operating System. 1.3.7 Multithreading Operating System Multitasking operating systems have the ability to execute different parts of a program, called threads, simultaneously. These threads are mutually exclusive parts of the program and can be executed simultaneously with out interfereing each other. For example the spell check process while typing content in MS-Word document is an example of Multithreading, because one thread will type the content on document while the other thread in background will work to check the spelling or grammatical errors in the document. Advantages of Multithreaded Operating System Increases CPU untilization by reducing idle time Mutually exclusive threads of the same application can be executed simultenously. Disadvantages of Multithreaded Operating System If not properly programmed, multiple threads can interfere with each other when sharing hardware resources such as caches. There are chances that the computer might hang while handling multiple process, but the Multitasking is one of the best feature of Operating System. 1.3.8 Multiuser Operating System A multi-user operating system is a computer operating system (OS) that allows multiple users on different computers or terminals to access a single system with one OS on it. The users will typically be at terminals or computers that give them access to the system through a network, as well as other machines on the system such as printers. A multi-user operating system differs from a single-user system on a network in that each user is accessing the same OS at different machines. Advantages of Multiuser Operating System More than one user can operate on centralized data. So this data grows or update for multiple users. Resources like printer and CPU can be shared across multiple computers. Disadvantages of Multiuser Operating System Increased cost is involved for having the additional infrastructure to connect multiple computers. Security threats regarding virus and unauthorized acess are higher in multi-user operating systems.