Os 003

You might also like

Download as pdf
Download as pdf
You are on page 1of 21
UNIT -I Operating System Introduction System components ided roughly into four components: the hardware, the A computer system can be ‘operating system, the application programs, and the users. © Hardware: The hardware the central processing unit (CPU). the memory, and the input/output (V0) devices—provide the basic computing resources for the system + Application programs: The application programs. such as word processors. spreadsheets. compilers. and Web browsers—define the ways in which these resources are used to solve users’ computing problems. * Operating system: The operating system controls the hardware and coordinates its use among the various application programs for the various users. We can also view a computer system as consisting of hardware, software, and data. ‘The operating system provides the means for proper use of these resources in the operation of the computer system. An operating system is similar to a government. Like a government, it Performs no useful function by itself. It simply provides an environment within which other programs can do useful work. Operating System Definition An operating system is a program that manages a computer’s hardware. It alo Provides a basis for application programs and acts as an intermediary between the computer user and the computer hardware. or An Operating system is one of the programs running at all times on the computer, usually called kernel. Structures Serial Processing * With the earliest computers, fiom the late 1940s to the mid-1950s, the programmer interacted directly with the computer hardware; there was no OS. * These computers were run from a console consisting of dis some form of input device, and a printer. ‘+ The users have access to computer in series. If the programmer wish to execute a program, they need to follow certain steps, > Programs in machine code were loaded via the input device (c.g., a card reader). > Ifan error halted the program, the error condition was indicated by the lights. > Ifthe program proceeded to a normal completion, the output appeared on the printer. ‘+ Two main problems: > Scheduling: A user could sign up for a block of time in multiples of a half hour or so. A user might sign up for an hour and finish in 45 minutes; this would result in wasted computer processing time. On the other hand, the user might run into problems, not finish in the allotted time, and be forced to stop before resolving the problem. > Setup time: A single program, called a job, could involve loading the compiler plus the high-level language program (source program) into memory, saving the compiled program (object program), and then loading and tinking together the object program and common functions. Each of these steps could involve mounting or dismounting tapes or setting up card decks. If an error occurred, the hapless user typically had to go back to the beginning of the setup sequence. Thus, a considerable amount of time was spent just in setting up the program to run, lay lights, toggle switches, Simple Batch + Early computers were very expensive, and wasted time, so the concept of batch OS was developed * Monitor > The central idea behind the simple batch-processing scheme is the use of a piece of software known as the monitor. With this type of OS, the user no longer has direct access to the processor. > Instead, the user submits the job on cards or tape to a computer operator, who batches the jobs together sequentially and places the entire batch on an input device, for use by the monitor. > Each program is constructed to branch back to the monitor when it completes processing, at which point the monitor automatically begins loading the next program. Two view points > Monitor point of view: The monitor controls the sequence of events. For this to be so, much of the monitor must always be in main memory and available for execution. That portion is referred to as the resident monitor. The rest of the monitor consists of utilities and common functions that are loaded as subroutines to the user program at the beginning of any job that requires them. The monitor reads in jobs one at a time from the input device (typically a card reader or magnetic tape drive). As it is read in, the current job is placed in the user program area, and control is passed to this job. When the job is completed, it returns control to the monitor, which immediately reads in the next job. The results of each job are sent to an output device, such as a printer, for delivery to the user. Device drivers Monitor Bounlary —_y |. > Processor point of view: At a certain point, the processor is executing instructions from the portion of main memory containing the monitor. These instructions cause the neat job to be read into another portion of main memory. Once a job has been read in, the processor will encounter a branch instruction in the monitor that instructs the Processor to continue execution at the start of the user program. The processor will then execute the instructions in the user program until it encounters an ending or error condition, Either event causes the processor to fetch its next instruction from the ‘monitor program. * The monitor performs a scheduling function: A batch of jobs is queued up, and jobs are executed as rapidly as possible, with no intervening idle time. The monitor improvés job setup time using job control language (JCL). Multi-programmed * A single program cannot, in general, keep either the CPU or the I/O devices busy at all times. Single users frequently have multiple programs running. ‘+ Multiprogramming increases CPU utilization by organizing jobs (code and data) so that the CPU always has one to execute, * The idea is as follows: The operating system keeps several jobs in memory simultaneously. Since, in general, main memory is too small to accommodate all jobs; the jobs are kept initially on the disk in the job pool. This pool consists of all processes residing on disk awaiting allocation of main memory. The set of jobs in memory can be a subset of the jobs kept in the job pool. The operating system picks and begins to execute one of the jobs in memory. Eventually, the job may have to wait for some task, such as an I/O operation, to complete. * In a non-multiprogrammed system, the CPU would sit idle. In a multiprogrammed system, the operating system simply switches to, and executes, another job. When that job needs to wait, the CPU switches to another job, and so on * Eventually, the first job finishes waiting and gets the CPU back. As long as at least one job needs to execute, the CPU is never idle. '* This idea is common in other life situations. A lawyer does not work for only one client at a time, for example, While one case is waiting to go to trial or have papers typed, the lawyer can work on another case, If he has enough clients, the lawyer will never be idle for lack of work. Time-shared Time sharing (or multitasking) is a logical extension of multiprogramming. In time- sharing systems, the CPU executes multiple jobs by switching among them, but the switches occur so frequently that the users can interact with each program while it is running. Time sharing requires an interactive computer system, which provides direct communication between the user and the system, The user gives instructions to the operating system ot to a program directly, using an input device such as a keyboard, mouse, touch pad, or touch screen, and waits for immediate results on an output device Accordingly, the response time should be short—typically less than one second. * A ttime-shared operating system allows many users to share the computer simultaneously. UV Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user. As the system switches rapidly from one user to the next, each user is given the impression that the entire computer system is dedicated to his use, even though it is being shared among many users. A time-shared operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared computer. Personal Computer * A Personal computer is a small relatively in expensive computer designed for an individual user. These are based on microprocessor technology that enables ‘manufactures to put an entire CPU on one chip. The goal is to maximize the work (or play) that the user is performing with some attention paid to performance and none paid to resource utilization. +. Personal computers are used for word processing, accounting, running spreadsheets, database management applications, games ete., l | Parallel Systems * Also known as parallel systems or multicore systems. * Definition: Systems having two or more processors in close communication, sharing the computer bus and sometimes the clock, memory, and peripheral devices. © Advantages > Increased throughput. By increasing the number of processors, we expect to get more work done in less time. When multiple processors cooperate on a task, a certain amount of overhead is incurred in keeping all the parts working correctly. This overhead, plus contention for shared resources, lowers the expected gain from additional processors, Economy of scale. Multiprocessor systems can cost less than equivalent multiple single-processor systems, because they can share peripherals, mass storage, and 4 v power supplies. > Increased reliability. If functions can be distributed properly among. si processors, then the failure of one processor will not halt them system, only slow it down. If we have ten processors and one fils, then each of the remaining nine processors can pick up a share of the work of the failed processor. ‘Thus, the entire system runs only 10 percent slower, rather than failing altogether. Increased reliability of a computer system is crucial in many applications, ‘The ability to continue providing service proportional to the level of surviving hardware is called graceful degradation, Some systems go beyond graceful degradation and are called fault tolerant, because they can suffer a failure of any single component and still continue operation. + Two Types Multiple-Processor Systems > Asymmetric multiprocessing: each processor is assigned a specific task. A boss Processor controls the system; the other processors either look to the boss for instruction or have predefined tasks. This scheme defines a boss-worker relationship. The boss processor schedules and allocates work to the worker C processors > Symmetric multiprocessing (SMP): each processor performs all tasks within the operating system, SMP means that all processors are peers; no boss—worker relationship exists between processors. ] a we (| el co — | J || ED | Lam | Ge fe eS Sel Aspamtic Mol Fracensing C Distributed Systems | + A distributed system is a collection of physically separate, possibly heterogeneous, | computer systems that are networked to provide users with access to the various resources that the system maintains. * Access to a shared resource increases computation speed, functionality, data availability, and reliability, * Distributed systems depend on networking for their functionality, + Networks vary by the > Protocols used : Most OS support TCP/IP | » Distances between the nodes: LAN, WAN, MAN, PAN > Transport media: Copper wires, fiber stands & wireless transmissions * A network operating system is an operating system that provides features such as file sharing across the network, along with a communication scheme that allows different 5 processes on different computers to exchange messages. ‘© A distributed operating system provides a less autonomous environment, A distributed ‘operating system provides a less autonomous environment, The different computers communicate closely enough to provide the illusion that only a single operating system controls the network. ‘+ Reasons for building distributed systems There are four major reasons for building distributed systems, > Resource Sharing : If a number of different sites (with different capabilities) are connected to one another, then a user at one site may be able to use the resources available at another. For example, a user at site A may be using a laser printer located at site B. Meanwhile, a user at B may access a file that resides at A. > Computation Speedup: If a particular computation can be partitioned into sub computations that can run concurrently, then a distributed system allows us to distribute the sub computations among the various sites. The sub computations can be run concurrently and thus provide computation speedup. > Reliability: [fone site fails in a distributed system, the remaining sites can continue operating, giving the system better reliability. Communication: When several sites are connected to one another by a communication network, users at the various sites have the opportunity to exchange information. v Real-Time Systems ‘+ A realtime system is a computer system that requires not only that the computing results, be correct but also they are produced within specified deadline * A realtime system is used when rigid time requirements have been placed on the operation of a processor or the flow of data; thus, it is often used as a control device in a dedicated application. ‘+ Sensors bring data to the computer. The computer must analyze the data and possibly | ‘adjust controls to modify the sensor inputs. ‘Systems that control scientific experiments, medical imaging systems, industrial control stems, and certain display systems are real time systems. Some automobile-engine fuel-injection systems, home-appliance controllers, and weapon systems are also real- time systems. + A real-time system has well-defined, fixed time constraints, Processing. must be done within the defined constraints, or the system will fail. For instance, it would not do for a robot arm to be instructed to halt after it had smashed into the car it was building, * Types Itis of 2 types > Hard real time systems: Has the most strict requirements, guaranteeing that critical real time tasks be completed within their deadlines. Safety critical systems are typically hard real time systems > Soft real time systems: Less restrictive simple provides a critical real time task will receive priority over other task and that it will retain that priority until it completes. Operating System services ‘An operating system provides an environment for the execution of programs. It provides certain services to programs and to the users of those programs. These operating 6 to make the programming task easier ‘Operating System Services Those Are Helpful to the User 1. User interface. “{imost all operating systems have a user interface (UI). This interface can take uses text commands and a method specific format with several forn One is a command-line interface (CLI), whi pping in commands in as for entering them (say, a keyboard for ty specific options). commands and directives to control those Another is @ bateh interface, in which and those files are executed. ce (GUI) is used, Here, the interface is a ‘and make ‘commands are entered into files, Most commonly, 2 graphical user interfa window system with a pointing device to direct 1/0, choose from menus, selections and a keyboard {0 enter text. stem services are provided for the convenience of the Programmer: | ‘Some systems provide two or all three of these variations. 2. Program execution. “The system must be able to load a program into memory and to run that program The program must be able to end its execution, either normally or abnormally * Gndeatng enor | 3. 1/0 operations. © Arrunning program may require I/O, which may involve a file or an / device. For specific devices, special functions may be desired (such as recording to a CD or DVD drive or blanking a display screen). + Forefficiency and protection, users usually cannot control I/O devices directly ‘Therefore, the operating system must provide a means to do 1/0. 4. File-system manipulation | ‘* Programs need to read and write files and dit | © Many operating systems provide a variety of file systems, sometimes to allow 1] & personal choice and sometimes to provide specific features or performance ctories, characteristics. | 5. Communications. ‘There are many circumstances in which one process needs to ¢ with another process. Such communication may occur between processes that are executing on the same computer or different computer systems using Shared memory or Message passing ange information techniques. 6. Error detection. ‘+ The operating system needs to be detecting and correcting errors constantly. © Errors may occur in CPU and memory hardware (such as a memory error or a power failure), + VO devices (such as a parity error on disk, a connection failure on a network, or lack of paper in the printer), | User program (such as an arithmetic overflow, an attempt to access an illegal ‘memory location, or a too-great use of CPU time). * For each type of error, the operating system should take the appropriate action to ‘ensure correct and consistent computing. Operating System for Efficient Operation of the System Itself 1. Resource allocation, * When there are multiple users or multiple jobs running at the same time, resources ‘must be allocated to each of them, + The operating system manages many different types of resources such as CPU cycles, main memory, and file storage. 2. Accounting, + We want to keep track of which users use how much and what kinds of computer resources. This record keeping may be used for accounting (so that users can be billed) or simply for accumulating usage statistics. * Usage statistics may be a valuable tool for researchers who wish to reconfigure the system to improve computing services. 3. Protection and security. * The owners of information stored in a multiuser or networked computer system may want to control use of that information. ‘+ Protection involves ensuring that all access to system resources is controlled. © Security starts with requiring each user to authenticate himself or herself to the system, usually by means of a password, to gain access to system resources. It extends to defending external /O devices. System Calls Definition: System calls provide an interface to the services made available by an operating. system, These calls are generally available as routines written in C and C++, although certain low-level tasks (for example, tasks where hardware must be accessed directly) may have to be written using assembly-language instructions. Example To Illustrate How System Calls Are Used: Writing A Simple Program To Read Data From One File And Copy Them To Another File. * The first input that the program will need isthe names of the two files: the input file and the output file, * These names can be specified in many ways, depending on the operating-system design. One approach is for the program to ask the user for the names. * In an interactive system, this approach will require a sequence of system calls, first to write @ prompting message on the screen and then to read from the keyboard the 3129 characters that define the two files. On mouse-based and icon-based systems, a menu of file names is usually displayed in a window. The user can then use the mouse to select the source name, and a window can be opened for the destination name to be specified. This sequence requires many 1/0 system calls. Once the two file names have been obtained, the program must open the input file and create the output file. Each of these operations requires another system call. Possible error conditions for each operation can require additional system calls. When the program tries to open the input file, for example, it may find that there is no file of that name or thatthe file is protected against access. In these cases, the program should print a message on the console (another sequence of system calls) and then terminate abnormally (another system call) Ifthe input file exists, then we must create a new output file, We may find that there is ‘already an output file with the same name. This situation may cause the program to abort (a system call), or we may delete the existing file (another system call) and create a new ‘one (yet another system call). Another option, in an interactive system, is to ask the user (via a sequence of system calls, to output the prompting message and to read the response from the terminal) whether to replace the existing file or to abort the program. ‘When both files are set up, we enter a loop that reads from the input file (a system call) and writes to the output file (another system call). Each read and write must return status information regarding various possible error conditions. ‘On input, the program may find that the end of the file has been reached or that there was «hardware failure in the read (such as a parity error). The write operation may encounter various errors; depending on the output device (for ‘example, no more disk space). Finally, ater the entire file is copied, the program may close both files (another system call), write a message to the console or window (more system calls), and finally terminate normally (the final system call). — — source file destination file | Example System Call Sequence Acquire input file name ‘Write prompt to screen Accept input Acquire output file name Write prompt to screen Accept input Open the input tile if file doesn't exist, abort Create output file if file exists, abort Loop’ Read from input file Write to output file Until read fails Close output file Write completion message to screen Terminate normally Application Programming Interface (APD) ‘The API specifies a set of functions that are available to an application programmers including the parameters that are passed to each finetion and the return values the programmer can expect «Three of the most common APIs available to application programmers are the Windows [API for Windows systems, the POSIX API for POSIX-based systems (whiel include virtually all versions of UNIX, Linux, and Mac OSX), and the Java API for programs that run on the Java virtual machine, ‘The functions that make up an APL typically invoke the actual system calls on behalf of the application programmer. System call Interface «For most programming languages, the run-time support system (a sct of functions built into libraries included with a compiler) provides a system call interface that serves as the link to system calls made available by the operating system. ‘©The system-call interface intercepts function calls in the API and invokes the necessary system calls within the operating system. Typically, a number is associated with each system call, and the system-call interface maintains a table indexed according to these numbers. + The system call interface then invokes the intended system call in the operating-system keel and returns the status of the system call and any return values. ‘©The caller need know nothing about how the system call is implemented or what it does during execution. Rather, the caller need only obey the API and understand what the operating system will do as a result of the execution of that system call. ‘© Thus, most of the details of the operating-system interface are hidden from the programmer by the API and are managed by the run-time support library er arionton > user mode 4 mode | Li}: open () Implementation > ofopen() system call return Types of System Calls System calls can be grouped roughly into six major categories: Process control 10 ae a. end, abort ¢ A running program needs to be able to halt its execution either normally (end ()) or abnormally (abort ()) + When a running program tern ‘examined by- a system program designed to aid the programmer in finding and correcting errors, oF bugs—to determine the cause of the problem In Command line interfaces, it is it is assumed that the user will issue an appropriate command to respond to any error. © Ina GUI system, a pop-up window might alert the user to the error and ask for tes abnormally, a dump is written to the disk and guidance. # Ina batch system, the command interpreter usually terminates the entire job and continues with the next job. Some systems use Control cards which determine severity of errors and determine which action to be taken. b. load, execute ‘© A process or job executing one program may want to load () and execute () r another program, : ‘+ This feature allows the command interpreter to execute a program as directed by, for example, a user command, the click of a mouse, or a batch command ©. create process, terminate process ‘© An interesting question is where to return control when the loaded program terminates. This question is related to whether the existing program is lost, saved or allowed to continue execution concurrently with the new program. © Ifcontrol returns to the existing program when the new program terminates, we must save the memory image of the existing program; thus, we have effectively created a mechanism for one program to call another program. ‘+ If both programs continue concurrently, we have created a new job or process to be multiprogrammed. The system call for this purpose is create process or submit job. ‘© We may also want to terminate a job or process that we created (terminate process) if we find that it is incorrect or is no longer needed. d. get process attributes, set process attributes ‘+ If we create a new job or process, or pethaps even a set of jobs or processes, we should be able to control its execution. * This control requires the ability to determine and reset the attributes of a job or process, including the jot’s priority, its maximum allowable execution time, and so on using get process attributes() and set process attributes(). | €. wait for time | £ wait event, signal event | © Having created new jobs or processes, we may need to wait for them to finish | their execution. We may want to wait for a certain amount of time to Pass (wait time ()). More probably, we will want to wait for a specific event to occur (wait event ()) © The jobs or processes should then signal when that event has occurred (signal event ()) i 4 g. allocate and free memory 2. File locate memory for programs and releases it after completion. Most OS ‘management a. create file, delete file b. open, close ¢. read, write, reposition 4. get file attributes, set file attributes We first need to be able to create () and delete () files. Fither system call requires the name of the file and perhaps some of the file's attributes, Once the file is created, we need to open () it and to use it We may also read (), write (), or reposition () (rewind or skip to the end of the file, for example). Finally, we need to close () the file, indicating that we are no longer using it For either files or directories, we need to be able to determine the values of various attributes and perhaps to reset them if necessary. File attributes include the file name, file type, protection codes, accounting information, and so on. At least two system calls, get file attributes () and set file attributes (), are required for this function, Some operating systems provide many more calls, such as calls for file move () and copy(), . Device management a, request device, release device b. read, write, reposition ¢. get device attributes, set device attributes 4d. logically attach or detach devices * The various resources controlled by the operating system can be thought of as devices. Some of these devices are physical devices (for example, disk drives), ‘+ Assystem with multiple users may require us to first request () a device, to ensure while others can be thought of as abstract or virtual devices (for example, files). exclusive use of it. After we are finished with the device, we release () it. ‘These functions are similor to the open () and close () system calls for files. * Once the device has been requested (and allocated to us), we can read(), write(), and (possibly) reposition() the device, * Many OS including UNIX merge file and devices structures into one and use Inform: a. get b. get get same set of system calls ation maintenance time or date, set time or date system data, set system data Process, file, or device attributes d. set process, file, or device attributes * Many system calls exist simply for the purpose of transferring information 12 between the user program and the operating system. \ ‘© For example, most systems have a ste cal to return te current time Q and date Q). Other system calls may return information about the syst as the number of current users, the version number of the operating system, the amount of free memory or disk space, and so on. In addition, the operating system keeps information about his information, Generally, calls are J set process attr s processes, and Iso used to ite system calls are used to ace reset the process information (get process attributes () a 0). 5. Communications a, create, delete communication connection b, send, receive messages ¢. transfer status information 4. attach or detach remote devices, There are two common models of inter process communication: a) The message passing model b) The shared-memory model. a) The Message Passing Model ‘© In the message-passing model, the communicating processes exchange messages With one another to transfer information. Messages can be exchanged between the processes either directly or indirectly through a common mailbox. Before communication can take place, a connection must be opened, The name of the other communicator must be known. is commonly known. A host + Each computer in a network has a host name by w' also has a network identifier, such as an IP address. Similarly, each process has a process name, and this name is translated into an identifier by which the operating system can refer to the process. The get hostid () and get processid () system calls do this translation. The identifiers are then passed to the general purpose open () and close () calls provided by the file system or to specific open connection () and close connection () system calls, depending on the system's model of communication, * The recipient process usually must give its permission for communication to take place with an accept connection () call. Most processes that will be receiving connections are special-purpose daemons, which are system programs provided for that purpose. * They execute a wait for connection () call and are awakened when a connection is made. * The source of the communication, known as the client, and the receiving daemon, known as a server, then exchange messages by using read message() and write ‘message() system calls. The close connection () call terminates the communication. b) Shared-Memory Model + In the shared-memory model, processes use shared memory create () and shared 3 memory attach() system calls to create and gain access to regions of memory owned by other processes. Nonmally, the operating sy: stem tries to prevent one process from accessing another Drocess’s memory. Shared memory requires that two or more processes agree to remove this restriction. They can then exchange information by reading and writing data in the shared areas. * The form of the data is determined by the processes and is not under the operating system's control. The processes are also responsible for ensul writing to the same location simultaneously wg that they are not Comparison of both the models * Message passing is useful for exchanging smaller amounts of data, because no conflicts need be avoided. It is also easier to implement than is shared memory for inter computer communication, Shared memory allows maximum speed and convenience of communication, since it can be done at memory transfer speeds when it takes place within a computer. Problems exist, however, in the areas of protection and synchronization between the processes sharing memory. 6. Protection set permission, get permis b. allow user, deny user System calls providing protection include set permission () and get permission (), which manipulate the permission settings of resources such as files and disks. The allow user () and deny user () system calls specify whether particular users can—or cannot—be allowed access to certain resources, z 2958 aM (Operating System - Services Operating System - Services An Operating System provides services to both the users and to the programs. It provides programs an environment to execute. + Itprovides users the services to execute the programs in a convenient manner. Following are a few common services provided by an operating system - + Program execution + lO operations + File System manipulation @ communication + — Error Detection + Resource Allocation + Protection Program execution Operating systems handle many kinds of activities from user programs to system programs like printer spooler, name servers, fle server, etc. Each of these acti ies is encapsulated as a process. A process includes the complete execution context (code to execute, data to manipulate, registers, OS resources in use). Following are the major activities of an operating system with respect to program management - ("£024 a program into memory + Executes the program, Handles program’s execution. Provides a mechanism for process synchronization. Provides a mechanism for process communication. Provides a mechanism for deadlock handling. VO Operation ‘An lO subsystem comprises of /O devices and their corresponding driver software. Drivers hide the peculiarities of specific hardware devices from the users. ‘An Operating System manages the communication between user and device drivers. ntpsilwu toilet comoperatng_systemiossenices him 1 a Operating System - Services + {10 operation means read or write operation with any file or any specific VO device. . Operating system provides the access to the required I/O device when required. 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. Examples of storage media include magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its own properties like speed, capacity, data transfer rate and data access methods. A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions. Following are the major activities cof an operating system with respect to file management ~ + Program needs to read a file or write file, +The operating system gives the permission to the program for operation on fie. + Permission varies from read-only, read-write, denied and so on. i Operating System provides an interface to the user to create/delete files Operating System provides an interface to the user to create/delete directories: Operating System provides an interface to create the backup of file system. Communication In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, or a clock, the operating system manages communications between all the processes. Multiple processes communicate with one another through communication lines in the network. The OS handles routing and connection strategies, and the problems of contention and security. Following are the major activities of an operating system with respect to communication — e + 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 Error handling Errors can occur anytime and anywhere, An error may occur in CPU, in VO 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. ips su ulorlspit.conlperatng_systomls_ serves im BA AM ‘Oparating System - Services The OS takes an appropriate action to ensure correct and consistent computing. Resource Management 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 operating system with respect to resource management - * — 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 @ the Tesources defined by a computer system. Following are the major activities of an operating system 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. Useful Video Courses Operating System 86 Lectures 10 hours Arnab Chakraborty a ecatennint comloperating systenios_services. Nim ws ‘What are system cals in Operating System? What are system calls in Operating System? A figure representing the execution of the System call is given as follows - USER MODE Process Executing Execute System Call KERNEL MODE As can be seen from this diagram, the processes execute normally in the user mode until a system (@ill interrupts this, Then the system call is executed on a priority basis in the kernel mode. After the execution of the system call, the Control returns to the user mode and execution of user Processes, can be resumed, |n general, system calls are required in the following situations - * Ifa file system requires the creation or deletion of fi les. Reading and writing from a system call, Creation and management of new processes, . etc. requires a system call, Types of System Calls There are mainly five types of system calls. These are explained in detail as follows - Ps wera tutoralepoint com/wha-are-system-calt.n-operating-systom a What are system cals in Operating System? SS Control SE syst _ © System calls deal with processes such as process creation, process termination etc. File Management These system calls are responsible for file manipulation such as creating a file, reading a file, writing into a file ete. Device Management These system calls are responsible for device manipulation such as reading from device buffers, writing into device buffers etc. Information Maintenance ‘These system calls handle information and its transfer between the operating system and the user Program. sommunication e These system calls are useful for interprocess communication. They also deal with creating and deleting a communication connection. Some of the examples of all the above types of system calls in Windows and Unix are given as follows - ‘Types of System Calls Windows Linux K CreateProcess() oo Process Control ExitProcess() a0 WaitForSingleObject() CreateFile() open() ReadFile() read() & File Management WiteFile() wing CloseHandle() close() SetConsoleMode() ioc’) Device Management ReadConsole() read() WriteConsole() write() GetCurrentProcessID() getpid() Information Maintenance SetTimer() alarm() Sleep() sleep() CreatePipe() pipe() Communication CreateFileMapping() shmget() MapViewOfFile() mmap() hh tps aw tAoraepeint comwha-ae-ystem-calh-operaing system | 20 What ava syatom can Operating Syston? e are many diffe er y different system calls as shown above. Details of some of those system calls are as open() The open() system call is used to provide access to a file in a file s) resources to the file and provides a handle that the process uses to rel opened by multiple processes at the same time or be restricted to one process file organisation and file system. ystem. This system call allocates fer to the file, A file can be s, It all depends on the read() The read() system call is used fo access data from a fi read can be identified by its file descriptor and it shou! read. In general, the read() system calls takes three arguments ie. the stores read data and number of bytes to be read from the file. Je that is stored in the file system. The file 10 Id be opened using open) before it can be file descriptor, buffer which write() data from a user buffer into a device such as a fle This system from a program. In general, the write system calls takes three where data is stored and number of bytes to write The wrte() system calls writes the call is one of the ways to output data arguments ie. file descriptor, pointer to the buff from the buffer. close() The close() system call is used to terminate access 10 @ file system. Using this system call means 'd so the buffers are flushed, the file metadata is that the file is no longer required by the program ans updated and the file resources are de-allocated. M vr, Distibutod operating Systom Distributed operating System ‘An operating system (OS) is basically a collection of software that manages computer hardware resources and provides common services for computer programs. Operating system is @ crucial component of the system software in a computer system. Distributed Operating System is one of the important type of operating system. yy Distributed systems to serve multiple real-time apy g the processors. plications Multiple central processors are used b) and multiple users. Accordingly, Data processing jobs are distributed amon sation lines (like high-speed Processors communicate with each other through various communi pled systems or distributed systems buses or telephone lines). These are known as loosely cou Processors in this system may vary in size and function. They are referred as sites, nodes, computers, and so on. Qavantages ser at one site may be able to use the resources available With resource sharing facility, a u: at another. another via electronic mail. Speedup the exchange of data with one ers, the remaining sites can «Failure of one site ina distributed system doesn't affect the oth potentially continue operating. Better service to the customers. Reduction of the load on the host computer. Reduction of delays in data processing.

You might also like