Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
92 views
187 pages
MCA-FIRST YEAR-19MCAC204-Operating System
Operating system
Uploaded by
vivianchepngetich21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save MCA-FIRST YEAR-19MCAC204-Operating System For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
92 views
187 pages
MCA-FIRST YEAR-19MCAC204-Operating System
Operating system
Uploaded by
vivianchepngetich21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save MCA-FIRST YEAR-19MCAC204-Operating System For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save MCA-FIRST YEAR-19MCAC204-Operating System For Later
You are on page 1
/ 187
Search
Fullscreen
19MCAC204: OPERATING SYSTEM Unit I— Introduction of Operating System Tnroduction ‘Am operating system acts as an intermediary between the user of a computer and computer hardware. The purpose of aa cperaing system is to grovide an environment in whi auser can execute programs in acoavencent end efficient menner. ‘An cperaing system is a sofware thet manage: the computer hardware. The adware must provide appropriate mechanisms to ensure the correct operation of the computer system and te prevent user programs from inverlering with the proper operation cf the system Operating System —Definition ‘An opecating system is a program that controls the execation of application pregrams and an interlace between the user cf « computer and che computer hardware A. more common definition is that the operatng system is the on2 program running at ell :imes on the computer (asually called the kernel), with al! else being application programs ‘Am opecating system is conceraed with the allocation of resources and services, such as memory, processors, devices, and informatica. The operating system correspondingly inciudes programs to manage these rescurces, such at a traific cortroller, a schedules, memory menagement module, UO programs, and a file system Functions of Operating system —Operating system perZorms three functions: Convenience: An OS makes a computer more convenien: to use Efficiency: An OS allows the computer system resources to be used in ax eificieat manner Ability to Evolve: An OS should be constmeied in such a way as to permit the effectve development, testing and intredvction of new system fx interfering with service. ons at the same time wi out Operatiag system as User Interface — User System and application programs Operating system HardwareEvery general-puspose compucer consists of the hardware, operating system, system progcams, and applicaton programs. The hardware consists of memory, CEU, ALT, and VO devices peripheral device, and storage cevice. System program consists of compilers, loaders, eciters, 8, ete The agpl:caticn program consists of business programs, databese programas a ee Compiler Assembler Database System SYSTEM AND APPLICATION PROGRAMS OPERATING SYSTEM COMPUTER HARDWARE Figl: Conceptual view of a computer system Every compater must have an operating sysem to run cther programs. Tae operating system coordinates the use of the Lardware among the vatioxs system programs and epflication programs for various users. It simply provides an environment within whick o:her programs can dousefal werk The operating systems is ¢ set of special programs that run on a computer system chat allows it te work property. It performs basic tasks such as recegnizing input from the keyboard, keeping track of les and directeries on the disk, sending output to the display screen and controlling peripheral devices OSis designed to serve two basic purposes It coatrols the allocation and use of the computing System’ s resources ameng the varicus user and tasks Ji provides an interface between the computer aardware and the programmer that simplifies and makes feasitle for coding, creation, debugging of application programsThe Operating system must support the following tasks. The task ere Prow:des the facilities t oreatz, meditication of programs and daa files asing an editor Access to the compiler for translaing the user program from high level language to m: language Provide a leader program to move the compiled program ecde to the computer's memory for execution, Provide routines thet handle the derails of UC programming 0 System Management - The module that keeps track: of the status of devices is called the 1/O traffic controller. Each YO device nas a device aandler that cesides in a separate process associated with that device. The YO subsystem consists of A. memory Management componen: thatincludes tuffering caching and spooling, A general device driver intecfaze Diivers fer specific nardware devices Assembler - The input to an assembler is an assembly language program. The output is an object program plus information that enables tae loader to prepare the odject program for execution, At one time, the computer programmer had at his disposal a tas.c machine that incerpreted, shrough hardware, certan fundamental instructions. Ee would program this computer by writing ¢ series of ones and Zeros (Machine language), place them in:o the memory of the machiae Compiler - The High-level languages- examples are FORTRAN, COBOL, ALGOL end PLT are processed by compilers andin‘erpreters. A compiler is @ program ‘het accep's a source program in a“aigh- level language “and produces a ccerespondiag object program. An interpreter is a program that appears to execute a scurce program az if it was machine language. The sem2 name (FORTRAN, COBOL, etc.) is often used to designace doch a compiler and its assoriared language Leader - A Loacer is a routine that Leads an object program and prepares it for execution. There are various loading schemes: absolute, zelocating and directinking In general, the loader mustload, relocate and link the object program. The loader isa program that places programs into memory and prepares them for execution, In a simple loading scheme, the assembler ontpats the machine language ‘raaslation of a programa on a secondary device and 2 leacer places it in the core Theloader places into memory the machine language version cf she user's program and transfers coatrol toit, Since the loader program is much smeller thaa the asserabier, those make more core available to tae user's program History of Operating system - Operating system has been evelving through the years. Following Tzble shows the history of OS First 1945-55 Vaccum Tubes Plug Boards Second 19554 Transistors Batch Systems Thire 1965-80 Invegraied Circuits) Maltiprogramming Fourth Since 1880 Larg2 Scale Integration PC Types of Operating System — Batch Operating System- Sequence of jobs in a program on a computer withoat manual interventions Time shaing operating System- allows many users to share the computer recovrees.(Max utilization of the resources). Distributed operating System-Manages a group of different computers and make appear to be a single compuier Network operating system- compurers mnning in different opercting system can patticipate in comrioa network (Itis ased Zor security purpose) Real time operating system —meant applications to fix tae deadines Examples of Oper ating System are - ‘Windows (GUL based, FC) GNU/Linux (Personal, Workstat ons, ISP, File and print server, Threestier client'Server) macOS (Macintosh), used for Apple's personal computers and work stations (MacB ook, iMezc). Android (Gcogle’s Operating System Zor sma atphones/tablets/smactwatshes) iOS (Apple’ s OS for iEhcne, iPad and iPod Touch)Op 2 System Structure ‘Am opecating system is a cens:ruct that allows the user application programs to iateract with the system hardwere Since the cperaing system is such a complex structure, st should be created with utmest cave soit can be ased and medified easly An easy way to de this is to create the operating system in parts. Each of these parts saould be well defined with clear inpu's, ovtpats and foncticns Simple Structure There are many operating systems that have a rather simple stricture, These started as small systems and rapidly expanded maca further than their scope. A common example cf tais is MS- DOS. It was designed simply for a niche amouat for people. There was no indication that it would tecome so popular An image to illustrate the structure of MS-DOS :s as Zoll ows APPLICATION PROGRAM MS-DOS DEVICE DRIVERS ROM BIOs OF Ibs better that operating systems have a modalar structire, unlike MS-DOS, Thet would lead te greater control over the computer system ard its various epplications. The modular structure would also allow the programmers to hide information a: required and implement internal routines as they see fit withcut changing the outer specifications Layered Structure One way to achieve modularty in the operating system is the layered approach Ia this, the bettem layer is the hardware and the topmest layeris the user intedface ‘An image demonstrating the layered approach is as Zoll owsi Operations | Existina Operations Layered Structure of Operating System ‘As seen from the image, each upper layer is built on the bottom layer. All she layers hide some stmucrures, operations etc rem their ugpes layers Operating System Operations ‘Am opecating system is a cens:ruct that allows the user application programs to iateract with the system hardware. Cperating sysiem by itself does not provide aay function but it provides an atmosphere in which differeat applications and programs can do useful work. The mejor operations of the cperaiing system are process managemeat, memory management, device management and file management. These are giver in detail as follows manigerent re Speen ery onajamont |*—|_ S288 —*| arageneProcess Management The operating system is responsible for managing the processes i.e assigning the processor to a process at a time. This is known as process scheduling. The different algorithms used for process scheduling are FCFS (frst come first served), STF (shertest job firs), pronity scheduling, round robin scheduling ete There are many scheduling queves that are used to handle processes in process management. When the processes enter the system, they are pvt into che job quene. The processes that are seady to execute in the main memory are kept in the eady quexe. The processes that are waiting for the V/O device are keptin the device quexe ‘Memory Management ‘Memory managemeat slays ar important part in operating system. T: deals with memory and the moving of processes from disk to primary memory for executicn and back agein. The activisies performed by the operating system for memory management are # The operating system assigns memory to the prozesses 2s required This can be dene using bestfit, Es: fiz and worst ft dgorithias + All the memory is tracked by the operating system i.e. it nodes what use by the processes and which are empty © The operating system deall oceted mem cry from processes as required, This may heppen ory paris arein wher. aprocess hes been terminated orif it no longer needs the memory Device Managem ent There are many IO devizes handled by the operating system such as mouse, keytoard, disk drive ets, There are differen: device drivers that 2an be connected to the operating system to handle a specific device. The device contreller is en interface between the dev.ce and the device driver. The user applications car. ancess ali tae I/O devices using the device drivers, which are derice specific codes File Management Files are vsed to provide a uniform view of date storage by the operatiag system, All the files are mapped onto physical devices that are usually non volatile so data is safe in the case of system failure The files can be ascessed by the system in two ways ie, sequential access and direct access+ Sequential Access ds are azcessed or. after another. Most of the file systems such as editors, compilers ete. use sequential access The information in a file is processed in order using sequential access, Tae files r + Direct Access In direct access or relative access, the files can be accessed in random for reac and write operations. The direct access model is baszd on the disk model of « file, since i: allows random accesses Protection and Security in Operating System Protection and secusity requires that computer resources such as CPU, softwares, memory etc are protec:ed. This extends :o she operating system as well as the data in the system. This can be done by ensuring integrity, confidentiality and availability in the operating system The system mustbe protect against unauthorized access, viruses, worms ete Threats to Protection and Security A theeat is a program that is mal Scme of tae common threats tha: us in nature and leads to harmful effects for the system cur in a system are: Virus Viruses are generally small snippets of code embedéedin asystem They are very dangerous and can corrupt files, destroy date, orash systems etc, They 2an also spread further by ceplicating themselves as reqnired Trojan Horse ‘A trojan korse can secretly access the login details of a system, Then a malicioas user can use these to enter the system as a aanmiess being and wreak: havoc Trap Door ‘A trep door is a security breach that may be present in a system without the knowledge cf the users, It can be exploitedto aa the data or files ix a system by malicious people Worm A. worm can destroy a system by using its resources to extreme levels copies which claim all the rescurzes and den't allow any other pr can sau: down a whele network ia this way. an generate multiple them. A worm ses to accesDenial of Service These type of attacks do not allow the legitimate users to access a system. It overwhelms the system with requests so itis overwhelmed and cannot work properly for other user. Protection and Security Methods The different methods that may previde protect and security for different compucer systems are Authentication This deals with identifying each user in the system and mak:ng sare they are who ‘hey clam te be, The operating system makes sure that all the asers are authenticated before they access the system. The different ways to mae sure that the users are authentic are © Username! Password Eech user has a distinct useraame and password combination and they need :o enter it correctly before they can access tae system © User Key/ User Card The users need te punch a card into ‘he caré slot or use they individual key on a keypad to access the system. © User Attribute Identification Different user attribute ideatidications that can be used are fingerpriat, eye reiina etc These are unique for ezch user end are compared with the existing samples in the davabase, The user can only access the system if there is a match One Time Password These passwords provide a lot of security for avthentication purposes. A one time password can be generated exclusively fer a login every time a user wants to enter the system. It cannot be used ore thar oace. The various ways a one time paseword can be implemented are + Random Numbers The system car ask for numbers that correspond to alphabets that are pre aaaged. Tais combination can be changed eaca time legin is required. + Secret Key A hardware device 2an create a secre: key related to the user id for legin. This key can change each timeKernel Data Structures The kemel data structares are very imporiant as they stere data about the current scate cf the system, For example, if a new process is created n the system, a kernel data structure is created that contains the details atovt the process ‘Most of the kemel data structures are only accessitle by the kerne! andits subsystems. They may coatain deta as well as pointers to other data straczures Kernel Components The xemel stores and organizes a lot of information. $0 it has data about which processes are running in the system, fei memory requiremen‘s, files ir use etc. Te handle all this, three impcrtant structures are used, These are process table, file table and v node! i node inormation ( KERNELDATA sTrucTuRES / PROCESS FILE V-NODE AND TABLE TABLE NODE TABLES. Details about these ae as follows Process Table The process table stores information about all the processes ranaing in che system, These include the storage infcrmation, execwioa status, file informaatioa ete Waea a process forks a child, its entry in the process table is duplicated including the file information and fle peinters. So the parent and the ckild process share a file File Table The ‘ile table contains entries about all the files in the system. IF two or more procesces use the same file, then they contain the same file information and the file descriptor aumter.Each file table entry contains information abou che file such as file scatas (file cead or file write) file cffset etc. The file offse: specifies the position for next read or write into the fle The file table also contains v-node and i-node pointers which point to the virtual node and index node respect vely ‘These nedes contain information on how :0 read afile ‘V-Node and I-Node Tables Bath the v-node and i-node are references ‘o the storage system of the file and the storage meckanistas, Taey conaest the hardware to the software The 7-node :s an abstrac: conzept thet defines she method t> access file deta without worrying abou: the actual structure cf the system. The i-node specifies file aczess :nformation like file storage device, read/write procedures ete Computing Environments A.computer system ases meny devices, arranged ir. different ways te solve maay problems. Tais coastitutes a computing environment where many compu‘ers are used to proces: and exchange information to handle multiple issues. The different types of Computing Environments are Computing (es ) {Cluster Time Sharing \ ( -cottwatny ) Computing. ) Environment Let us begin with Personal Computing EnvironmentPersonal Computing Environment In the personal computing eaviroamert, there isa single compucer system All she system processes are avalable on the computer and executed thers, The different devices that constitute a personal computing environment are laptops, mcbiles, printers, computer systems, scanners ete Time Sharing Computing Environment The time siraultaneously Each user is provided a time slize and the processor switches rapidly among the users according to i. Besause of this, each user believes that they are the only ones using the system. ating computing environment allows multiple users to share the system Client Server Computing Environment Jn client server computing, she cliert requests a sesource andthe server provides that resource. A server may serve multiple clients at che same time while a clieat is in contact with only ene server. Beth the client and server usually communicate via a corapater network but somerimes they may reside in the same system Distributed Computing Environment A distrbvted computing eav:ronment contains multiple nodes that are physically separate but linked together using the network. All the nedes ia this system commanicete with each other and hance processes in tandem. Each of these ncdes contains a small part of che distributed operating system software Cloud Computing Environment The computing is moved awey frcm individual computer systems to a cloud cf computers in cloud computing environment The cloud users only see the service being provided and not the intemal details of how the service is provided. Tais is dene by pocling all the computer resources and taen managing them using a softwere Cluster Computing Environment The clustered computing environment is similar to parallel computing environment as they both have multiple CPUs. However a major difference is that clustered systems are created by two or more indiviéual computer systems merged together which then work: parallel to each other. Open Source Operating Systems Oper. Source operatng systems are released under a license where the copyright holder allows others to study, chenge as well as distribute the software t> other people This can be cone for any reason, The different oper. source operating system availatle in the market are:Cosmos This is an opea source cperaiing system written mnestly in programming language C#. Its full form is C# Open Scurse Managed Operating System. Till 2915, Cosmos did ao: intend to b: fully fledged cperating system bu: a system that allowed other developess to easily build their own operating systems, E aise hid the inner workings of the hardware from the developers thus providing data abstraction FreeDOS This was a Sree operating systema developed fer systems compatible wich IBM PC compaters FreeDOS provides a complete exvirormen: te run legacy software and otier enbedded systems It can bocted from a floppy disk or USB flash drive as required, FreeDes is licensed under the GNU General Public keense and contains Sree and opea source software So there is no license fees seqniced for sts distribution and changes to the system are permitted Genode Genede is free as well az open scurce I contains 2 microkernel layer and different user components. It is cne of the few open source cperaling systems not derived from a licenced operating system suck as Unix. Genode can be used as an operating system for computers table's etc, as required I: is also used as 2 base for virtualisation, interprocess coramurication, software development etc. as it has a small code system, Ghost OS This is a Zee, open scurze operating system developed for personal computers research projec: and developed to contain various advanced features like graphical user interface, Clibrary ete. The Ghost operating system features multiprocessing and multizacking and is based on the Ghost Kernel. Most of the programming in Ghos: OS :s doae in C++ ITs ft staned as a The incompatible time-sharing system was developed by the MIT Actificial Intelligence Library Jb:s priacipally atime sharing system. Taere :s a remote logia facility whick allowed guest users to inZormally try out the operating system and its Features using AXPAnet ITS also gave out many new featares chet were unique at chet tme such as device independent graphics terminal, virtual devices, inter machine file system access ete Osv This was an operating system released in 2013. It was mainly focased on cloud computing and was duit to run on top of a virtual machine es a guest. This is the reason it doesn't include drivers for tare hardware, in the OSy operaiing systema, everything rans ia the kemel address space and there is no concept of a multi-user systemPhantom OS This is an operating system that is based on the concepts cn persistent victual memory and is code oriented. It was mostiy developed by Russian developers. Phantom OS is not based on concepts of famous operating systems such as Unix. its main goal is simplicity and effectiveness in process manegem ent. Operating System Services An Cperating System provides services to both the users and to the programs © Ib provides programs aa envircnment to execute + Ib provides users she services to execute the programs in a converient menner Following are afew somm ox services provided by an operating system— © Program execution © UO operations + File System menipulation © Communication + Excor Detection + Resource Allocation # Protection Program execution Operatiag systems handle many kinds of activities from user programs to system programs like prnter spooler, name servers, file server, etz. Each of these activities is encapsulated as a process A proce includes the complete execution context (code to execute, deta to maripalete, registers, OS resources in use) Following are the major activities of ar operating system with respect ‘o program management — + Leads ¢ program ints memory + Executes the program Handles program's execation * Provides 2 mechanism for provess synchronization © Provides a mechanism for pr <8 coramunication Provides a mechanism for deadlock handling,VO Operation An LO subsystem comprises of UO cevices and their coresponding criver seftware, Drivers hide che peculicrities of specific hardware devices from the asers An Cperating System manages the communication between user and device davers © WO cperation means read or write operation with any file or any specific VC device + Operating system provides the access ‘she required JJG device waen required. File system manipulation A file represents a collection of relaied infcrmation, Computers can store files oa the disk (secendary storage), for long-term storage purpos?. Examples of storage media include magnetic tape, megnetic disk and optical dick drives like CD, DVD. Each of these media has its own groperties like speed, cepacity, data transfer ate and data access methods A file system is ncrmally organized into directories for easy navigation and usage. These diseccories may contain ‘les and other directicns Following are the major activities of an operating system with respect to file management- # Programa needs to reada ‘ile or wrive a file + The opera‘ing system gives the permission o the program for operation on file # Permission varies from reaé-oaly, read-write, denied and so on. + Operating System provides an interface to tie user to create/celete files + Operating System provides an interface :o the user te createldetete directories + Operating System provides an interface to create the backup cf file system Communication In case of distrbuted sysiems whica are a collection of processors taat do not share memocy, peripheral devices, or a clock, the operating system manages communications beeen all the processes. Muliple processes communicate with one anotaer through commurication lines in the network. The OS handles routing and conneciioa strategies, and the problems of conteation and security Fellowing are the majo: fivites of ar. operating system with respect to communication - + Two processes often require deta to be transfesred tetween them + Both the processes can be on one computer or on difveren: 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 car occur anytime and anywhere, Aa error may oceur in CPU, in YO devices or in the memory kardware, Following are the majer acti error handling— sof an operating system with respect to © The OS constantly checks for possible errers + The OS takes aa epprooriate action to ensure correct and consistent computing Resource Management In cese of multi-user or multi-tasking environmeat, resources such 2s mein memory, CPU cycles ané files storage are to be alloceted to each user or jeb. Fellewing are the major activites of an operating system with respect to resource management — © The OS manages all kiads of rescurces using schedulers + CPU scheduling algorithms are used for better utilization of CFU. Protection Considering a comguter system having maltple users and concurrent execution of multiple processes, the various processes must te protected from each cther's activities Protection refers to @ mechanism or a way to control the access of programs, processes, or users to the resources defined by a compater system. Following are the major activicies of an opsrating system with respect to protection— © The OS exsures that al! access to system resources is controlled The OS exsures that extemal I'O devices are protected from invalid access attempts + The OS provides authent.caticn features for eaca user ty means of passwords. Operating System and User Interface ‘As already mentioned, in addition to the herdwere, a computer also needs a set of program:—an operating system—to contral the devices. This page will discuss the following There are different kinds of operating systems such as Windows, Linux and Mac OSThere are also different versions of these operating systems, e.g. Windows 7, € aad 10 Operating systems can be used with different user interfaces (UI) text user interfaces (TUL) ard graphical user interfaces (GUD) as exaraples Graphical user interfaces havemany similarities in different operating systems such as the start menu, desktop etc ‘Waea you can recognize the typical parts of each operating system's user interface, you will mostiy be able to use bota Windows and Linux as well as 2.g. Mac OS. THE ROLE OF OPERATING SYSTEMIN THE COMPUTER ‘An opecating system (OS) is ase: of programs which ensures the interoperatility of the haréware and software in. your computer. The cperaling sysiem enables, among otaer things ‘The identification and activation of devices connected to the computer, The installation and ase of programs, and The handling of files ‘Waa: happens when you ‘umn on your computer or smarrphone? ~The computer checks the Fuactionality of its components ané any devices ccnnected to it, and starts tolcok fer tae OS on ahard ceive or other mem ory media. ~F the O3 is found, the computer starts to load iate the RAM (Random Access Memory). When the OS has loaded, the compu:er waits for commands from you DIFFERENT OPERATING SYSTEMS Over the years, several different operatiag systems have been developed fer different purposes The mest typical operating systems is. ordinary computers are Windows, Linvx and Mas OS WINDOWS The ame of the Windows OS comes fom the fect that programs are run in “windows”: each program has its own window, and you can have several programs open at the same time ‘Windows is the most popular OS for home computers, and chere are several versicns of it The newest vession is Windows 10LINUX AND UNIX Liauz is en open-source OS, which means that its program code is freely availeble to software developers. This is why shousands of programmers arcund the worldhave developed Linux, and it is consideced the most tested OS in the world, Linux kas beer. very much influenced by the commercial Unix OS In additioa to servers, Liauz is wicely used ia kome computers, since there are a great number of free programs for i: Gor text and image processing, spreadsheets, publishing, etv.). Over the years, maay different versions of Linax have become available for distbution, mos: of which are free for the user (such as Uban, Fedora and Mint, :o name 2 few). Sez the additicnal reading material for more information on Linax MAC OSX Apple's Mac computers have heir own operating system, CS X. Mos: of the progcams that are available for PCs are alse available for Macs rurniag uader OS X, but these two types of computers cannot use the exact same programs: for example, you cannot install tie Mac version of the Micreso% Ofice suite on a Windows computer. You cen install cther operating systems on Mac computers, but the OS Xis only available for computers made by Apple. Apple's lighter portable devices (iPads, iPhones) use alight version of she seme cperating system, callediOS ‘Mac computers are popula: because OS X is considered fast, easy t» learn and very stable and Apple's cevices are considered well-designeé—though rather expensive. See the additicnal reading material for more irfcrmation on OSX. ANDROID Android is an operating system designed fer phones and other mobile devices. Android is not available for desktop computers, but in mobile devices it is extremely popular: more than z half of all motile devices ia tae world mn on Android USER INTERFACES A-user interface (UD refers to the part of an opereting system, programa, or device that allows a user to enter and receive information. Atext-based user interface (sez the image to the Left) displays text, en its commands are usvally typed on a command line using a keyboard. With a graphical user interface(see the right-hand image), the fuactions are carried out by clicking ormoving buttons, izons and menus by means of a pointing device.Lacger image tex UL| grephical Ul The images contain the same information: a directory listing of a computer. You can often carry out the same tarks regardless cf which kind of UL you are using TEXT USERINIERFACE (TU) ‘Modern graphizal userinveriaces have evolved from texc-based Uls. Some operating systems can still be ased with a tex:-based user interface. In chis case, the commancs are entered as text (e.g. “cab story tet”) This demonstration will show you now co rename a file in a TUL the example will show both the (rename) andthe (directory listing) commands.Tae use of a TUI does not differ very much from a GUI (Graphical User Interface) coatrolled with e.g, a mouse (many TUIs mitror GUIs) To display the text-based Command Prompt in Windows, cpen theStartmenu and typeemd Press Enter on the ceyboard to launca the commend pomp: in a separate wiadow With the command prompt, you can type your commands from the keytoard instead of using the mouse GRAPHICAL USERINTERFACE Jn mos: cperating systems, the primary user interface is graphical, :.c. instead of -yping the command: you man.pulate rasioas graphical objects (such as icons) with a pointing device The underlying principle of differen: graphical user interfaces (GUIs) is largely the same, co by knowing how to ase a Windows UL, you will most likely know how to use Linux or some other GUL ‘Most GUIs have the following basic components a start menu with program groups a taskbar showing running programs a desktop vacicusicons and shortcutsSystem Calls Jn computing, asystem callis the programmatic way in which a computer program requests a service from the kemel of she operating system it :s executed on. ... It provides an interface between a process endoperating system to allow user-level processes to request the operating system, ervices of The interface between a process and an operating system is provided by system calls. In general, system calls are available as acsemtly language instructions They are also included ia the manuals used by ‘he assembly level progremmers. System cells are usvally made when a process in user mode requires access to a resource. Ther it requests the kemel to previde the resource via @ system call. Types of System Calls There are mainly five types of system calls. Taese are explained in detail as Zollows ; . jo I / ‘ i a nestgomen} \ ae, - nein > ( seamenance { management } Process Control These system calls deel with provesses such as process creat:on, process File Management These system calls are responsible fer file maripuletion such as creaiing a file, reacing « file writing into afile etcDevice Managem ent These sysiem calls are responsible for device manipulation such as reading Ercm device buffers, vwniting into device buffers ete Information Maintenance These syscem calls handle informacion end its transfer berween the operating system and the user program. Communication These system calls are useful fer interprocess communication. They also deal with creatng and deLetng acommvnication conaection Scme 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 rreateProcess() ork rocess Control ExitProcess() lexit( sitForSingl Object sit reateFile() lopend eadFile( eed() File Management ‘teFle0 ie oseHandle() closed etConscleMode() ctl) Device Management ReadConsoie() eed() riteConsole( ‘ted et CarrentPrecessDO etpi dC information Maintenance SetTimer() blarm() leep() bleep rreatePipe( ine ‘cmmunication ‘reateFileMapping() hmget() ep View OF ie mapCThere are many different system calls as shown above. Details of some of those system calls are as Follows: wait() Jn some systems, a process mey wait for another proces: to complete its exezutioa. This aappens wher parent process creates a child prozess and the execution of the parent orocess is suspendeé uatil the child process executes The suspending of the parent process occurs with 2 ‘wait() sysem call. When the child process completes execution, the con‘rol is returned back te the parent process exec() This system call runs an executable file in the concext of an already running process. It seplaces the previous execatable file, Tais isknown as ar. oveslay. The criginal process identifier remains since a new process is not created but data, aeap, stack etc. of the process are zeplaced by the new grocess fork() Processes use fhe fork() system call to create processes that are a copy of shemselves. This is cne of the maror methods of process creation in cperating sysiems. When a parent proces: create: child process and the executon of the paren: prozess is suspended until che child process executes, Whea the child process completes execation, the control is resumed back :o the parent process exit() The exit() system call is used by a program to ermina‘e its exezuiioa, In a mullithreaded environment, this means that the taread execution is complete, The cperating system reclaims recources chat were used by the process after the exit() system call kill The Zill() system call is ased dy the operating system to send a termination signal to a process that arges the process to exit However, Lill system call does not necessary mean xilling the process and can have various meanings System Programs There are mainly two categories of programs i.e. application programs and system programs. A diagram that demonstrates their place in the logical computer hierarchy is as ZollowsUser User User 7 2 : i I T Operating system l Computer Haraware Application Programs These programs pe:form a particular function directly for the users. Some cf the common apolication programs incluce Email, web browsers, gaming software, word processors, graohics software, media player etc All of these programs provide an agplication to the end users, so they are known es application programs, For example: a web browser is used to find information waile 2 gaming sofware is used :o play games The requests for service and application communication systems used in an application by @ programmer is known as an application program interface (AED) System Programs The system programs are used to program the cperating system software. While application programs provide software that :s used direccly by the user, system programs provide software that are used by other systems such as Saa applications, computeticnal science applications etc The attributes of system programming are Using system programming, aprogrammer cen make assumptions about the hardware of the system: that the program suns on. + A low level orogramming language is used in system. programming normally. This is so that the programas can cperate in low rescurze environments easily + Most system programs are created to have alow runtime overhead, These programs may have small runtime library+ Scme paris of the system programs may be directly written in assembly language ty the programmers # A dedngger cannct be used on system programs mestly. This problem can be sclved by running the programs ir. a siraulated environment. Scme example: cf system programs are operating system, networking system, wed site server, daca backup server etc Operating System desi¢n and Implementation ct that allows the user application programs to iateract with the n but it provides an ‘Am operating system is a const system hardware. Cperating sysiem by itself does not provide aay fun atmosphere in which differeat applications and programs can do useful work. There are many problems that caa occur wail ces:gring end implementing an operating system These are covered in operating system design and implementation Layered Operating System Design Operating System Design Goals Ibis quite complicated te define all the goals end specifications of the operating system while designing it,The design changes depeading oa the type of the opereting system i.e ifitis batch system, time shared system, siagle user cys-era, multi user system, distributed systema etc There are basically two types of goals waile des.gring en operating system, These are User Goals The operating system should be coavenient, easy 20 use, reliatle, safe and ast eccording to the users, Eowever, these specifications are aot very useful as there is no set methed to ackieve these goalsSystem Goals The operating system should be easy to design, implement and maintair.. These are specifications required by those who create, maintain and operate the cperating system. Bu: there is not specific method to achieve these goals as well Operating System Mechanisms and Policies There is no specisic way to design an operating system as itis a highly creative task. However, there are general software principles that are apolicadle to all cperaiing systems A subtie difference bebveen mechanism and policy is that mechenism shows how to de something and pdlicy shows what :o do Policies may change over time and this would lead to al mechanism tha: would require few changes ia mechanism. So, it is better to have ¢ gene changes even when a policy change occurs For example - If the mechanism and pclicy are indepencen:, then few changes are required in meckanism if policy changes. If a policy favours LO iniensive processes over CDU intensive processes, ther. a policy change to preference of CEU intersive processes will nct change the mechanism Operating System Implementation The operating system aeeds te be implemented after it is designed, Earlier they were wsitten in asserably language but now higher level langvages are ased. The first system not wiitten in asserably language was the Master Control Program (MCB) for Burroughs Computers Advantages of Higher Level Language There are multiple advantages to implementing an operating system using a higher level language such as: the code is written more fast, it is compact and also easier to detug and understand, Also, the operating system can be easily moved from one kardware to another i? itis written in ahigh leve! language Disadvantages of Higher Level Language Using high level language for implementing an operating system leads to a loss in speed and increase ia storage ceqniements However in modem systems oaly a small emouat of code is needed fer aigh performance, such as the CEU scheduler and memory manager. Alsc, the bettleneck routines in the system can be replaced by assembly language equivalents if required. Operating System-debugging Debvgging is the process of finding the problems in a computer system: and solving them. There are mary different ways in which operating systems perform debugging. Some of these are:Log Files The log files recerd all the events that occur in an operating system This is done by writing all the messages into a log file. There are different types of Log files. Scme cf these arz given as follows Event Logs These stores the records of all the eveats that occu: in the execution of a system. This is done se that the activities of all the eveats cen be undesstood to diagncse problems. Transaction Logs The ‘raasaction logs store the changes to the data so that the system can recovel and other errors, These legs are readable by ahuman m crashes ‘Mbssage Logs These logs store both the public and private messages between the users. Taey are mostly plain text files, busin some cases they may be HTML files Core Dump Files The core cump files contan the memory address spece cf a process thet cerminates unexpectedly. The creation of the core éump is triggered in respense to program crashes by the kemel, The core dump files ave used by the developers to find the program's state at the time of its termination so that they can find out why the terminat on red, The automate creation of the 2ore dumg files can be disabled ty 1 improve performance, lear disk space or increase security Crash Dump Files users, This may de dene te Jn the event of a total system failuce, the information about the state of the operating system is captured in crath dump files. There are thrze types of damp hat can be capured wien 2 system crashes, These are Complete Memory Dump The whole contents of the physical memory at the time of the system crash are captured in the complete memory damp. Thisis the default setting oa the Windows Server System Kernel Memory Dump Only the kernel moce read enc write pages that are present in the man mem ory al the time of the system crash are stored in the kernel memory cumpSmall Memory Dump This memory dump coatzins the list of device divers, stop code, process and threadii kemel sack ete Trace Listings The wrace listing record iaformat on about a program execution using loggiag. This information is used by programmers for debugging. System administrators and techrical personnel can use the trace listings to find tae commaon problems wita software using sofware monitoring tocls Profiling This is a type of program analysis chet meascres various parameters in a program such as space and time complexity, frequency and duration of fuactioa calls, usage of specific :nstrvctions ete Profiling is doae by moritoring the source coce of the required system program using a cede profiler Operating System-Generation Operating Systens are evolved over the years, Se, their evoluticn through the years can be mapped using generations of operating systems. There are four geaerations of operacing systems These can be described as Follows: ‘The First Generation (1245-1955 ) Vocuum Tubes ond Plug boards ‘The Secona Generation (1955-1968 ) ‘Transistors and Baich Systems The Third Generation (1966-1880 ) Integrated Circuits and Mutt Programming The Fourth Generation ( 1980-Current) Personal Computers (OPERATING SYSTEM GENERATIONSThe First Generation (1945 - 1955 }: Varuum Tubes and Plugboards Digital computers were ao: constracted uati! the second world wer, Caloulating engines with meckarical selays were built at that time, However, the mecaanical relays were very slow and were la‘er replaced with vacuum tubes. These macaines were enormous but were still very slow These cay computers were designed, tuilt and maintained by a single group of peorle Programming languages were unknown ard there were no operating systems co all the programming wes dene in mackine language. All the problems were simple numerical calculations By the 1950's punch cards were introduced and ‘his improved the computer system. Instead of using plugboards, programs were written cn cards and reed into the system The Serond Generation (1955 - 1965): Transistors and Batch Systems Transistors led to the development of the computer systems that could be manufactured and sold to paying customers. These machines were knows es main‘rames and were lecked in air- condtioned computer rooms with staff to cperaze them. The Baich System was introduced to reduce the wasted time in the computer. A ‘ray full of jobs was collected in the inout rom and read inte the magnetic tape. After that, the tape was rewound and mounted on a tape chive. Then the batch operating system was loadedin waich sead the first jo> from the tape and ran i The cutput was written on the secoad tape, After fhe wiole batch ‘was done, the iapat and cutpu: tepes were removed aad the cutput tape was printed The Third Generation (1955- 1980): Integrated Circuits and Multiprogramming ‘Uniil the 1960's, shere were two types of computer systems ie the scientific and she commercial computers. These were combined by IBM in the System/360. This used integrated circuits and provided a major rice and performance advantage over the second generaticn systems The third generator operating systems also introduced multipsogramming. This meant that the processor was nct idle while a job was completing its VO operation. Another job was scheduled on the processor so thet iss time would not be wasted The Fourth Generation (1980 - Present): Personal Computers Personal Computers were easy to create with the development of large-scale integrated circuts These were chips ccntaining taousands of wransistors on a square ceatimete: of silicon. Because of these, microcomputers were much cheaper than minicomputers and that made :t possible for 2 single indivi dual to own one of them The advent of personal computers also led to the growth of aetworks. This crested network operating systems aad distnbvted operaing systems, Tae users were aware of a network while using a network operating system and could log in to remote machines and cepy files from cne machine to anotherSystem Boot The dooting of an operating system works dy loadng a very smell program into tae computer and thea giving that progcam cortrol so thet ir in turn lads the entire operating system. Booting or loading an operating system is differen: than installing it, which is generally an initial one- time activity Booting and Dual Booting of Operating System The orocedure of staring a compater by loading the kemal is known asBootingthe sysiem Hence it needs a special program, stored in LOM to de this jo> knowa as the Boorstrap loader Example: BIOS (boot inou: output system). A modern PC BIOS @asic Input/Output System) supports booting from various devices. Typically, the BIOS will allow the user to configare 2 beot order. Ifthe boot order is setto CD Drive Hard Disk Drive Network Then the BIOS will try to boot from the CD érive first, and if that fails then :t will ty to boot from the hard disk drive, and if that fals then it will try 10 doot trom the network, and if that fails then it won't boot at all Booting is a startap sequence that starts the operating system of a computer wher it is turned on. A boot sequence is the iaital set cf operatioas that ‘he computer performs waen it is switched on Every computer has a boot sequence. Bootstrap loader locates the kemnel, loads it into main memory and starts its execution In seme systems, a simple doots:rap loade: fetche: mere complex boot program from disk, whic’ ia tarn loads the kemel POWER ON COMPUTER i pice penronmercet | Disk J ) RAM | JDual Booting: “Waea tw operating system ace installed cn che computer system then itis celled dual booting Jn fact multiple operating sysvemas cen be installed on such a system Eut how system kaows whica opercting system is te boct? A boot loades thar understand multiple file systems and multiple operaing system can occupy the boot space.Once loaded, it can boo: cne of the operating systems available or the disk.The disk can have muliple partitions, each containing 2 different type of operating system. When a computer system tum cn, a oot manager program displays a menu, allowing user to choose the cperaiing system to use Unit I — Process Management © A process can be thonght of ar a program in execution, A process will need certain resources - such as CPU time, memery, files, and I/O devices - to accomplish its task These resources are allecaied to the process either when it is created or while it is executing, © A process is the unit of work ia most systems. Systems consist processes: operating-system processes execute system code, and user processes execute user code, All these processes may execute concurrently © Although tradicionally a process contained cnly « single thread of control as itran, most modern operating systems now suppost processes tha: have multiple threads = The opzrating system is responsible for several important aspects of process and thread management: the creation and delet on of processes, and the orevisicn of mechanisms fer synchronization, communication, and deadlock aandling for processes Process Concepts: a collection of oth user and system processes; the scheduling A. questioa tha: arises in discussing operating systems involves what to call all the C2U activities. A batch sysiem execuces jobs, wheress a time-shared system has user programs, or tasks Even on single-aser system, a user may be able :o run several programs at cne time: 2 word processor, a Wet browser, and en e-mail package And even if a user can execate only one program at atime, such as on an embedded device that does not support multitasking, the operating system may need to sugpert its own intemal programmed activities, suck as memo-y menagement In many respects, all these activities are similar, so we call all of them processes The termsjob and process are used almost interchangeably in this textThe Process: max ~~ © A process ismore than the program code, which is sometimes known as the text section Tt also includes the curren: ectivity, as represented by the value of the program counter and the contents of che processor's registers # A process generally also includes the process stack, which 3, rebum = coatains temporary data (ich as function parame: addresses, and local variables}, end data A data section, which contains global variables © A process may alse include cheap, which :s memory that is i dynamically alloceted during process ren ime. The structare of a process in memory is shown in Figure. We empkas.ze that « program by :tselfis ao: a process. © A program is epassiveencity, such as afile containing alist of instructions stored on disk (often called an executable file) © In contrast, a process is an aciive entity, wich a program counter specifying the next instrocton to execute and a set cf associated resources. A programa becomes a process wher. an executable file isloaded into memory Two commoa techniques for Loacing executable files are © Double-clicking an :ccn sepresenting the executable file and © Extering the name of the executable file on the command line (as in preg.2xe or a.out) Process State As aprocess executes, it changes state The state of a orccessis defined in oart ty the current activity of that process, A prozess may be in one of the fcllewing states: The state diagram comesponding to these states is presented in below Figure New- Tae process is being adnitted —irterupt eit Conus created HON oe Running: Lastructioas are being execured. Waiting -Tae process is waiting for some even: occur (such as an 1/C completion) Ready -The process is waiting to be assigned to a processor, WO or event completion "2aTerminated- The process has fin: shed execution Ibs important ‘0 cealize that cnly cne process can be rumaing on any processor at any instant. Meny processes may be readyand waiting, Process Control Block-[PCB] Each process is represented in the operating system by @ preaese sats process control block (PCB)—also called atask control block process number APCEis shown in Fgure program counter Ib contains many pieces of informarioa essociated with a registers specific process, including these memory limits # Process state The state may be new, ready, ruaning, and writing, hated, and so on list of open files © Program counter. The counter indicates the address of the se next instrvction to be executed for this process = CPU registers The registers pocess Fy operating ster process P, vary in number an¢ tye, . i degendiag on the computer peep oteysen a archicecture, They include Ll a accumulators, index registers, stack peinters, and geaeral- save tate into PCB, purpose registers, olus eny : pide coadition-tode information. © CPU-scheduling information (ead ste fom PCB, This information includes a - process priority, peinters te scheduling queues, and eny other ye ineruptorysiemeal executing scheduling pararzeters -——._ © Memory-management ts information. This information save state into PCE, may include such items as che ° Sie value of the base end limit registers andthe page tables, or ee the seamert tables, depending on tebad state fom PCB, the memory system used by she executing {~~ operating system © Accounting information. This information inclades ‘he amount Diagram showing CPU switch frm proces to process,of CPU ard real tme used, time limits, eccount numbers, job or process rumbers, and sc on = V0 stausinformation. This irformation includes tae lis: o? LO devices allocated :o the process, alist of open diles, and so on In brief, the PCB simply serves as the repository Zor ary informatioa that may vary from process to process, Process Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU utilization The objective of time staring is to ewitch tae CPU among processes so frequently that users can interact with each program while itis runniag Te meet these objectives, the process scheduler selects an available process (possibly from a set of several available processes) fcr program execution on the CEU For a single-procescor system, there will never te more than one running process. If there are more processes, the res: will have to wait until the CPU :s ‘rez enc can be rescheduled Schedul Que ‘As processes enter the system, they are pu: into a job queue, which consists of all processes in she system The processes that are residing in main memry and are ready and waiting to execute are kept on a ist called the ready queue This queue is generally stored as ¢ linked list. A ready- quene header coatans peinters to the fisst and final PCBs in the list Each PCB includes 2 pointer field thet points to the next PCB in che ready quene mt The system also includes other queues. When 2 process is allocated the CPU, it executes Zor a while and eventually quits, is interrapted, or waits for che occurrence of a particular event, ; such as the completion cf an YC ‘Theretdy queue and vrous 0 device aieuesrequest, Suppose the process makes an VO zequestto a shared device, sach as a disk Since there are many processes in the system, che disk may be busy with the LO request of some ocher process, The srocess therefore may aave to wait Zor the disk. The list of processes waiting for a patticular UO device is called a device queue Each cevice hes its own device quene aE A common representation of L process scheduling is a queuing diagram, 2) ee such as that in Figure. Eeck rectangular es ex represents 2 queue. Two types of ee queues are present: the ready queue and 2 a set of cevice queues. The circles represent ( cectes hid the resoarces that serve the queves, an: = — arows indicate the flow of processes ior), [vata \ peau interrupt system. Avnew prozess is initially put in 1 ready quene It weits there until it is selecied for executicn, or dispatched, Once the process is allocated the CPU and is execatiag one cf several events could cccur ‘Qusteng-dagram eprese + The process could issue an /O request and then be placed in an VO queze. + The process could create anew child process and wait forthe child’ termination + The process could be removed forcitly from the CPU, as a result of aa iaterrupt, and be pur back in the ready queue. Jn the firs: two cases, the process eventually switches from the waiting state to the ready state and is thea put back in the ready queue. A proces: continues this cycle until it terminates, at which time itis removed from all queues and has its PCB and rescurces deallocated Schedulers: ‘A process migrates amoag the various scheduling queues chroughou: its lifetime. The operating system mus: select, for scheduling purposes, processes From these queues in some fashion The selection process is carried out by the app-opriate scheduler. Often, in 2 daich system, more processes are submitted than can be executed immediately These processes are spooled to a mass-storage device (:ypically a disk), where they are kept fos leter execation.The long-term scheduler, orjoh scheduler, s:le:i processes from this pool and loads them into memory for execution The short-term scheduler, or CPU scheduler, selects from arioag the processes that are ready te execute and allocates the CPU to one of shem, The long-term scheduler executes rauch less frequeatly, minutes mey separate the creaton of onz aew process aad the next. The long-term scheduler contzols the degree of multiprogramming (the cumber of processes in memory) Scme operating systems, sack as time-sharing systems, may introduce an additional, intermedicte level of scheduling, Tais medium-term scheduler is diegrammed in Figure. The key idea behind a mediurs-temm scheduler is chat sometimes it can be advantageous to remove a process fiom memory (end from active contention for the CPU) ané thus reduce the degree of multiprogcamming, La‘er, the process can be seintrodacedinto memory, and its execution can be contiaued where it left off. This scheme is called swapping The process is swapped out, and is later swapped in, by tae medura-term scheduler, Swagping may be aecessay to improve the process mix or because a change in memory requirements has cvercommitted availble memory, requiring mem ory tc be Beed up Context Swit svaoin_| pata oeuted svapout . snapped-utprocses Switching the CPU to another process requires perfcrming a state save of enti a the current prozess and a state restore of 2 <=] mafyaime > ced Font different process. This task is known as 2 context switch non ‘When 2 context switch occurs, she a kemel saves che context of the old process in its PCB and loads the saved context of the new process scheduled to run Context-switch time is pure overhead, because the system dees no useful work while switching. Switcking speed varies trom machine to machine, depending on the memory speed, the mumber of cegisters that mus: be copied, and the existence of special instriciioas (suck as a single instruction to load or stere all registers) A typical speed is afew milliseconds Operations on Processes The processes in mos: sysiems can execute concurrently, and they mey be crea‘ed and deleted dynamicelly. Thas, these systems must provide a mechanism for provess creation. and terminationJn this section, we explore she mechanisms involved in creating processes and illustrate process creation on UNIX and Windows systeras Process Creation During the course of exer mentoned earlier, the crzating pro: called the children of that process. Each of these new processes may in tum create other processes, processes, rion, a process may create several new processes. As cs 18 called parent process, aad the new processes are rming a tree of Most operating = systems (including ) UNIX, Lim, and Ss. Windows) identify 5s processes according t> 2 unique process identifier (or pid), which is typically an integer aunber The pid provides a unique value for each process in the system and i: can be used as an ‘tee of processes ona pial Linux sytem index to gocess various attsibates of a process ‘With in the kemel Jn general, when a grocess creates a child process, thet child process will need certain recources (COU time, memory, files, LO devices} to accomplish its task A.child process may be able te obtain its resources divectly fiom the operating system, or it mey be coastraned to a subset of the resources of the parent process. The parent may have te partition its resources among its children, or it may be ble to share scme resources (s memory o: files) among several of its children. Restricting a child process to a subset of the parent's zesonrces prevents any process from overloading the system by creating toe mary child processes “Waea a process creates 2 new process, twe possibilities for execution exist: 1. The paren: 2. The parz ontinues te execute concurrently with its children, aits untl some or all of its children have terminatedThere are also swo address-space possibilities for the new process 1. The child provess is a duplicate parent) 2, The chil process has anew program loaded inte it 2 the parent process (same program and data es the The C program shown in Figare illustrates the UNIX system calls include
previously descrited We now have ——— two défereat processes ruaning t copies of the same program, The Pine Bie only difference is thet the value of /+ fork a child process */ pid (the process identifier) for he Bee: child process is zero, while shat for if (pid < 0) { /* error occurred */ the parent is an integer value grea‘er fender, than zero (in fact, itis the actual pid } . of the child process) else if (pid == 0) | /* child process +/ 1 sexsslp i fhia/A ALES The child process inhecits else { /+ parent process */ privileges and schecul:ng attributes Ceo. SS es from the parent, es well certain Print£ ("Child Complete") resources, such as open files. The } child process then overlays its rerun 0} address space with the UNIX } command ftinls (used to get diectory listing) using the execlo( system call (ezeclp() is a version of the exec() system call) The parent waits Zor the child process to complete with the wait() system call. When the child process completes (by either implicitly or explicitly invoking exit()}, the pareat process recumes from ‘he call to wai:0), where it completes using the exit() system cell. Tais is alse illustatedin the following Figure parent rk) ) hid (gid = 0) Process creation using the fork () system callOf course, there is nothing to prevent the child from mot invoking execand continuing to execate as 2 copy of the parent process. In this ccenaric, fhe pareat and child are concurrent processes running the same code insructions. Becanse the child is a copy of the pereat, each process has ivs owa copy cf any data Process Termination A process temminates when :t finishes executing its final statement ard asks the operating system to delete it by asing the exit() system call, AA: that pcint, the process may rem a status value (iypically an integer) to its pareat process (via the wai:() system call) All tae resources of the process—including physical and virtval memory, open files, and WO bufiers—are dedlocated by the operating system. Termination can ozcur in cther circumstances as well, A proves can cause the temminaticn of another process via an appropriate system cali (for example, Terminate Provess() in Winéows) Ueudlly, suca ¢ system call can te invoked only by the parent cf the process thatis to be terminated, Otherwise, users could arbitzarily kell each other's jods. Note that a parent needs te know the identities of its children if itis :0 terminace them Thus, when onz prozess sreates a new process, the idertity of the newly created process is passed to the parent. A parent may terminate the execation of one of its children for a variety of reasoas, such as these © The child has exceeded its usage of some of the resources that it aac been allocated, (Te derermine whecher this has occurred, the paren: must have a mechanism to inspect the state of its chil dren.) The task assigned to the child is no longer required The parent is exiting, and the operating system does not allow a child to continue if its parent terminates Scme systems do not allow a child to exist ifits parent hes terminated In saca systems, if a process temixates (ether normally o: abnormally), then all its children must also be terminaceé. This phenomenoa, referred to as cascading termination, is normally init:ated by che operating system Te illustrate grocess execution and termination, consicer that, in Lixux end UNIX systems, we can termainat2 2 process by using the exi:() system call, providing an exit status as 2 parameter:/* exit with status 1 */ exit(); under ronnal termination, exit() may be called either cirectly (as shown above) or indirectly (by @ retum statement in nzin() Interprocess Communication Processes executing concurrently in the operating system may >e either independent processes or ccoperating processes ‘A. proves: is independent if it cannot affect or be affected by the otker procesres exzovting in she system Any process that does net shave data with any other process is independent A. process is cooperating if it can aftect or be affected by the orher grovesses executing in the system. Clearly, any process shat shares data with otter processes is a cooperating process There are several reasons for process A process A providing an envirenment that | allows process cooperation: shared memory process B l ‘| + Information sharing Since r process B several users may be interested in the same piece of information We must provide an environment to allow concurrent access to such information essaye queue + Computation speedup. If we want mola. a patticalar task to run faster, we eee kemel must break i: into svbtasks, each of kere which will be executing in parallel ; with the others ia) (b) + Modularity, We may want tc Commuricatons modes ( Message pessng.b) Shaedmenoy, CO2struct che system in a modular fashion, dividing the system functions into separete processes or threads * Convenience Even an individual aser may work on many tasks ai the came time. Fer instance avser may be editing, listening to music, and compiling in oacalielCooperating processes require an interprocess communication (IPC) mechanism that will allow them to exchange data and infomation, There are two fundamental models of interprocess communication © Shared memory © Message passing In the shared-memory medel, aregion of memory that is shared by cooperating processes is established, Processes caa thea exchange informatioa by reading and wrsting da‘a to the shared region Jn the message-passing model, commanicaticn takes place by means of messages exchanged between the cooperating processes The two commanications models are con:rasted in above Figure Both of the medels just mentioned are common in operating systems, and mary systems implement beth use no conflicts Message passing is aseful for exchanging smaller amounts of data, b need be avoided, Message passing is alco easier to implement in a distributed system than shared memory. Shared memory can be faster than message passing, since message-passing systems are typically implemented vsing system calls and thus require che mose time-consuming tack of kemel interventicn. In sharzd-memory cysteras, system calls are required cnly to establish shared memory regions, Once sharadmemory is estebl:shed, all accesses are treated zs routine memory aczesses, and no assistence from the kemel is reqnired ‘Shared-Memory Systems Interprocess communication using shared memory requires communicating processes to establish aregicn of shared memory They can shen exchenge informaiioa ty seading and writing data ia the shared areas The form of the cata aad the location are determined by these processes and are not under the opecating system’ s coatrol. The processes are also responsisle for ensuring that they are not writiag to the same location simultaneously. Te illustra problem, ‘he concept of cooperating processes, let's consider the producer — consumer‘Wich is a common paradigm for cooperating processes. A producer process predic informaticn tha’ is consumed by aconsumer process For example, a compiler may produce a:sembly code that is consumed by an assembler The assembler, in tum, may prodace object modules that are consvmed by the loader. The producer - consumer proslem also provides a usetul metaphor for the client ~ server paradigm, We generally think of a server az a producer and a client as a consumer. Fo: examgle, awed server produces (that is, provides} ETML files and images, which are consumed (that is read) by the client web browser requesting the rescurze One solution te the preducer ~ ccnsumer protlem uses shared memory. Te allow producer and consumer processes to mun concurrently, we must have aveileble 2 buffer of stems that can te filled by the prodvcer en¢ emptied by the consumer. This buffes will reside in a region of memocy that is shared by she producer and coasumer processes. A producer can produce one item while the consumer is consuming anotaer item. Tae producer and coasumer must be synchronized, se that the consumer does a0: try ‘o consume en item thet has not yet been produced while (ime) C J produce an item in nex: produced *! while (((in + 1) % BUFEER SIZ3) = oat) ; do nothing * buifer{in] =next produced; in = (in + 1) % BUFFER SIZE } The producer process using shared memory Two types of buffers can be used. The unbounded buffer places no practical limit on the size of the tuffer The coasumer may have to waitfor new items, but the producer can always produce new items The bounded buffer assumes 2 fixed buifer size. In th:s case, the consumer must is full ‘wait ifthe buffer is empty, and the producer must watt i the ‘Mbssage Passing System s The shared-memcry environmen: requires that these processes share a region of memory and that the code for accessing and manipulating the shared memory be wristen explicitly ty the apolication prograrmer.Another way to achieve the same eifect s Zor the opera‘ing system to provide the means for cooperating processes te communicate with each other via amessage-pacsing facility Message passing provides a mechanism to allow processes te communicate and to syachronize their actions without sharing the same address space, It :s particularly vseful in 2 distributed eavironmert, where the communicating processes may resi le on different computers coanected by a network. For example, an Intemet communicate with one another by exchangiag messages at program could be designed so that chat participants ‘A. message-passing facility provi des atleast two operations d (message) receive(message) “Messages sent by a process can be sitaer fixed or vasiable in size EE only fixed-szed messages can be seat, the system-level implemertatioa is straigat- forward, This restricticn, however, makes the task of programming more difficult Conversely, varatle-sized messages require a more complex system-level implementator, but the programming task becomes simpler. IE processes P and Q want tc communicate, they must send messages to and receive messages Zrom each other: acommmunication linkmust exist >etween them This link can te implemented in a variety of ways. We are concerned here not with the link’s physical implemeataticn (suck as shared memory, hardware bus, or network) but rather with its logical :mplementation Here are several methods for logically implementing a link and the send()éreceive() © Direct or indizect communication © Syncarenons or acynchroaoas communication © Automatic or explicit buffering Naming Procesces that wentto communicate raust have a way to refer to each other. They can ase either direct o: indirect communication ‘Under direct communication, each process thal wants ‘ + explicitly the comruaication, Ja this scheme, the send() and receive name the secipient or sender primitives are defined asA communication link in this scheme nas th sendi(P, message)— Senda message to process P reveive(Q message)— Receive a message from process Q following properties © A link is established automatically betwee every peir of processes that want te comruaicate, The processes need to know only each other's identity to communicate # Alinkis associated with exactly two processes © Between eaca pair of procesces, there exists exactly one link Synchronization Communication between processes takes place through calls to cend() ané receive() primitives, There are different design cptiors for implementing each primitive Message passing may be sither blocking or nonblocking— also xncwn as synchronous and asynchronous (Throughout :his tex:, you wil! encounter the ccncepts of synchronous and asynchronous behavior in relation to vasioas operating-system algozithms.) Blocking send The sending process is blocked amil the messege ic received by the receiving orccess or by the mailbox. Nonblocking send The sending process sends the message and resumes operaton, Blocking receive The receiver tlocks until amessage is availatle Nonblocking receive The receiver retrieves zither a valid message or anull Buffering ‘Waesher communication is direst or inditec:, messages exchanged by communicating processes reside in a temporary cneze Easically, such queues cen be implemented in three ways Zero capacity The queve has a maxiznvm length of zero, thus, the link canaot have any messages weiting in it, In this case, the sender must block untl ‘he recipient receives the messaze Bounded capacity The queve tas finite length yj thus, at most » messages reside in i. IE the queue is not full when a aew message is sent, the message is placed in the quene (either the message is cop:ed or apointer to the message is kept), and the sender car. continue execution withcut waiting, The link’s capacity is finite, however EE the linkcis full, she sender must block until space is available in the queze. Unbounded capacity The queue’ s length is po:entially infirite, thus, ny number of messages an waitix it The sender aever blocks‘Multi. Threaded_Programming Thread A thread is a flow of execution through the process code, with its own program counter that keeps track of which instruction te execute aext, system registers which hold :ts current working varsables, anda stack which coatains the execution history ‘A thread shares wita its peer threads few informeticn like code segment, data segment and cpen files. Wher. one shread alters a code segment memory iterr, all other chreads see that A thread is also called a lightweight process Threads provide 2 way to smpreve apolization performance throaga pavallelism. Threads cepresent a software approach to improving performance of cperating system: by redacing the overhead thread is equivalent to a classical process. Each thread beloags to exactly one process and no thread can exist outside a process Each thread represents a separaie flow of conol. Threads have been successfully used in implementing netwerk servers and web server. Taey dso provide a suitable foundation for parallel executor cf applications on shared memory multigrecessors ‘The following figure shows the working of a singl2-tareaded and a multithreaded process Difference between Processand Thread SN. Process Thread 1 Processisheavy weight or resource Threads light weigh’, taking lesser rescurces intensive than a process 2 Process switshing needs interaction with Thread switching does notneed toinceract operating system with operating system 3 Inmnttiple processing envirenments, each All threads can share same set of open files process executes tae same code bet has its child processes own memory and file resources 4 Ione process is blocked, then a0 other While one thread is blocked and waiting, process can execute ansil the first process is unblocked second threadin the same task can ran5 Maltple processes withoat using threads Multiple threaded processes use use more resources resources 6 __ Inmnttiple processes each process One thread can read, write or change another operates irdepeadently of the ochers threads data Advantages of Thread © Threads minimize the context switching time # Use of threads provides concurrency within a process + Efficient commurication © Ibssmore economical to create and context switch threads © Threads allow utiization of maltiprocescor architectures to a greater scale ard efficiency ‘Typesof Thread Threads are implemeated in following two ways— + User Level Threads~ User manageé threads. + Kernel Level Threads ~ Operating System managed threads actng cn kemel, an operating system core A thread is a basic unit of CPU utilization; it compsises a thread ID, a program counter, 2 regiscer set, and a stack, It shares with other threads belonging te the same process its code section, data section, and other operating-system resources, suck as opea files and signals =| A tradticnal (or heavyweight) process has single ‘hread of control. IE 2 process has multiple tareacs of coatrol, it [Lee Tse J ee can perform mere than one task a atime The following Figure illusraes che roi 8 8 $ ot “difference between a tradtioaal single threaded process aad a multithreaded process retired provers Motivation Most sofware applications chet um on modern computers are multitareaced An apolicatioa typically isimplemerted as a separate process with several chreads of coatrol.A. web browser might have one thread display images or text while another thread retrieves date from the network For example, A word processor my nave a thread for dieplaying graphics, another thread for responding t> keystrokes from the user, and a third thread fer pecfcrming spelling and grammar checking ia the backgrouad, Applications can also be designed to leverage processing capabilities on multicore systems. Such applications parallel across the multiple computing cores perform several CPU-intersive tacks in (2) create new One solution is to have (1) request yesite rns the server run as a single procese cient -— seer }- ttreat ] thet accepts requests. When che server receives a request, it creates a separate process te service that request. In fact, this (@) resume listening process-creation method was in jor addtional aliens common use before threads became pogular. Process creation is time consaming and resource intensive, however. If the new grecess will pesform the same tacks ac the existng process, why incur all faa: ovechead? It is generally more eflicient t> use one process that contains multiple threads If the webserver precess is multithreaded, the server will create a separate thread that listens for client requests. When a request is made, rather than creakng another process, the server creatzs a new thread to service the request and resume listening for additional requests Finally, most operating-sysiem Lemels are now multitareaced Several chreads operate in the kemel, and each thread performs a specitic task, suca as managing devices, managing memory, or interrup: handling. For example, Solaris has a set of threads ir the kernel specifically for intecrupt handing, Linux uses alkernel thread for managing the amcunt of fee memory in the system. Benefits The benefits of multithreaded orogramming can be broken down inte four major categories © Responsiveness Multithreading an interactive applicator may allow a program te continue sunning ever. if part of st is blocked cr is pecforming a lengthy operation, thereby increasing responsiveness to the user. © Resource sharing Processes can only share resources through techniquessuch as shaced memory and message passiag © Economy. Allocating memory and resources for proce: threat creation is costly Becanse
You might also like
Fundamentals of Cyber Security 2
PDF
No ratings yet
Fundamentals of Cyber Security 2
52 pages
Chapter 1 OS, 2016
PDF
No ratings yet
Chapter 1 OS, 2016
21 pages
Introduction of Operating System
PDF
No ratings yet
Introduction of Operating System
21 pages
Introduction To Operating System
PDF
No ratings yet
Introduction To Operating System
11 pages
Operating System NOTES
PDF
No ratings yet
Operating System NOTES
22 pages
400level Operating Systems Lecture Notes
PDF
No ratings yet
400level Operating Systems Lecture Notes
248 pages
Unit I J1
PDF
No ratings yet
Unit I J1
7 pages
OS
PDF
No ratings yet
OS
100 pages
Unit 1
PDF
No ratings yet
Unit 1
54 pages
Operating Systems
PDF
No ratings yet
Operating Systems
22 pages
Setoran Kantin
PDF
No ratings yet
Setoran Kantin
4 pages
Operating System
PDF
No ratings yet
Operating System
10 pages
Unit 1
PDF
No ratings yet
Unit 1
103 pages
Os 12
PDF
No ratings yet
Os 12
88 pages
Computer Architecture OS
PDF
No ratings yet
Computer Architecture OS
38 pages
BY Juhi Agarwal Assistant Professor CIT Upes
PDF
No ratings yet
BY Juhi Agarwal Assistant Professor CIT Upes
46 pages
Operating System - Full Note
PDF
No ratings yet
Operating System - Full Note
133 pages
Operating System
PDF
No ratings yet
Operating System
139 pages
Computer Operating System Lecture Notes
PDF
No ratings yet
Computer Operating System Lecture Notes
28 pages
OS Chapter One
PDF
No ratings yet
OS Chapter One
36 pages
Operating System Lecture Note 2015
PDF
No ratings yet
Operating System Lecture Note 2015
118 pages
Unit 1
PDF
No ratings yet
Unit 1
109 pages
AICT Lecture 10
PDF
No ratings yet
AICT Lecture 10
19 pages
Operating System
PDF
No ratings yet
Operating System
78 pages
Introduction To Operating System
PDF
No ratings yet
Introduction To Operating System
37 pages
Operating System
PDF
No ratings yet
Operating System
19 pages
Ebook csc204
PDF
No ratings yet
Ebook csc204
184 pages
Operating Systems Notes FINAL - Unit1
PDF
No ratings yet
Operating Systems Notes FINAL - Unit1
11 pages
Unit 2 Operating System: Structure Page No
PDF
No ratings yet
Unit 2 Operating System: Structure Page No
12 pages
1operating Systems
PDF
No ratings yet
1operating Systems
51 pages
Lecture 4
PDF
No ratings yet
Lecture 4
57 pages
OS Unit 1
PDF
No ratings yet
OS Unit 1
41 pages
Unit-1 Operating System
PDF
No ratings yet
Unit-1 Operating System
31 pages
Osunit 1 Part 1
PDF
No ratings yet
Osunit 1 Part 1
22 pages
Unit 1 - Overview of Operating System
PDF
No ratings yet
Unit 1 - Overview of Operating System
34 pages
Os Notes
PDF
No ratings yet
Os Notes
29 pages
Operating System-1
PDF
No ratings yet
Operating System-1
189 pages
Pos Notes Unit 1
PDF
No ratings yet
Pos Notes Unit 1
13 pages
EContent 11 2023 02 26 23 57 40 Unit1pdf 2023 01 16 10 08 03
PDF
No ratings yet
EContent 11 2023 02 26 23 57 40 Unit1pdf 2023 01 16 10 08 03
131 pages
CSE - Operating System Notes
PDF
No ratings yet
CSE - Operating System Notes
87 pages
Lecture 01
PDF
No ratings yet
Lecture 01
55 pages
Chapter 1 - Introduction
PDF
No ratings yet
Chapter 1 - Introduction
21 pages
What Is An Operating System?
PDF
No ratings yet
What Is An Operating System?
15 pages
Os Bca Unit 1.1
PDF
No ratings yet
Os Bca Unit 1.1
21 pages
Chapter 1 Introduction
PDF
No ratings yet
Chapter 1 Introduction
21 pages
Unit-I-Operating System Overview and Structure
PDF
No ratings yet
Unit-I-Operating System Overview and Structure
68 pages
Os Full
PDF
No ratings yet
Os Full
59 pages
Book 2.indb - DCAP403 - OPERATING - SYSTEM
PDF
No ratings yet
Book 2.indb - DCAP403 - OPERATING - SYSTEM
19 pages
OS Unit-I - Operating System
PDF
No ratings yet
OS Unit-I - Operating System
44 pages
OS Lesson1
PDF
No ratings yet
OS Lesson1
34 pages
MDU BCA - Operating System
PDF
No ratings yet
MDU BCA - Operating System
181 pages
Operating System: by Bhaswanth
PDF
No ratings yet
Operating System: by Bhaswanth
21 pages
1.1.2 - Introduction of Operating System - 20220817 - 090404
PDF
No ratings yet
1.1.2 - Introduction of Operating System - 20220817 - 090404
5 pages
Introduction To Operating System
PDF
0% (1)
Introduction To Operating System
20 pages
OS Intro
PDF
No ratings yet
OS Intro
34 pages
Course Name-Operating System Course Code-COM-302 Lecture No-1 Topic - Introduction To OS Date-18-10-2021
PDF
No ratings yet
Course Name-Operating System Course Code-COM-302 Lecture No-1 Topic - Introduction To OS Date-18-10-2021
17 pages
Adobe Scan 13 Mar 2024
PDF
No ratings yet
Adobe Scan 13 Mar 2024
7 pages
Cyb 203 Lecture Note 1
PDF
No ratings yet
Cyb 203 Lecture Note 1
18 pages