Unit 1 - Introduction to OS Presentation PDF
Document Details
Uploaded by CourtlyIambicPentameter
Tags
Summary
This presentation provides an introduction to operating systems (OS). It explains the foundational concepts of computer systems, including components like the CPU, memory, and I/O devices, and how OS manages them.
Full Transcript
Unit-1 Introduction to Operating System Outline Computer system overview Computer system architecture What is Operating System (OS) Roles of Operating System (OS) Objectives / Goals of Operating System (OS) Generations of Operating Systems (OS) Operating Systems...
Unit-1 Introduction to Operating System Outline Computer system overview Computer system architecture What is Operating System (OS) Roles of Operating System (OS) Objectives / Goals of Operating System (OS) Generations of Operating Systems (OS) Operating Systems (OS) services Types of Operating Systems (OS) System calls Operating Systems (OS) structure Multiprogramming v/s Multiprocessing v/s Multitasking Time Sharing Operating System Parallel Processing Operating System Distributed Operating System Computer system overview A computer is an electronic device that can be programmed to accept data (input), process it and generate result (output). A computer along with additional hardware and software together is called a computer system. A computer system primarily comprises a central processing unit (CPU), memory, input/output devices and storage devices. All these components function together as a single unit to deliver the desired output. A computer system comes in various forms and sizes. It can vary from a high-end server to personal desktop, laptop, tablet computer, or a smartphone. Computer System Architecture Figure 1.1 Continue.. Figure 1.1 shows the block diagram of a computer system. The directed lines represent the flow of data and signal between the components. Input unit It provides data and instructions to the computer system. Commonly used input devices are keyboard, mouse, magnetic tape etc. Input unit performs following tasks: Accept the data and instructions from the outside environment. Convert it into machine language. Supply the converted data to Output unit It connects the internal system of a computer to the external environment. It provides the results of any computation, or instructions to the outside world. Some output devices are printers, monitor etc. Storage unit This unit holds the data and instructions. It also stores the intermediate results before these are sent to the output devices. It also stores the data for later use. The storage unit of a computer system can be divided into two categories: Primary Storage Secondary Storage Primary storage (memory) vs Secondary storage (memory) Primary storage Secondary storage Examples: RAM, ROM, Cache Examples: Hard Disk, Floppy Disk, memory, PROM, EPROM, Magnetic Tapes, etc. Registers, etc. and volatile. It is temporary It is permanent and Non-volatile. Primary memory is directly Secondary memory is not directly accessible by Processor/CPU. accessible by the CPU. Primary memory devices are Secondary memory devices are expensive. cheaper. The memory devices used for The secondary memory devices primary memory are are magnetic and optical semiconductor Primary memorymemories. is also known as memories. Secondary memory is also known Main memory or Internal memory. as External memory or Auxiliary memory. CPU (Central Processing Unit) The Arithmetic Logical Unit and Control Unit are together known as CPU. CPU is the brain of computer system. It performs following tasks: performs all operations. takes all decisions. controls all the units of computer. ALU (Arithmetic Logical Unit) All the calculations are performed in ALU of the computer system. The ALU can perform basic operations such as addition, subtraction, division, multiplication etc. Whenever calculations are required, the control unit transfers the data from storage unit to ALU. When the operations are done, the result is transferred back to the storage unit. CU (Control Unit) It controls all other units of the computer. It controls the flow of data and instructions to and from the storage unit to ALU. Thus it is also known as central nervous system of the computer. What is Operating System (OS) A Computer System consists of various hardware's such as Processo RAM Keyboard & r Mouse Hard Monito Printe Disk r r Who manages (controls) these Operating hardwares??? System Definition of Operating System (OS) An Operating System (OS) is a collection of software that manages hardware resources provides various service to the users Examples of Operating System (OS) Where OS lies? (Interaction of OS & Hardware) OS lies between hardware and user program. It acts as an intermediary Web E-mail Music between the user and the hardware. browser reader player Modes of operation of computer 1. Kernel Mode User has complete access to all the User Program Mode hardware Software can execute any instruction that a Kernel Operating System machine is capable of executing Mode has high privileged (rights) Hardware 2. User Mode has limited access to limited hardware can execute only subset (few) of the machine instructions has less privileged (rights) Roles of Operating System (OS) OS as Extended Machine The architecture of a computer is difficult to program Architecture (instruction set, memory organization, I/O, bus structure) of most of computer at the machine level language is primitive and awkward to program. Example: If user want to read from floppy or hard disk: OS as Extended Machine Example: If user want to read from floppy or hard disk: User has to write command and address to the disk controller and then initiate Disk the I/O. Controller OS as Extended Machine The disk controller will find the User has to check the requested data in the disk and status of disk controller fetch it from disk to disk controller operation where it has buffer. finished or not. OS as Extended Machine If success, the data from disk controller buffer should be moved to main memory (to the application buffer). OS as Extended Machine If all the users will have to do these messy details: The program will be very difficult to write and quite long. The program will be hardware dependent. User don’t want to be involved in programming of storage devices. Therefore, an OS provides a set of basic commands or instructions to perform various operations such as read, write, modify, save or close. Dealing with these command is easier than directly dealing with hardware. Operating system hides the complexity of hardware and present a beautiful interface to the users. OS as Resource Manager There are lots of resources in computer system CPU (Processor) Memory I/O devices such as hard disk, mouse, keyboard, printer, scanner etc. If a computer system is used by multiple applications (or users), then they will compete for these resources. OS as Resource Manager It is the job of OS to allocate these resources to the various applications so that: The resources are allocated fairly (equally) Wants to print 50 P1 lines After printing 10 lines of P1 Wants to print 20 P2 lines After printing 20 lines of P1 Wants to print 15 P3 lines Wants to print 15 P4 lines OS as Resource Manager It is the job of OS to allocate these resources to the various applications so that: The resources are protected from cross-access. Wants to print 50 P1 lines After printing 10 lines of P1 Wants to print 20 P2 lines After printing 20 lines of P1 Wants to print 15 P3 lines Wants to print 15 P4 lines OS as Resource Manager It is the job of OS to allocate these resources to the various applications so that: Access to the resources is synchronized so that operations are correct and consistent Example: If we write a program to calculate below in C language 7+9–6*4/ P P P P 2=4 1 20 2 3 4 3 4 1 2 OS as Resource Manager It is the job of OS to proper allocate these resources to the various applications so that: Deadlock are detected, resolved and avoided. OS as Resource Manager Resource manager – sharing resources in two different ways: 1. In time sharing/multiplexing (i.e CPU) OS as Resource Manager Resource manager – sharing resources in two different ways 2. In space sharing/multiplexing. (i.e Memory) Proces Process Process Empty s1 2 3 Space Main Memory Objectives / Goals of Operating System (OS) system convenient to use in an Make the computer efficient manner. Hide the details of the hardware resources from the users. Provide users a convenient interface to use the computer system. Act as an intermediary between the hardware and its users, making it easier for the users to access and use other resources. Manage the resources of a computer system. Keep track of who is using which resource, granting resource requests, and mediating conflicting requests from different programs and users. Provide efficient and fair sharing of resources among Generations of Operating Systems (OS) Generations / History of OS (First generation) First generation (1945-1955) Vacuum tubes and plug-boards are used in these systems. Vacuum tubes Plug board Generations / History of OS (Second generation) Second generation (1955-1965) Transistors are used in these systems The machine that are produced are called mainframes. Batch systems was used for processing. Programmers 1401 bring reads cards batch Operator of jobs carries 7094 input Operator does tape carries output 1401 prints tape toonto 1401tape to 7094 computing to 1401 output Generations / History of OS (Third generation) Third generation (1965-1980) Integrated circuits (IC's) are used in place of transistors in these computers. It provides multiprogramming (the ability to have several programs in memory at once, each in its own memory partition). Generations / History of OS (Forth generation) Fourth generation (1980-present) Personal Computers (PC) LSI (Large Scale Integration) circuits, chips containing thousands of transistors are used in these systems. Services / Functions / Tasks of Operating System (OS) Definition of Operating System An Operating System (OS) is a collection of software that manages hardware resources provides various service to the users Services / Functions / Tasks of Operating System (OS) 1. Program development It provides editors and debuggers to assist (help) the programmer in creating programs. Services / Functions / Tasks of Operating System (OS) 2. Program execution Following tasks need to be perform 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. Services / Functions / Tasks of Operating System 3. Access to(OS) 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. Services / Functions / Tasks of Operating System (OS) 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. P1 P2 Services / Functions / Tasks of Operating System 5. Controlled(OS) 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. Services / Functions / Tasks of Operating System (OS) 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. Services / Functions / Tasks of Operating System (OS)and response 7. Error detection 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. Services / Functions / Tasks of Operating System (OS) 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. Services / Functions / Tasks of Operating System 9. Protection(OS) & 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. Types of Operating Systems (OS) Types of Operating Systems (OS) 1. Mainframe operating systems OS found in room sized computers which are still found in major corporate data centers. They offer three kinds of services: 1. Batch OS 2. Transaction processing 3. Timesharing Examples: OS/390, OS/360. Mainframe Operating Systems services Batch OS – processes routine jobs without any interactive user presents i.e. claim processing in insurance Transaction processing – handles large numbers of small processes i.e. cheque processing at banks Timesharing – allows multiple remote users to run their jobs at once i.e. querying a database, airline booking system Types of Operating Systems (OS) 2. Server operating systems This OS runs on servers which are very large PC, workstations or even mainframes. They serve multiple users at once over a network and allow the users to share hardware & software resources. It provides print services, file service or web service. It handles the incoming requests from clients. Examples: Solaris, FreeBSD, and Linux and Windows Server 200x. Types of Operating Systems (OS) 3. Multiprocessor operating systems A computer system consist two or more CPUs is called multiprocessor. It is also called parallel computers, multicomputer or multiprocessor. They need special OS or some variations on server OS with special features for communication, connectivity and consistency. Examples: Windows and Linux. Types of Operating Systems (OS) 4. Personal computer operating systems The operating systems installed on our personal computer and laptops are personal OS. Job of this OS is to provide good support to single user. This OS is widely used for word processing, spreadsheet and internet access. Examples: Linux, Windows vista and Macintosh. Types of Operating Systems (OS) 5. Handhelds computer operating systems A handheld computer or PDA (Personal Digital Assistant) is small computer that fit in a Pocket and perform small number of functions such as electronic address book, memo pad. The OS runs on these devices are handheld OS. These OS also provides ability to handle telephony, digital photography and other functions. Examples: Symbian OS, Palm OS. Types of Operating Systems (OS) 6. Embedded operating systems This OS is installed in ATMs, printers, calculators and washing machine. It runs on the computer that control devices. It neither allow to download new software nor accept user installed software. So there is no need for protection. Examples: QNX, VxWorks. Types of Operating Systems (OS) 7. Sensor node operating systems Network of tiny sensor nodes are being developed for numerous purpose. Each nodes are tiny computers with a CPU, RAM, ROM and one or more environmental sensors. The OS installed in these nodes are sensor node OS. They communicate with each other and with base station using wireless communication. These sensor network are used to protect area of building, detect fires in forest, measure temperature. Examples: TinyOS. Types of Operating Systems (OS) 8. Real time operating systems These systems having time as a key parameter. Real time OS has well defined fixed time constraints. Processing must be done within defined time constraints otherwise system fails. Two types of real time OS: Hard real time – missing an occasional deadline can cause any permanent damage. Many of these are found in industrial process control, car engine control system. Soft real time – missing an occasional deadline does not cause any permanent damage. Used in digital audio, multimedia system. Examples: e-Cos. Types of Operating Systems (OS) 9. Smart card operating systems Smallest OS run on smart cards which are credit card sized devices containing CPU chip. These OS are installed on electronic payments cards such as debit card, credit card etc. They have limited processing power. Some smart cards are Java oriented. ROM on smart card holds an interpreter for the JVM – small program. System calls What is 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. It is a programmatic method in which a computer program requests a service from the kernel of the OS. System call provides the services of the operating system to the user programs via Application Program Interface(API). System calls are the only entry points for the kernel system. Types of system calls Process Control: This system calls perform the task of process creation, process termination, etc. Functions: End and abort 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 Types of system calls 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 Types of system calls Communication: These types of system calls are specially used for interprocess communications (IPC). Functions: Create, delete communications connections Send, receive message Help OS to transfer status information Attach or detach remote devices Example of system calls (Read system call) Example: In Unix Read system call is count = read(fd, Return to caller Library buffer, nbytes) Trap to the kernel procedure fd is a file descriptor. 5 Put code for read in read register When a file is opened, 1 6 Call to library permissions are checked. 0 User proc If access is allowed, a 4 1 number (fd) is returned. space Increment SP 1 Then file can be Call read User read/written. 3 Push fd program nbytes is number of Push calling read bytes to read 2 Push &buffer parameter 9 buffer is where read onto stack 1 Push nbytes deposits (stores) the data Sys Kernel Dispat 7 8 call space ch handl er Steps involved in making a system call (Read system call) Steps involved in making a system call In steps 1-3, the calling program pushes the parameters onto the stack. The first and third parameters are called by value, but the second one is called by its address as denoted by the & symbol. In step 4, the actual call to the library procedure is made. This instruction is the normal procedure call instruction used to call all procedures. In step 5, the library procedure places the system call number in a place where the operating system expects it, such as a register. In step 6, the library procedure executes a TRAP instruction to switch from user mode to kernel mode and start execution at a fixed address within the kernel. In step 7, the kernel examines the system call number and then dispatches it to the correct system call handler. This correct number is given in the table of system call handlers by pointers referenced at the system call number. In step 8, the system call handler runs. In step 9, the operation is completed, and the user is given back control once the TRAP instruction is set. In step 10, this procedure returns to the user program, like how all normal library procedures do. In step 11, the operating system has to clear the stack, so it increments it enough so System calls System calls Multiprogramming v/s Multiprocessing v/s Multitasking Multiprogramming v/s Multiprocessing v/s Multitasking Multiprogrammin Multiprocessing Multitasking g Multiprogramming v/s Multiprocessing v/s Multitasking Multiprogramming Multiprocessing Multitasking The concurrent The availability of more The execution of residency of more than one processor per more than one task than one program in system, which can simultaneously is the main memory is execute several set of called as called as instructions in parallel multitasking. multiprogramming. Number of processor: is called of Number as processor: Number of processor: one multiprocessing more than one one One process is More than one process One by one job is executed at a time. can be executed at a being executed at a time. Multitasking is a logical time. extension of multi programming. The major way in which multitasking differs from multi programming is that multi programming works solely on the concept of context switching whereas multitasking is based on time sharing alongside the concept of context switching. Time Sharing Operating System Time Sharing Operating System A time sharing operating 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. Parallel Processing Operating System Parallel Processing Operating Systems are Multiprocessing designed to speed up the execution of programs by dividing the program into multiple fragments and processing these fragments simultaneously. Such systems are multiprocessor systems. Parallel systems deal with the simultaneous use of multiple computer resources that can include a single computer with multiple processors. Distributed Operating System Distributed Operating System is a model where distributed applications are running on multiple computers linked by communications. A distributed operating system is an extension of the network operating system that supports higher levels of communication and integration of the machines on the network. Views of Operating System An operating system is a framework that enables user application programs to interact with system hardware. The operating system does not perform any functions on its own, but it provides an atmosphere in which various apps and programs can do useful work. The operating system may be observed from the point of view of the user or the system, and it is known as the user view and the system view. Viewpoints of Operating System 1. User View The user view depends on the system interface that is used by the users. Some systems are designed for a single user to monopolize the resources to maximize the user's task. In these cases, the OS is designed primarily for ease of use, with little emphasis on quality and none on resource utilization. The user viewpoint focuses on how the user interacts with the operating system through the usage of various application programs. In contrast, the system viewpoint focuses on how the hardware interacts with the operating system to complete various tasks. Continue… 1. Single User View Point Most computer users use a monitor, keyboard, mouse, printer, and other accessories to operate their computer system. In some cases, the system is designed to maximize the output of a single user. As a result, more attention is laid on accessibility, and resource allocation is less important. These systems are much more designed for a single user experience and meet the needs of a single user, where the performance is not given focus as the multiple user systems. 2. Multiple User View Point Another example of user views in which the importance of user experience and performance is given is when there is one mainframe computer and many users on their computers trying to interact with their kernels over the mainframe to each other. In such circumstances, memory allocation by the CPU must be done effectively to give a good user experience. The client-server architecture is another good example where many clients may interact through a remote server, and the same constraints of effective use of server resources may arise. Continue… 3. Handled User View Point Moreover, the touchscreen era has given you the best handheld technology ever. Smartphones interact via wireless devices to perform numerous operations, but they're not as efficient as a computer interface, limiting their usefulness. However, their operating system is a great example of creating a device focused on the user's point of view. 4. Embedded System User View Point Some systems, like embedded systems that lack a user point of view. The remote control used to turn on or off the tv is all part of an embedded system in which the electronic device communicates with another program where the user viewpoint is limited and allows the user to engage with the application. System View The OS may also be viewed as just a resource allocator. A computer system comprises various sources, such as hardware and software, which must be managed effectively. The operating system manages the resources, decides between competing demands, controls the program execution, etc. According to this point of view, the operating system's purpose is to maximize performance. The operating system is responsible for managing hardware resources and allocating them to programs and users to ensure maximum performance. From the user point of view, we've discussed the numerous applications that require varying degrees of user participation. However, we are more concerned with how the hardware interacts with the operating system than with the user from a system viewpoint. The hardware and the operating system interact for a variety of reasons, including: Continue… 1. Resource Allocation The hardware contains several resources like registers, caches, RAM, ROM, CPUs, I/O interaction, etc. These are all resources that the operating system needs when an application program demands them. Only the operating system can allocate resources, and it has used several tactics and strategies to maximize its processing and memory space. The operating system uses a variety of strategies to get the most out of the hardware resources, including paging, virtual memory, caching, and so on. These are very important in the case of various user viewpoints because inefficient resource allocation may affect the user viewpoint, causing the user system to lag or hang, reducing the user experience. 2. Control Program The control program controls how input and output devices (hardware) interact with the operating system. The user may request an action that can only be done with I/O devices; in this case, the operating system must also have proper communication, control, detect, and handle such devices. THANK YOU