Operating System (2302CS401) - Darshan University PDF
Document Details
Uploaded by MagicalMendelevium
Darshan University
Prof. Asha A. Gondaliya
Tags
Summary
This document is course material for a 4th-semester Diploma in Computer Engineering at Darshan University, focusing on operating systems. It covers definitions, functions, features, and different types of operating systems like batch, multiprogramming, and time-sharing, including their advantages and disadvantages.
Full Transcript
# Darshan University: Operating System (2302CS401) ## Subject Material (English) - Diploma 4th Semester - (Computer) - Prof. Asha A. Gondaliya - Department of Computer Engineering ## Table of Content - **1.1 Operating Systems - Definitions** - Definition: - OS is a program/software th...
# Darshan University: Operating System (2302CS401) ## Subject Material (English) - Diploma 4th Semester - (Computer) - Prof. Asha A. Gondaliya - Department of Computer Engineering ## Table of Content - **1.1 Operating Systems - Definitions** - Definition: - OS is a program/software that manages the computer hardware. - It provides a simple interface to the hardware for user programs. - Goal of OS: - Convenience for users. - Efficient operation of the computer system. - Example: - Linux - Windows - Ubuntu - Mac - Android - Mac OS - **1.2 Functions of OS** - 1. Program development: - It provides editors and debuggers to assist (help) the programmer in creating programs. - 2. Program execution: - Following tasks need to be performed to execute a program: - Instructions and data must be loaded into main memory. - I/O devices and files must be initialized. - The OS handles all these duties for the user. - 3. Access to I/O devices (Resource allocation): - A running program may require I/O, which may involve file or an I/O device. - For efficiency and protection, users cannot control I/O devices directly. - Therefore, the OS controls these I/O devices and provides to program as per requirement. - 4. Memory management: - OS manages memory hierarchy. - OS keeps the track of which part of memory area in use and free memory. - It allocates memory to program when they need it. - It de-allocate the memory when the program finish execution. - 5. Controlled access to file: - In case of file access, OS provides a directory hierarchy for easy access and management of file. - OS provides various file handling commands using which user can easily read, write and modify file. - 6. Communication: - In multitasking environment, the processes need to communicate with each other and to exchange their information. - Operating system performs the communication among various types of processes in the form of shared memory. - 7. Error detection and response: - An error may occur in CPU, in I/O devices or in the memory hardware. - Following are the major activities of an operating system with respect to error handling: - The OS constantly checks for possible errors. - The OS takes an appropriate action to ensure correct and consistent computing. - 8. Accounting: - Keeping a track of which users are using how much and what kinds of computer resources can be used for accounting or simply for accumulating usage statistics. - Usage statistics is used to reconfigure the system to improve computing services. - 9. Protection & Security - Protection involves ensuring that all accesses to system resources is controlled. - To make a system secure, the user needs to authenticate himself or herself to the system. - **1.3 Features of Operating system** - 1. Interface between user and the computer - An OS provides a very easy way to interact with the computer. - It provides different features and GUI so that we can easily work on a computer. - We have to interact just by clicking the mouse or through the keyboard. Thus, we can say that an OS makes working very easy and efficient. - 2. Managing the Input / Output Device - The OS helps to operate the different input/output devices. - The OS decides which program or process can use which device. Moreover, it decides the time for usage. In addition to this, it controls the allocation and deallocation of devices. - 3. Multitasking - The OS helps to run more than one application at a time on the computer. - It plays an important role while multitasking. Since it manages memory and other devices during multitasking. Therefore, it provides smooth multitasking on the system. - 4. Manages the Memory - It helps in managing the main memory of the computer. - Moreover, it allocates and deallocates memory to all the applications/tasks. - 5. Manages the system files - It helps to manage files on the system. - As we know, all the data on the system is in the form of files. It makes interaction with the files easy. - 6. Provides Security - It keeps the system and applications safe through authorization. Thus, the OS provides security to the system. - 7. Booting - Booting is basically the process of starting the computer. - When the CPU is first switched ON it has nothing inside the memory. - So, to start the computer, we load the operating system into the main memory. Therefore, loading the OS to the main memory to start the computer is booting. Hence, the OS helps to start the computer when the power is switched ON. - **1.4 Types of Operating System** - **1.4.1 Batch Operating System** - In past, computer were large machines. - Input devices: Card readers, Tap drives - Output devices: Line printers, Punch cards and Tap drives - The OS was very simple and always reside in main memory. - Programmers would prepare a job and submit it to the operator. Job was consisted program, data and some control information. - Operator would sort them in batches with similar requirements, and as computer available, run them batch wise. - At some later time (Hours/Days), output appeared. The output consist of the result of the program and error information. - Advantages: - Multiple users can share the batch systems. - The idle time for batch system is very less. - It is easy to manage large work repeatedly in batch systems. - Disadvantages: - Low throughput – CPU remain idle when I/O is going on. - Programmers do not have direct interaction with job. - Debugging is possible only offline, after output appears. - Operations were too much time consuming. - **1.4.2 Multiprogramming Operating System** - A multiprogramming OS provides the ability to run more than one program concurrently. - Contrast to batch OS, here more than one program (or Job) can be loaded in main memory simultaneously. - These programs can be executed concurrently. - Memory is shared between OS and such kind of programs as such in fig. - Working: - A simple multiprogramming OS works in a non-preemptive manner - A program is allowed to execute until it voluntarily gives up the CPU. - A program voluntarily gives up the CPU in following two conditions: - It waits for some events like I/O operation, memory read/write, file read/write etc. - It terminates(After successfully completion of execution). - Once a CPU becomes free, it can be allocated to some other program as see in figure. - Objective: - The Primary objective of Multiprogramming OS is to maximize CPU usage. - Advantages: - Multiprogramming significantly improves system throughput and resource utilization. - Various resources such as CPU, can be utilized as much as possible among various simultaneously executing programs. - Disadvantages: - Complexity in handling multiple jobs. - Requires more memory. - **1.4.3 Time Sharing Operating System** - Time Sharing OS is a logical extension of the Multiprogramming OS. - CPU is multiplexed by time among several programs (or jobs) that are kept in main memory and on disk. - Working: - It works in preemptive manner. - A program is allowed to execute only for some maximum time duration. - After this time duration, a CPU is forcibly taken away from that program and allocated to another program. - Smaller programs need not to wait for other large program to finish its execution. - So it minimizes the response time for user. - They are suitable for interactive programs in which user can directly interact with the program. - Such type of system is also referred as multitasking system. - User can perform more than one task simultaneously. - For ex. User can execute program like MS-Word to prepare a document, as well as can run some other program like Windows Media Player to play songs. Both of these task can be performed simultaneously. - Objective: - The primary objective of Time Sharing OS is to provide better response time to users. - Advantages: - Improvement in system throughput and resource utilization - Response time is low. - It also allows sharing of computer among multiple users simultaneously. - It gives an illusion/impression to each user as if the entire computer resources are available to him only. - Usage: - Memory management & protection - Swapping and virtual memory - CPU scheduling - Disk management - Synchronization & Communication - **1.4.4 Single User OS** - A single-user operating system is a type of operating system developed for use on a computer or similar machine that will only have a single user at any given time. - This type of OS is typically used on devices like wireless phones and two-way messaging devices. - Single user operating system can only run one program or application at a time. - So it is not as useful for a computer or other device intended to run multiple programs at once. - Advantages: - This OS occupies less space in memory. - Easy to maintain. - Less chance of damage. - This is a single-user interface it allows only one user's tasks to execute in a given time. - In this operating system only one user work at a time, so there will be no interruption of others. - Disadvantages: - It can perform only a single task. - The main drawback is, the OS remains idle for most of the time and is not utilized to its maximum. - Tasks take longer to complete. - It has a high response time. - **1.4.5 Multiuser Operating System** - In a multiuser operating system, multiple numbers of users can access different resources of a computer at the same time. - A multi-user operating system allows the permission of multiple users for accessing a single machine at a time. - The various personal computers can send and receive information to the mainframe computer system. - Thus, the mainframe computer acts as the server and other personal computers act as clients for that server. - Users will usually sit at terminals or computers connected to the system via a network and other system machines like printers. - Advantages: - It helps in the sharing of data and information among different users. - It also helps in the sharing of hardware resources such as printers. - Users can share their work with other users. - Disadvantages: - It requires expensive hardware to set up a mainframe computer - When multiple users log on or work on the same system it reduces the overall performance of the system. - Information is shared with the public so privacy loss. - **1.5 Components of Operating System** - Hardware: - The hardware comes at the lowest Level. It contains various kind of physical devices like processor, memory, keyboard, mouse, monitor etc. - Operating System: - The next level is for the OS. So, it provides simple interface between application programs and hardware. It manages all the connected hardware. It hides complex details of hardware from the users. - Application Programs: - Application programs perform particular tasks. They use different kinds of functionalities provided by OS. Ex. railway reservation system, banking system, web-browser. - User - The users comes at the top level. Users interact with the system by using application programs to perform particular tasks. - **1.6 Operating System Services** - OS services can be described from two different points of view: - OS From User point of View - OS From System point of View - **1.6.1 OS From User View** - This is a top-down view. - From user point of view, OS can be considered as an Extended Machine. - OS represents the computer system as a machine which is easier to program rather than connected hardware. - OS hides all the details of the hardware. - It act as a layer between user and hardware, and provides simple interface between them. - User doesn't need to concern about the complexities of the hardware. - User have to just use the functionalities provided by the OS such as system calls, to make his work done. - The primary goal of OS is the Convenience of User. - Services - 1. Program Execution: - The OS provides an efficient and convenient environment for the execution of programs. So, an OS must provide functions for loading a program into main memory, execute it, and after execution, terminate it. - 2. 1/0 Operations - A running program needs 1/0 operations for reading input data, and for outputting the results. This I/O may be with a file or with device. - 3. File System Manipulation - OS provides file system manipulation functionalities like create, read, write and delete a file. - 4. Communications: - In multitasking OS more than one processes are running simultaneously. - Some time there is a need to exchanging information among processes. The OS provide communications for such inter processes. - 5. Error Detection: - Errors may be in user programs. CPU and memory hardware, or in I/O devices. OS detects such errors and makes user aware from them. - **1.6.2 OS: From System View** - This is a bottom-up view. - OS can be considered as Resource Manager. - OS manages all the resources such as CPU, memory, I/O devices. - By multiplexing them in TIME: - Here, each user takes turn to use the resource. Ex. CPU - By multiplexing them in SPACE: - Here, each user gets parts of the resource. Ex. Memory - The primary goal of OS is the Efficiency of OS. - Services - 1. Resource Allocation - When multiple user are sharing the same machine, or when multiple jobs are running simultaneously, there is a need of fair allocation of resources among them. - 2. Accounting - The OS keeps information about the users uses which resources, and for what duration of time. Such information can be used to bill the users in multi-user environment, or to get information of future usage of resources. - 3. Security - OS ensures that all access to system resources is controlled. Also security from outsiders is important. - **1.7 System Calls** - A system call is a way for programs to interact with the operating system. - A system call is a mechanism that provides the interface between a process and the operating system. - A computer program makes a system call when it makes a request to the operating system's kernel. - When the application requests the help of the operating system that time system call occurs. - When it will require hardware then only it will come to kernel mode. - After compilation of the work of hardware resources it will again come back to user mode. - **1.7.1 Types of System Calls** - Process Control: This system calls perform the task of process creation, process termination, etc. - Functions: - Load and execute - Create process and terminate process - Wait and signed event - Allocate and free memory - File Management: File management system calls handle file manipulation jobs like creating a file, reading, and writing, etc. - Functions: - Create a file - Delete file - Open and close file - Read, write and reposition - Get and set file attributes - Device Management: Device management does the job of device manipulation like reading from device buffers, writing into device buffers, etc. - Functions: - Request and release device - Logically attach/ detach devices - Get and Set device attributes - Information Maintenance: It handles information and its transfer between the OS and user program. - Functions: - Get or set time and date - Get process and device attributes - **1.8 System Programs** - In an operating system a user is able to use different types of system programs and the system program is responsible for all the application software performance of the computer. - The system programs are responsible for the development and execution of a program. - System programs communicate and coordinate the activities and functions of hardware and software of a system and also controls the operations of the hardware. - Following Various types of task perform by programs. - File management – these programs create, delete, copy, rename, print, exit and generally manipulate the files and directory. - Status information – It is the information regarding input, output process, storage and the CPU utilization time how the process will be calculated in how much memory required to perform a task is known by status information. - Programming language supports – compiler, assembler, interrupt are programming language support used in the operating system for a particular purpose in the computer. - Programming Loading and execution – the needs to enter the program and after the loading of a program it needs to execute the output of the programs and this task is also performed by system calls by the help of system programs. - Communication – These services are provided by the user because by using this number of devices communicates with each other by the help of device or wireless and communication is necessary for the operating system. - **1.8.1 Types of System programs** - Utility program: - It manages, maintains and controls various computer resources. - Example: antivirus software, backup software - Device drivers: - It controls the particular device connected to a computer system. Device drivers basically act as a translator between the operating system and device connected to the system. - Example - printer driver, scanner driver, storage device driver etc. - **1.9 System Structure** - An operating system is a structure that allows the user application programs to interact with the system hardware. - A system structure for an operating system is like the blueprint of how an OS is organized and how its different parts interact with each other. - Because operating systems have complex structures, we want a structure that is easy to understand. - It is easier to create an operating system in pieces, much as we break down larger issues into smaller, more manageable sub problems. - Operating systems are implemented using many types of structures, as will be discussed below: - **1.9.1 Types of System Structure** - We have the following structures in the operating system: - Monolithic Systems - Layered Systems - Client-server Model - **1.9.1.1 Monolithic Systems** - In monolithic structured operating system, a central piece of code called kernel is responsible for all major operations of an operating system. - Such operations includes file management, memory management, and device management and so on. - The kernel is the main component of an operating system and it provides all the services of an operating system. - The kernel has access to the all the resources and it acts as an interface with application programs and the underlying hardware. - A monolithic kernel structure promotes timesharing, multiprogramming model and was used in old banking systems. - Advantages: - Easy Development: As kernel is the only layer to develop with all major functionalities, it is easier to design and develop. - Performance: As Kernel is responsible for memory management, other operations and have direct access to the hardware, it performs better. - Disadvantages: - Crash Prone: As Kernel is responsible for all functions, if one function fails entire operating system fails. - **1.9.1.2 Layered Systems** - In this system, the OS is organized as a hierarchy of layers. - In this structure, the OS is broken into a number of layers (levels). The bottom layer (layer 0) is the hardware, and the topmost layer (layer N) is the user interface. - The functionalities of each layer are separated in this method, - This simplifies the debugging process, if lower-level layers are debugged and an error occurs during debugging, then the error must be on that layer only, as the lower-level layers have already been debugged. - Advantages: - Implementation of a layer can be changed easily without affecting the other layers. - It is very easy to perform debugging and system verification. - Disadvantages: - Simple structure. - It requires careful planning for designing the layers. - **1.9.1.3 Virtual Machine** - In this system structure that enables the execution of multiple operating systems concurrently on the same hardware. - It provides virtualized environments for guest operating systems and manages their interactions with the same hardware. - We can develop a virtual machine for a variety of reasons, all of which are fundamentally connected to the capacity to share the same underlying hardware while concurrently. - Advantages: - Simple availability, accessibility, and recovery convenience. - Secure. - Disadvantages: - Depending on the workload. - Virtual computers are less effective than physical ones. - In a multi-user system, different user needs to access different part. ## List of Figure - FIGURE 1.1 BATCH OPERATING SYSTEM.. - FIGURE 1.2 MULTIPROGRAMMING OPERATING SYSTEM - FIGURE 1.3 MULTIPROGRAMMING WITH THREE PROGRAM.. - FIGURE 1.4 COMPONENTS - FIGURE 1.5 SYSTEM CALL - FIGURE 1.6 MONOLITHIC KERNEL - FIGURE 1.7 LAYERED SYSTEM..