0% found this document useful (0 votes)
871 views

OSY Chapter 1 To 6 Notes

Uploaded by

2008 Avadhut
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
0% found this document useful (0 votes)
871 views

OSY Chapter 1 To 6 Notes

Uploaded by

2008 Avadhut
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
You are on page 1/ 98
ola a Overview of Operating System Operating System : Concepts, Components of Operating system, Operations of OS » Program management Resource management, Security and Protection Views of 0S = User view, System view Pending Different Types of Operating systems : Batch operating system, Multi Programmed, Time Shared OS Multiprocessor Systems, Distributed Systems, Real time systems, mobile OS (Androld, iOS) Command line based OS : DOS, UNIX, GUI Based OS - Widows, Linux 1.1__ Introduction to Operating System ~ An operating system is system software which manages, operates and communicates with the computer hardware and software. ~ To complete the execution user program, need many resources ~ The main Job of the operating system Is to provide resources and services to the user program. So without operating system, a computer would be useless. Definition ; ~ An operating system acts as an interface between the user and hardware of the computer and also controls the execution of application programs = Operating system is also called as resource manager, 1.1.1 Need of Operating System Basically operating systems perform tasks, for example identifying input from the input devices such as keyboard, ‘mouse etc and sending output to the output devices such as monitor, printer etc and keeping track of files and directories on the disk, and controlling peripheral devices such as secondary storage devices, printers, scanners, audio mixer, ~The heart of a computer system is a processing unit called CPU. ~ User's program should get the processing unit to complete the execution and computer system should offer the Service to allocate processing unit to users program. a ~The operating system allocates memory to user progra sm as per need. In the same way, user programs interact with the other user programs through devices like key board, or a mouse or even a joy stick. 1.1.2 Components of Operating System Operating system consists of many components. Each component of the operating system has its own set of defined inputs and outputs. Different components of OS perform precise tasks to offer the overall functionality of the operating ‘system, The most important functions of the operating system are as follows : Process Management Memory Management File Management Device Management . Protection and Security User Interface or Command Interpreter . Booting the Computer Performs basic computer tasks 1. Process Management The process management activities involves (i) To provide control access to shared resources like file, memory, I/O and CPU. (ii) Control the execution of user applications. (ii) Creation, execution and deletion of user and system processes {iv) Resume a process execution or cancel it (v) Scheduling of a process (vi) Synchronization, interprocess communication and deadlock handling for processes 2. Memory Management The memory management activities handled by operating system are (i) Allocation of memory to the processes (li) Free the memory from process after completion of execution {lii) Reallocation of memory to a program after used block becomes free (iv) Keep track of memory usage by the process. }. File Management The file management activities of operating system consist of (i) Creation and deletion of files and directories (il) Provide access to files and allocation of storage space for files (lil) Maintain back-up of files (iv) File Security. System 19 4. Device Management ‘The device management tasks includes : () Toopen, close and write device drivers, (ii) Communicate, control and monitor the device driver. 5. Protection and Security ‘The resources of the system are protected by the operating system. User authentication, fle attributes such as read, write, encryption and back-up of data are used by operating system to give necessary protection. 6. User Interface or Command interpreter ‘The role of operating system is to work as interface between the User and hardware of the computer. This interface is Provided by operating system through set of commands or itis a Graphical User Interface (GUI) 7. Booting the Computer The process of starting or restarting the computer is known as booting. If computer is switched off completely and if turned on then it is called cold booting. A warm booting is the process of using the operating system to restart the computer. 8. Performs basic computer tasks ‘The different peripheral devices such as the mouse, keyboard and printers are managed by operating system. Now ‘days most operating systems are plug and play which means any device will automatically be detected and configured without any user interference 1.1.3 Operations of Operating System = Modern operating systems are interrupt driven. Operating system sits idle and waitin case if there are no processes to execute, no 1/0 devices to offer service and there is no any user to whom response is to be given. = In this case operating system just waits for something to happen. When interrupt or trap occurs then events are signalled. = Ifabnormal condition arises in system during program execution, then itis detected by CPU is called trap. = Trap occur exactly same point of time of program execution. Software interrupts are trap or exceptions. Example is division by zero, = After recei ‘once it is through servicing the interrupt. 1g an interrupt, operating system carry out some housekeeping so that it can resume its computation ~ After this a searching is carried out in the interrupt vector or interrupt table. ~ This table remains in kernel-memory space and includes address of the code in the device driver that isto service the interrupt, > The Interrupt handler is then executed. When the handler finishes, control ofthe CPU is returned to the code that was ‘executing before the interrupt occurred. ~ Interrupt routine ISS) deal with interrupts. ~The design of the operating system should be in such a way that one erroneous or malicious program should affect other programs. C For ee 1.1.3.1 Dual Mode Operation There are two modes of operating system : “The malorityof CPUs support at least two modes of operation Le. Kernel mode and user mode. ‘and the entire and set of all registers is accessitje {In kernel mode, all instructions are allowed to be executed, throughout the execution. con the contrary to this, In user mode, memory and register access is restricted, The CPL) gets switched to kernel mode while executing operating system code. Is through system calls as implemented by the operating ‘The only means to switeh from user mode to Kernel mode i system. Hardware contain mode bit which indicate kernel mode when 0 and user mode when set to 1. When user application is running then system isin user mode. When user application requests the service from operating system then transition from user mode to kernel mode take place. During booting of the system, hardware is in Kernel mode, Once the operating system Is loaded and start executing User application system goes in user mode. Due to dual node operation, protection from misbehaving users is achiev allowing the execution of privileged instructions in kernel mode only, fed. This protection can be provided by ‘Any attempt to execute these privileged instructions in user mode cause trap to operating system, ‘The instruction to enter in user mode, Instructions for /O control, timer management, and interrupt management are some of the examples of privileged instructions. From user mode, control is switched to operating system through interrupt, a trap, or a system call The interface between OS and user programs is defined by the set of syster calls that the operating system offers system call isthe call for the operating system to perform some task on behalf of the program, Therefore system calls make up the interface between processes and the operating system There are two ways for the process to switch from the user mode to the kernel mode. (One is when a user process explicitly request to enter in kernel by issuing a system call Other i, during the execution of user process kernel can take over to carry out some system housekeeping task 1.1.3.2 Timer Computer contains crystal clocks containing crystal oscillator, a counter, and a holding register ‘A quartz crystal under tension produces a periodic signal of very high accurateness, usually in the range of several hundred megahertz to a few Gigahertzes, depending on the crystal chosen, By electronic circuitry, this base signal can be multiplied by a small integer to get frequencies up to several gigahert? ‘and more than this. Computer contains at least one circuit, than produce synchronizing signal and given to many circuits in computer. This synchronizing signal is fed into the counter to make it count down to zero. When the counter gets to zero, causes a interrupt, wien A 45 Overview of: 3 in one-shot mode, after the clock is started, holding register value gets copled into the counter and then decrements the counter at each pulse from the crystal. When the counter value becomes zero, It causes an interrupt and stops until it is explicitly started again by the software. In square-wave mode, after getting to zero and causing the interrupt, the holding register is automatically copied into the counter, and the whole process is repeated again indefinitely ‘These periodic interrupts are called clock ticks. Every computer has a battery-powered backup clock to save the ‘current time when machine is switched off. Universal coordinated time is used to synchronize the clocks of the machines. ‘Operating system ensures to set timer to interrupt before hand over the control to user application 1.1.4 Program Management ‘A program or application under execution is called as process. A process includes the execution context ‘A program resides on the disk. On disk it does require any resources. ‘A program gets executed in main memory So it should be transferred from disk to memory. To complete execution, program needs many resources and competes for it. These resources are memory, CPU, files etc. Now it becomes process. From the computation context point of view, 2 process is defined by CPU state, memory contents and execution environment Process manager implements the process management functions. {In multiprogramming, single CPU is shared among many processes. I many processes remain busy in completing /0, CPU is allocated to only one process at a given point of time Here some policy is required to allocate CPU to process called as CPU scheduling f multiple users are working on the system, operating system switches the CPU from one user process to other User gets the illusion that only he or she is using the system, Process synchronization mechanism is required to ensure that only one process should use critical section, Process communication and synchronization, deadlock handling, suspension and resumption of processes and creation ‘and deletion of the processes etc. are some of the activities performed in process management Program counter contains address of the instruction from which execution resumes after context switch The process management activities involve 1. Toprovide control access to shared resources like file, memory, I/O and CPU. 2. Control the execution of user applications. 3. Creation, execution and deletion of user and system processes. 4. Resume a process execution or cancel it. 5. Scheduling of a process 6. Synchronization, interposes communication and deadlock handling for processes Ee WW cporning System (MSBTED 1 Overview of Operating System 4.1.6 Resource Management ~ From the computer's point of view, the operating system is the program most closely involved with the hardware. In this context, we can view an operating system as a resource allocator. Resource : There are many resources available in the systems. For example CPU, memory (RAM), file-storage space, Vo devices (dish, files, printers and so on, = The OS acts as the manager of these resources. It decides which resource should be given to which program, for how much time and after use it reclaims the resource. Each program gets : 4. Time with the resource 2. Space on the resource = Multiple users/applications can share the resources. The reasons is of sharing are : 1, The devices are expensive, so sharing saves the cost. 2, The data needs to be shared as well as needs to be communicated. = Facing numerous and possibly conflicting requests for resources, the OS must decide 1. How to allocate them to specific programs (processes, jobs) ? 2. How to protect applications from one another ? 3, How to provide fair and efficient access to resources ? 4, How to operate and control the various 1/0 devices ? 1.1.6 Security and Protection 1.1.6.1 Security and It's Goals = The security breach or misuse of the system can be classified as purposeful (malicious) or unintentional (accidental). It is easy to deal with accidental misuse with compare to malicious misuse. The protection mechanisms are basically designed for protection from accidents. = The system is secure if its resources are used and accessed as proposed under all conditions. Total security is impossible to achieve. We must have mechanisms to make security breaches an exceptional occurrence, rather than the rule. The challenge in developing operating systems security is to design security mechanisms that safeguard process execution and their generated data in an environment with complex interactions. = The protection of the system considers and concern only about internal environment of the system. In contrast, security requires consideration of the external environment within which the system functions. Only sufficient Protection system is not enough for total security. Protection mechanisms refer to the particular operating system mechanisms which are used to protect information in the computer. Security encompasses the overall problem of security, = Security has many aspects. Three of the more important ones are ‘© The nature of the threats. © Thenature of intruders. © Accidental data loss. a vs protection system should be flexible enough to offer diferent and put into effect the different "yPes of policies. ferent types of applications have different types of resource use. The polcies designed should allow to offer ‘his resource use need. The resource use of the applications can change over the period of time. Hence, instead of relving totally on operating system, application programmer should use protection mechanism to protect the resources created against misuse. 4.1.6.3 Protection Domains ‘The system contains many hardware objects such as CPUs, memory segments, disk drives, printers, magnetic tapes and many software objects such as processes, files, databases, or semaphores. Each object can be referenced by its nique name. On every object a finite set of operations can be performed. For example, WAIT and SIGNAL on semaphores and READ and WRITE on files. — _Asystem should enforce a mechanism, to restrict the processes from accessing the needed objects for which they are not unauthorized. The mechanism should also ensure to restrict processes to a subset of the legal operations when that is needed. — For example, process P has a permission to read file F but not of performing write operation on it. A set of object and rights pair is called domain. Each pair denotes an object and some subset of the operations that can be performed on it. One domain corresponds to one user and specify the permissions to user for certain activities. Consider the following three domains as shown in Fig. 1.1.1. Domain 2 Domain 3 Filo CR) File D [RWX)| File E [RW] Filo F [RW] File G [RWX) Fig. 1.1.1: Domains — tis possible for the same object to be in multiple domains. (Read, Write, Execute] rights are available on each object. At a particular time of execution, each process executes in some protection domain. = Inthat domain there is some set of objects it can access, and for each object it has some set of rights shown in square brackets. During execution, processes can go from one domain to other domain. The rules for domain switching are very much depends on and varies from system to system. In Unix every process Is defined by user-id and group-id (uid, gid). Two processes with the similar (UID, GID) combination will have access to precisely the same set of objects. Process often switches from user area to kernel ‘rea, that is, from one domain to other. The kernel part has access to a different set of objects from the user part. 1.1.6.4 Access Matrix The kernel part has access to a different set of objects from the user part. cee nn Te ma Fr AOE FG 1, "System keeps track on which object belongs to which domain by using ‘shown in following Fig, 1.1.2. = The system can tell if an access to a given object In particular manner purpose, system makes use of this matrix and the current domain number. Object from a specified domain is permissible. For hi, write Read | Read write Execute | Read Write Read Write | Read write Execute | Write Fig, 1.1.2 : Access Matrix for Fig. 1.1.1 It ls possible to switch domain in the matrix model by considering that a domain is itself an object, with the actior ‘enters, Processes in domain are allowed to go in domain 2, but once It is in domain 2, they cannot go back to domain 1 This situation models executing a SETUID program in UNIX. In this example, other domain switches are not permitted ay Domain | Domain | Domain lec | FileD | Filee| Filer | FileG | PrinterA i A | Enter Read = a Read write fees Write write | Execute | JI nent | oe | Write ne Execute | cali Fig 1.1.3 : Matrix model with domain switching 1.1.7 Different Views of Operating System Different views of an operating system are Application View, User View, System View and implementation view. 1.1.7.1 Application View —_Inapplication view, we consider the services provided by operating system. Operating System is responsible to provid the needed execution environment to the running programs. The program needs processor, resources during execution. memory space and othe ~ This Is exactly provided by execution environment. The program uses network, storage devices, and hardwar components through Interfaces. These interfaces are also provided by execution environment. Interfaces provide ‘simplified, abstract view of hardware to application programs. Undesirable interaction between concurrent running programs Is prevented by execution environment making them isolated from each others is also, 1, Overview of 1.7.2. Users View ifthe user is working on the single autonomous PC for his work, then performance is mostly taken into consideration ‘operating system Is designed to give ease of use and gaining performance. In this case attention will not be given to ‘optimum resource utilization. f many users working on workstations connected to mainframe, minicomputers or servers, they share the resources of the servers. This is because all access ‘the same machine for their work. The exchange of information takes place ‘among the users. ‘The operating system is designed to maximize resource utilization. In recent times, many varieties of handheld ‘computers such as Personal Digital Assistant (PDA), Handheld Personal Computer (HPC), and Modem Cellular Phones etc. have come into fashion. ‘These devices are used by single user. Some are connected to networks, either directly by wire or through wireless modems. Since devices operate by battery power, there is limitation ‘of power. Due to the limitation of power and interfaces, the remote operations of these devices are also limited, Again operating systems for these devices are designed mostly for individual usability, but performance per amount of battery life is important as well 1.1.7.3. System View 11. 1.2 that. The operating system is called as resource manager. It manages the hardware resources of a computer system. Resources include processors, memory, disks and other storage devices, network interfaces, I/O devices such as keyboards, mice and monitors, so on. The running program needs resources and operating system allocates it. Some of the resources are sharable and some not. The operating system controls the sharing of the resources among many programs that are executing, .7.4 Implementation View The operating system is implemented as concurrent, real-time program. Concurrency in operating system is due to the requirement of supporting the concurrent applications. Also operating system should directly interact with the hardware which imposes timing constraints. The execution environment contains the abstract entities like files and file system, processes and threads, address spaces, sockets, pipes etc. These entities are manipulated by running program. Different Types of Operating Systems The classification of the different operating systems is given below along with a few examples of operating systems fall into each of the categories. Many computer operating systems will fall into more than one of the following categories : ¢ (1) Multi-user (2) Multiprocessing (3) Multitasking (4) Multithreading (5) Real time rf Multi-user = In multiuser operating system multiple users can work on same computer simultaneously. Some operating systems allow hundreds or even thousands of parallel users working on the system. ~ Following are some examples of multi-user operating systems. Linux, UNIX, Windows 2000, Windows.NET. lem 2. Multiprocessing ~ Multiprocessing operating system supports for multiple CPU in a system. It supports for allocation of ditfere, to multiple threads of the program, Due to parallel execution of the threads, efficiency and performance achieved. Following are some examples of multiprocessing operating systems. — Uinux, UNIX, Windows 2000, 3. Multitasking mt CEy ©2n be ~ Operating system which supports for multitasking, permits for execution of many software processes atthe same time. Multiple tasks are handled concurrently. Following are some examples of multitasking operating systems. o UNIX © Windows 2000. 4. Multithreading A single program can have multiple threads that can run in parallel. The operating system supporting for ‘multithreading can divide the program in multiple threads that can run in parallel ~ Such operating systems that would fall into this category are © Linux © UNIX © Windows 2000. 5. RealTime For Real time operating systems time constrains are a key parameter — Ifthe completion of particular task should happen in given time constraints or action completely must take place at a certain instant or within a certain range — Real time operating systems must respond quickly. All above OS like UNIX, Windows are not real time OS. Categories of operating systems are explained in further sections 1.2.1 Batch Operating System - In earlier days’ programmers used to write their programs by using punched cards. Normally at that time, mainframe computer system used to be a resident at a computer system centre with controlled environment. Punched cards were holding the instructions of programs in encoded form. This was done by punching the card. Card was holding the instruction in binary form, Among the deck header cards which were “job control cards” would specify compiles needed to compile the program, = The operators at the computer system would group the job as per programming languages, The jobs which required ong processing time were classified as long jobs and which had short processing time was classified as "short jobs”. = _ The entire processing was batch processing on the basis of set of jobs. There was no user interaction in processing the Jobs. The processor would remain busy at a time in processing one program. If any I/O required, then processor would wait as processor speed is high with compare to I/O speed. As a consequence of this processor utilization was P and would remain idle for most of the time. In this scenario only one program was kept in the memory at the time execution, 3 Overview of Operating System m This operating system does not permit the user to interact with executing program. Job scheduling in this type of OS in order of arrival that i first come first serve basis. ‘Accesses to files are serial. Therefore, file management is simple as no protection Is required. As in one part of memory OS resides and other part is used to load transient program for execution, the memory management is also simple. ‘These systems are better for long jobs and user interaction not needed. CPU remains busy all the time so its utilization is increased. Limitations of these types of system are smaller processes needs to wait for other jobs or processes, time consuming caused, and data Is supplied in batch so dela 4.2.2 Multiprogrammed Operating Systems Multiprogramming is required to support multiple processes simultaneously. Since multiple processes are resident in memory at the same time, it increases processor utilization if the processes are I/O bound. CPU does not remain idle. CPU utilization increases as it executes multiple processes on time sharing basis. ‘Multiprogramming gives illusion of running multiple processes at once and provides users with interactive response to processes. As single user cannot keep either CPU or 1/0 devices busy all the time, operating system supports multiprogramming, In multiprogramming, operating system organizes the jobs in such a way that the CPU always get one job to execute, Hence, Multiprogramming improves CPU utilization. Multiple jobs remain in memory so that CPU can take any one for processing During processing of job if 1/0 is required then CPU does not remain idle it takes other job for processing till 1/0 completes, Modern all personal computer operating systems support for multiprogramming. At the boot time itself, several programs starts up. These are single user as well as multiuser operating systems and offer good support to the single User or multiple users. Word processing, spreadsheets, games, and Internet access are some of the common use of these operating systems UNIX, Linux, FreeBSD, Windows 7, Windows 8, and Apple’s OS X are some of the examples of these operating systems. 1.2.3 Time Shared Operating Systems = Multiple users are permitted by time shared operating system to share the machine at the same time. Time shared system is capable of completing each action or command in a very less time. As a result, each user need can be fulfilled in very less time. A particular user program executes in allocated time by system and after expiration of slot, system gets allocated to other user program. ~ So the allocation of computer resources in time slots to several programs simultaneously is in time sharing manner. ‘Consider the example of multiple users logged in same server. The resources in server machine like CPU gets allocated to each user on time sharing basis giving the feeling to each user that only he or she is using the server machine exclusively, Overview of Operating S) 1.2.6 Distributed Systems = The development of powerful microprocessors and invention of the high speed networks are the two major developments in computer technology. Many machines in the same organization can be connected together through local area network and information can be transferred between machines in a very small amount of time. Asa result of these developments, it became easy and practicable to organize computing system comprising large number of machines connected by high speed networks. Over the period of last thirty years, the price of microprocessors and communications technology has constantly reduced in real terms. = Because of this, the distributed computer systems appeared as a practical substitute to uniprocessor and centralized systems. The networks of computers are present all ove. Internet Is composed of many networks All these networks separately and in combination as wel, share the necessary characteristics that make them pertinent topics to focus Under distributed system, 1.2.6.1 Definition = Acomputer network is defined as a set of communicating devices that are connected together by communication links. These devices include computers, printers and other devices capable of sending and/or receiving information from other devices on the network. These devices often called as node in the network. So computer network is Interconnected set of autonomous computers. — A distributed system Is defined as set of autonomous computers that appears to its users as a single coherent system ~ Users of distributed system feel that, they are working with a single system. Following are the main characteristics of distributed system. 1. A distributed system comprises computers with distinct architecture and data representation. These dissimilarities and the ways all these machines communicate are hidden from users 2. The manner in which distributed system is organized internally is also hidden from the users of the distributed system. 3. The interaction of users and applications with distributed system is in consistent and identical way, in spite of where and when interaction occurs. 4. Adistributed system should allow for scaling it 5, Distributed system should support for availability. t should be always available to the users and applications in spite of failures. 6. Failure handling should be hidden from users and applications. 1.2.6.2 Motivation Following are the objective behind buildin distributed system Resource sharing Computation speedup Reliability Communication 4. Resource sharing ~ Resource sharing offers saving in cost, One printer can be shared among many users in office instead of having ‘one printer to each individual user. There can be more saving in cost if expensive resources are shared Overview of 1. Network Operating System (NOS) if users have NOS installed on machine then they can elther access resources on other machine by remote login or transfer the data from remote machine to their own machine, Remote Login — Network operating system allows users to log in remotely. The Internet offers the telnet facility for remote login. NOS permit users to use services available on a particular machine in the network. Remote login service provided by NOS allows the user to log in remote machine from his/her terminal. = Using command for remote copy, user can copy the file from one machine to other. Remote File Transfer = NOS offer a mechanism for remote file transfer from one computer to another. Here, each computer has its own local file system. If a user working on computer A wants to access a file on another computer B, then the file must be copied explicitly from the computer B to computer A, File transfer protocol (FTP) is used for such transfer in internet environment. User invokes the FTP program as ftp name of computer B = After entering the correct username and password, user should connect to the right subdirectory to access the required file. Suppose user want to access the file abc.txt then this file must be copied from computer 8 to computer A by executing following command. get abe.tet = The location of file is not transparent to user. As file is only allowed to copy from one machine to other, many copies ‘exists which waste the storage space, The daemon process running on remote computer watches connection request ‘on FIP port and completes authentication of user. This daemon responds to the set of following predefined commands. 1, get : Transfer file from remote computer to local computer 2. put: Transfer file from local computer to remote computer. 3. Is ordir: List files in the current directory on the remote computer 4, ed : Change the current directory on the remote computer 2. Distributed Operating Systems (D0S) Ina distributed operating system, access to remote and local resources seems to be in the same way. Operating system controls the data and process migration from one site to another. (2) Data Migration (2) Computation Migration (3) Process Migration 1, Data Migration = User working on machine A can access data (such as 2 file) that reside at machine B. One method to data migration is to transfer the complete file to machine A. After this all access to the file s local. When the user need {s completed, a copy of the file ifit has been modified is sent back to machine B. = Although a small change has been made to a large file, all the data needs to be transferred. This method was used In the Andrew file system. This method of file transfer is inefficient. In other method of data transfer only those Portions of the file that are actually needed for the immediate task gets transferred. atest ‘When the user no longer = ifanother part of the file Is needed later on, jother transfer will si Reali sun va Wants», across the fle, any part of it that has been modified rmust Pe sent back t ote network file system (NFS) protocol uses this method, The Mierosot SMB protocol (running on FOP of ether rep, ‘or the Microsoft NetBEU! protocol) also ‘allows file sharing over 2 network, 2 Computation Migration = The computation rather than the data can be migration. if applications needs to access various large fl of those files. In this case, it would be mare beneficial an‘ reside and return needed results to the machine that initiated the computation me to execute the remote command, the remote transfer across the system. This approach Is called computa, Jes that reside at dfferent machines, to obtain a summa, d efficient to access the files at the machine where he, = If the time required to transfer the data Is longer than the t ‘command should be executed. Process Migration = Process migration involves transfer of process to other machine for execution purpose. The whole process, or portion of it, may be executed at different machines. The reason for migration is = Load balancing : The processes (or sub processes) may be dstributed across the network on different machines to balance the workload. = Computation speedup : The subprocesses of the single process can run concurrently on different machines then the total process turnaround time can be reduced. — Hardware preference : The particular process may need some specialized processor for execution. — Software preference : The needed software by process may available at only a particular machine, and elther the software cannot be moved, or is less expensive to move the process if the huge amount of data requires in the computation, it may be more efficient to have a process = Data access run remotely than to transfer all the data Difference between Distributed OS and Network OS = Distributed operating system attempts to achieve complete transparency in order to offer a single system view to the user. Whereas achieving full transparency with network operating system is not possible, As we have seen for remote login, user has to explicitly log into remote machine, In remote copy user knows the machine to which he/she s copying the files. The main advantage of network operating system is that It provides scalability. WE ae Distributed 05 (005) Network OS(NOS) — Degree of transparency is very high for multiprocessor OS. Degree of transparency is low. 1 = Degree of transparency is high for multicomputer OS a ‘Same operating system Is present on all nodes in both cases Operating system on different nodes is (Multiprocessor OS and Multicomputer OS). different. = As multiple processors present in single machine, number of copies | As multiple machines are preset of multiprocessor OS is one. multiple (n) copies of NOS are required 3. - As multiple machines are present multiple (n) copies of multicomputer OS are required. : = 6 ele in network OS, basis for communication Processors share the memory to communicate with each other. _| Is files. = In-case of multicomputer OS, Many machines communicate with ‘each other by passing the messages. Message passing Is basis for ‘communication ‘n-multiprocessor OS basis for communication is shared memory. Th network OS resource management is =n multiprocessor OS resource management is global and central. per node. Hence it is easy to scale the = Inmulticomputer OS resource management is global and distributed es system. —rrmultiprocessor 05 there is no scalability as single machine in | Network operating system offers the 6 le processors are presents scalability. = _ Multicomputer 0S supports for moderate scalability. 7 ‘Both multiprocessor OS and multicomputer OS are not open. ‘Network operating system is openness. ‘These OS are developed to optimize the performance. Modern operating systems are built with microkernel design 1.2.7 Real time Systems For Real time operating systems time constrains are a key parameter. If the completion of particular task should happen in given time constraints or action completely must take place at a certain instant (or within a certain range), we havea hard real-time system. Ina soft real-time system, the missing of an occasional deadline is acceptable. Digital audio or multimedia systems are the examples of this class, VxWorks and QNX are the well-known real-time operating systems. Each task should be ‘completed within the associated deadline to that task and missing a deadline can cause affects ranging from undesired to catastrophic. ‘The embedded systems are becoming more multifaceted and complex today. Also these systems will affect our life with more involvement. This means they will bear more and more responsibilities on their shoulders to solve real time problems to make our life easier. So real time operating system needs to be effective to manage more complex real time applications. Real time Operating Systems must respond quickly. These systems are used in an environment where a large number of events (generally external) must be accepted and processed in a short time. Real time processing necessitates quick dealing and characterized by providing instant response. For example, 2 measurement from @ petroleum refinery indicating that temperature is getting too high and might demand for immediate attention to avoid an explosion. In real time operating system swapping of programs from primary to secondary is not frequent, Most of the time, processes remain in primary memory in order to provide quick response, therefore, memory management in real time system is less demanding compared to other systems. ‘The primary functions of the real time operating system are Management of the CPU and other resources to fulfill the requirements of an application, Synchronization with and responding to the system events. Efficient movement of data among processes and carrying out coordination among these processes. 20 00 0 Along with the primary functions discussed, there are also secondary functions which plays important role in improvement of the performance. © Efficient primary memory management © Tooffer an restricted access to the computer resources. 1. Systems controlting 2. Immediate updating offering systems: 3, Systems giving information In minuets ‘about stock prices: 4. RADAR. 5. Reservation system for Airlines. 8 Mobile OS soble operating systems used for phones tablets and or some other mobile devices. , = personal Digital Assistants (PDAS), for example palm and pocket Ps and cellular ane o ranches aytems, several of such system uses spect purpose embedded Fe cual nes having small size and have @ ‘small amount of memory, slow processors, ‘and small display screen: ys memory size of these devices is between 512 KB ‘and 128 MB. Therefore It is 3 Job of operating system and applications to ‘manage memory efficiently. ‘A second concern to developers of handheld devices Is the speed of the processor used in the devices, Handhelg ed more powel. 50 it is obvious thay, processors ne for battery, Therefore most handheld device ting system and applications must be 1.24 devices require faster processors with compare to PC. Faster handheld devices require large battery size and will occupy more space se smaller, slower processors that consume less power. As a resull, the opera designed not to toll the processor. 1.2.8.1, Android OS ‘Android’ operating system combines open-source code with closed source third-party applications. Android Oper Source Project (AOSP) ls open source part of the operating system and Is totally open and free to be used and modified by anyone, The main goal of Android is to support a rich third-party application for applications to run against CDD (Compatibility Definition Document) 5 The requirement for compatible Android device is, which needs a stable defines the way environment, implementation and API the Android must act to be compatible with third party application: specified in CSS. Following are design goals of Android To offer a full open-source platform for mot system stack To offer strong support for proprietary third-party applications with a robust and stable API. Maintaining the open source and stable platform is challenging adequate for proprietary third-party applications arty applications, including those from Google, to compete on a level playing field bile devices. The open-source part of Android is a bottom-to-top operating = Topermit all third To offer the user an application security model, preventing them to trust on third-party applications. The operating system should provide the security to the user from misbehaviour of applications, including crash and misuse of the device and the user's data on it Making mobile and user interaction easy and efficient by paying short amounts of time in many apps. User should e& facility for quick interaction with all the applications. For example, quick look at new received email, receiving 2r4 sending an SMS message etc Ail application processes of users should be managed in such a way that, they do not have to worry about clos applications when after using them. It is possible for OS to fail as applications requires more RAM which Is P% available in device. So OS should be able to close and start applications as per requirement. Support applications to interoperate and collaborate in rich and secure ways Creating the general purpose operating system just like desktop operating system. e wa 1m 4.2.8.2 Androld Architecture The Androl organized a lyre architecture as shownin Fig. 2.21 Overview of Operating System Fig. 1.2.1 : Android Architecture Each layer includes many program components as described below. The services offered by each layer is different from other layer and each layer offers different types of services. Applications Applications in this layer are implemented in java language. The various applications are : Dialer, SMS/MMS, IM, Browser, Camera, Alarm, Calculator, Contacts, Voice Dial, Email, Calendar, Maps, Media Player, Album, Clocks and many more. Application Framework As source code of Android is publically open, developer can build rich and innovative applications. The framework API Used by core application, can be accessed fully by developers of applications. It is also offered that, any application can use the capabilities published by other application, thereby simplifies the reuse of components. Following are the components of this layer. ‘Activity Manager : It performs function of management of lifecycle of applications and offers a common navigation backstack Window Manager : The job of window manager is to manage window surface. Organizing screen layouts, locating drawing surface are some of the activity performed by window manager View Manager : Viewing the window is the function of view manager. Contents Manager : Facilitates the applications to access data from other application or to share their data Notification Manaj : It sends the notifications. For example we get notifications if battery goes low. Programmer an also provide implementation that allows the application to display customer alerts in status bar Package Manager : ‘manages other packages if it has instant in machine. Telephone Manager : It handles receiver call or voice calls. Resource Manager : It offers access to non-code resources such as Graphics localized string and layout files. Location manager: It finds location of mobile devices. Ex Map, GPS, or cell tower. XMPP service Manager : Manages the services on mobile devices such as ringtones, music application, browsers etc. ¥ ‘Operating System (MSBTE) Overview of Operating System 1.2.8.3 10S iPhone OS Is developed by Apple Inc. and itis a mobile operating system. = Inthe year 2007, 10S was released which included iPhone and iPod Touch. = Inevery year, at least one version of iPhone and iPad Is launched by the company. = The IOS SDK has evolved from 1.0 to 6.0. |OS 6.0, the latest SDK Is the only offically supported version in Xcode 4.5 and higher. = In iPhone OS, each application Is made up of one or more threads, which represents a single path of execution. Every applications starts with a single thread, which runs the application's main function. The applications can have ‘additional threads with executes a specific function. - Each thread has its own execution stack and the kernel schedules its run time separately. As threads are in the same process space, they can communicate with other threads and processes. = Most device drivers never need to take primary interrupts because their interrupt lines don’t cascade into the system's Interrupt controller. = The iPhone OS provides tools for system profiling. The Shark application lets user selectively find out what file system- ‘elated function calls the application makes. When user set up the session configuration, he can tell Shark exactly which function calls you want it to watch. A list of system calls includes all the file /O calls plus fentl, flock, fstat, fsync, link, Istat, Istatv, and stat = iPhone has no garbage collection, developer has to clean up the variables after use them, otherwise the program will leak memory. Though NSObject class has accounting stuff help to keeps the track of how many other objects are currently using the object, but It is not automatic and developers have to adjust that by themselves: ~ iPhone do not have the power management toolkit as Mac OS does. The iPhone OS security implementation includes a daemon called the Security Server that implements several security protocols, such as access to keychain items and root certificate trust management. The Security Server has no public API. Instead, applications use the Keychain Services API and the Certificate, Key, and Trust services API, which in turn communicate with the Security Server. 1.2.9 Difference between Time Sharing System and Real Time System Multiple users are permitted by time shared operating | For Real time operating systems time constrains system to share the machine at the same time. Time shared | are a key parameter system Is capable of completing each action or command in a very less time. A particular user program executes in allocated time by | Ifthe completion of particular task should happen system and after expiration of slot, system gets allocated to | in given time constraints or action completely other user program. So the allocation of computer | musttake place at a certain instant, we have a 2, _| resources in time slots to several programs simultaneously | hard real-time system. In a soft real-timesystem, {sin time sharing manner. the missing of an occasional deadline is acceptable. [ machine exclusively. ‘of multiple users logged in same server. The resources in server machine like CPU gets allocated to each user on time sharing basis giving the feeling to each user that only he or she Is using the server Consider the example These systems makes use of CPU scheduling and multiprogramming to offer each user with 2 small quantum of time slot to carry out the designated work... Many users ‘ean share the resources of computer system at the same time. gial ucla or mutinedia Ssems are ‘examples of this class. h task should be completed within th, Eact associated deadline to that task and missing , deadline can cause affects ranging fron, undesired to catastrophic The development of time sharing system was aimed to offer ‘an interactive utilization of the computer system to its user This Is aimed to work in real time environmen line is important where keeping the deadil Sar Today all modern OS are time sharing OS VaWorks and NX are the well-known real-time ‘operating systems. ¥ ‘A computer running more than one program at @ In multitasking, tasks shares 1.2.10 Difference between Multiprogramming and Multitasking Multitasking Poe 1s the common resource ie 1 time is called as multiprogramming CPU. Process manager implements the process Multitasking operating system allows the execution of ‘management functions. in multiprogramming, single | multiple processes simultaneously Multiple tasks are 2, | €PU 1s shared among many processes, It many managed and handled at the same time. For example * | processes remain busy in completing 1/0, CPU Is | UNIX, Windows 2000 are multitasking operating systems allocated to only one process at a given point of time. The idea behind multiprogramming is that CPU does | In multitasking, several tasks are performed in parallel not remain idle. When 1/0 is going on for one | Although we say so but practically no two tasks on # , process or context switch occurs then CPU gets | single processor machine can be executed . allocated to other process. simultaneously. In fact, CPU switches from one task t0 the next task so quickly that appears as if all the tasks ar executing at the same time oe 1.3 Command Line Based Operating System 4.3.1. DOS (Disk Operating System) = MS DOS is Microsoft Disk Operating System. It is single user, non-graphical line-oriented command or menu-stv=" operating system. It has simple interface but interface is less user friendly. tom 25, Overview of Operating System ‘The different versions of DOS which is available are 2.0, 3.0, 32, 4, 10.5YS and COMMAND.COM are three system files of DOS, CONFIG.SYS and AUTOEXEC.BAT are the user configuration files. 10.5¥S file contains the device 1/0 routines for management of 1/0 devices and the system initialization routines. 10.5Y5 file ls Input/output system file of DOS, This program offers Interface between the hardware devices and software of the system. DOS kernel actually resides In MSDOS.5YS file and offers all of the support functions needed to application programs. This fle contains the file management and the disk buffering management capabilities. It keeps track of all the disk access of an application 5.0, 6.0, 6.2, 6.22, 7.0, and 7.2. MSDOS.SYS, program and remains permanently in memory. COMMAND.COM Is a command interpreter which displays the system prompt. it executes command typed in by the user and handles user interface. Device drivers are loaded when operating system takes control of the computer. ng operating system for running special devices. ‘These device drivers are required for config CONFIG.SYS file contains reference to device drivers. When system is booted, this file automatically gets executed, Keys, paths to search files and messages to display on screen are defined using this file. Operating system executes ‘command in this file each time the system is started. Following are some of the features of DOS ‘Single user OS and permits execution of one task at a time. It offer command user interface. ‘Two types of commands (internal and external commands) are present Supports three executable files EXE files, COM files and BAT files Supports for hierarchical directories. It is written completely in 8086 assembly language. File name is supported in two parts, primary name and secondary name DOS facilitate the computer system to carry out input and output operations 1.3.1.1 Directory Structure In DOS DOS permits for grouping related files together in directories. When we format disk, the ROOT directory is created by DOS. ROOT directory is main directory on a disk and denoted by \ (a back slash) Other directories are created in the ROOT directory. Itis possible to create directory within the directory and each can contain a number of files. The directory structure Is like an inverted tree structure with the root at the top branching ‘down into lower layer directories and subdirectories. Each entry of directory consumes 32 bytes as shown below. The first byte of file name represents code indicating entry Is subdirectory, File is never used, or File Is used but now deleted. Entry in file attribute byte indicates either file is read ‘only, hidden, volume label, subdirectory, system file or archive bit. Byte size Content 8 _| Primary name of file 3 | Extensionname Following Fg. 1.3.1 shows layers In UNIK ayster” Inardware 1 it consists of the $ fig disks, terminals, and a _» pther devices, UNIX operating systom + It's function le to control the hardware and 9 omy) modo available a system call Interface to all the programs. These system calls ‘user programs to create, delete . es filos, and other Fig. 1.3.1 : Layers tn UNA wystorn resources, Standard library : Programs Isues a trap instruction to switch from user mode to Kernel robe arid makers a £/3!e0n ag by putting argument In stack or register, Library contains procedures implemented in avernbily langvaye (OF thay system call Standard utilities : These programs are invoked by users while working, on tereninal, It includes the editors, text processing programs, and file manipulation utilities. W, Cnrehee, User All the users Interacting with system. There are three interfaces, that Is, true system call Interface, the library Interface, and the Interface forrnied by the wwe of standard utility programs. 1.3.2.3 The UNIX Shell ~ In UNIX command line interface Is called the shell, Bourne shell (sh ), ksh , bash are the exarnples of the shel = Here we will discuss the bourne shell. When the shell starts up, it initialize itself, then types a prompt character, often @ percent or dollar sign, on the screen and waits for the user to type a cornmand line ~ When the user gives command by using command line, the shell removes the first word from it. After extraction of thes first word, the shell assumes that, Its the name of a program to be run, Then it finds this program, anc f found, & eure the program. ~ Until the program terminates, shell suspends itself, at which time it attempts to read the nem command. The ch Just a simple common user program having capability to read from and write to the terminal, and the power tn roe other programs. Following Is the description of bourne shell 1.3.2.4 UNIX Utility Programs = Apart from the shell, user interface to UNIX consist of a large number of standard utility programs. These #¢ Smtegorized 25 fle and directory manipulation commands, fiters, program development tools such 2 compilers, text processing, system administration and last is miscellaneous wt The POSIX 1003.2 standard denotes the syntax and semantics many of these, primarily in the fi nree categories ~ _ The reason behind standardizing them is that, anyone should be work on all UNIX systems, = In addition to these standard utilities, viewers, etc. = ——™ Zs able to write shell scripts that use these programs 2% f here are many application programs 2s wel, such as web browsers, malt sn a a a a |= Following are the some of the examples of utility programs and its use : Concatenate multiple files to standard output. chmod _| Change file protection mode. @ Copy one or more files. cut Cut columns of text from a file. grep _| Searchaa file for some pattern. head | Extract the first lines of a file. Is List directory make | Compile files to build a binary. mkdir} Make a directory od Octal dump a file. paste | Paste columns of text into a file. | pr Format a file for printing rm Remove one or more files. rmdir | Remove a directory. sort Sorta file of lines alphabetically. | | tail Extract the last lines ofa file. | tr Translate between character sets. | Following are some examples of these programs, starting with file and directory management. cpabe xyz Copies file abc to xyz, leaving the original file intact. In contrast, mv abe xyz Copies abc to xyz but removes the originalcat concatenates the many files. it reads each of its input files and copies them all to standard output, one after another. Files can be removed by the rm command. The chmod command allows the ‘owner to change the rights bits to modify access permissions. Directories can be created with mkdir and removed with ‘rmdir. slits the list of the files in a directory. 1.3.2.5 Information, File, Process / Memory Management Overview ~The kernel of the UNIX is divided in mainly two parts : ‘© Information Management ‘© Process Management 4331 Overview of Fig. 1.3.2 : Various UNIX modules and relations among them 1.4 GUI Based OS 1.4.1 Windows History = By taking inspiration from the user interfac (shell) that it called Windows. Windows 1.0 released and it was failure, -e of the Apple Lisa, the forerunner to the Apple Macintosh, Microsoft gave MS-DOS a graphical user interface = Windows 2.0 was designed for the PC-AT and released in 1987, was not succeed. Windows 3.0 for the 386 (released in 1990), and especially its successors 3.1 and 3.11, caught on commercial successes. = Allofthese early versions of Windows were not true operating systems. Windows 95 released in August 1995 still had the features of MS-DOS included. = After Windows 95, which had done very well and became successful shown the way for development of further versions : Windows 98 and Windows Me.? = By the late 1980s, Microsoft came to the conclusion that constructing a modern 32-bit operating system on top of MS- DOS certainly was not the beneficial way to go. In 1989 Microsoft made appointment of Dave Cutler, who was responsible for development of very successful RSX-11M and VAX/VMS operating systems at DEC (Digital Equipment Corporation). Cutler's contract was to build up a modern OS, which was portable to architectures except the Intel x 86 families, and so far compatible with the 0S/2 system and portable UNIX standard, POSIX, At that time, Microsoft was developing 05/2 in cooperation with IBM. This system was named NT (New Technology). = The release of first version of Windows NT 3.1 Is done in 1993. It has implemented identical GUI as Windows 3.1 and the follow-on to Windows 3.0. Windows NT 3.1 was a new 32-bit OS with the capability to support older DOS and Windows applications in addition to offering 0S/2 support. = Anumber of versions of NT 3.x pursued with support for further hardware platforms. Again in the year 1996, Microsoft made NT 4.0 publically available with the similar user interface as Windows 95. Extension to the NT 4.0, Microsoft ‘Dynamic device support : A PC could abruptly be connected to or disconnected from a complete set of peripherals. In ‘a modern PC, the situation has totally changed. The design of PC’s allows users to plug and unplug a huge host of peripherals constantly. Some examples are external disks; thumb drives, cameras, and the like are continually coming and going. Following are some of the features of Windows OS : ‘thas builtin and improved version of disk operating system. Large number of virtual device drivers are present in Windows for various devices Graphical user interface. thas Plug and play capabilities. Different icons for application, documents and program and other objects are provided. Easy internet access, multitasking, expansion of memory limitations, online support. ° 6 9 0 of ag Various fonts and styles of different languages are supported. © Data transfer can be done from one application to other using clipboard 1.4.1.1 Windows System Components, 1 Windows architecture follows a layered system approach of modules as shown in Fig. 1.4.1. The major layers are the HAL, the kernel, and the executive. All of these layers run in kernel mode, and a group of subsystems and services run in user mode. The subsystems that run in user mode are classified as the environmental subsystems which imitate distinct operating systems, and the protection subsystems, which offer security functions. The benefit of such layered architecture is that communications between modules are kept straightforward. Hardware Abstraction Layer : The major goal of Windows 7 was to build the operating system which would be portable across platforms. The HAL is responsible for hiding dissimilarities in hardware chipset from upper levels of the ‘operating system. Kernel : Following responsibilities are handled by kernel layer © Scheduling of threads © Low-level processor synchronization (© Interrupt and exception handling ‘© Switching between user mode and kernel mode Executive © The executive is the upper portion of the opera ting system. It is written in C and is architecture independent. The executive consists of ten components, each of which is just a collection of procedures that work together to accomplish a certain task. © These components are object manager, I/O manager, process manager, virtual memory manager, security reference monitor, cache manager, plug-and-play manager, power manager, registry and booting, advanced local procedure call facility. 135 Overview of Operat Giferent Gus (GNOME and KOE) have also been written for Linux. Several Linux features such as system cals, ‘programs, libraries, algorithms and internal data structures are very similar to those of UNI. ~ Even though Unux does not use a microkemel design, It accomplishes many of the potential benefts ofthis approach bby wens of hs particular modular architecture. Linux ls designed as a collection of modules, a number of which ean be dynamically loaded and unloaded, These relatively independent blocks are referred to as loadable modules. A module isan object fle whose code can be linked to and unilnked from the kernel at runtime. Normally, a module Implements some definite function, such as a file system, a device diver or some other feature of the kernel's upper layer. A ‘module Is executed in kernel mode on behalf of the current process. Hence, even though Unux may well thought-out to be monolithic, its modular structure conquers some of the ‘compleaities in developing and building the kernel 1.4.22 Features of Linux = Itls free and open source os. Supports Graphical User interface (GU!) that is X Window System, ~ _Unux's available in several languages, and supports most of custom keyboards as per the languages used worldwide ~ _ Ithas multiple application supports that can be downloaded from repository ~ _Itsupports multiple users, multithreading, multitasking and networking as wel. ~ _Unux is portable and can be installed on any machine 1.4.2.3 Components of Linux ~The Linux system comprises mainly three bodies of code, similar to most traditional UNIX implementations Kernel : It keeps all the important abstractions of the operating system, together with things as virtual memory and processes, System libraries : It defines a standard functions through which applications can interact with the kernel, Most of the operating-system functionality is Implemented by these functions. This functionality does not need the full rights of kernel code System utilities : These are the programs that carry out individual, specialized management tasks For initialization and configuration of some characteristic of the system, some ulllties need to be invoked only once Many other utilities run permanently and called as daemons. Some of the tasks handled by these daemons are ‘© Responding to incoming network connections (© Accepting logon requests from terminals ‘© Updating the log files. In Unux design, a microkernel design approach is not used. However it has a particular modular architecture from which it accomplishes many of the possible advantages of microkernel approach. Linux is contains a set of modules, many of which can be dynamically loaded and unloaded as per the need. These modules are called as loadable ‘modules. A module is considered as object file. ~The linking and unlinking of these modules code can be done with kernel at runtime, The implementation of module Offers some definite function, for example a file system, a device driver, or some other characteristic of the kernels higher layer. A module does not execute in user mode. Wrote 336 Overview of, ~ In fact it is executed in kernel mode in aid of the current process. Consequently, even though Linux design reflects ‘monolithic architecture, its modular structure conquers some of the trouble in developing and evolving the kernel = Following are the two important features of the Linux loadable modules : ‘Dynamic linking : When the kernel is currently running in main memory, a kernel module can be loaded and linked Into the kernel. in the same way, unlinking of module can be done and replaced from memory at any time. Stackable modules : There is hierarchical organization of modules. Individual modules provide services as libraries if invoked by client modules upper in the hierarchy, and as clients when they reference modules further down. 1.__| DoS only supports for single tasking. Windows OS is multitasking. DOS uses CLI (command line interface) | windows supports GUI (graphical user interface. 3._| Itisa single user 0s. Itis a multi user OS. 4. _| Iisa single threading OS. {tis a multithreading OS. 5._| Itdoesn't supports the networking. It supports the networking. 6._| Less user friendly with compare to Windows. More user friendly with compare to DOS. 7.__| DOS uses FAT 26 file system Windows uses FAT 32 file system 8.__| DOS supports 2 GB of maximum partition size Windows supports 2 TB or more partition size. Difference between GUI and CUI cur CUI stands for Character User Interface GUI refers to Graphical User Interface. a,_| User interacts with computer using mouse | Keyboard is needed to type commands in order to interact with the computer. 3._| Navigation is easy. Navigation is not easy _ 4 [we deal with graphics and other visual clues. We deal with text only. 5._| itis more user friendly. Itis less user friendly fires Modern operating systems are GUI base | Modern OS does not use CUI 7.__| Example of GULis Widows Os. | bos is the example of CUI Advantages of Linux / UNIX over Windows Following are the advantages of Linux/UNIX over Windows ~ UNIX has more flexibility and run on types of architecture, together with main-frame computers, supercompute’s* micro-computers. ~ _ UNIX and Linux offers more stability and does crash as frequently as Windows does, therefore of less adminis ‘and maintenance requirement is not as much of Windows. ae ats ee ee UNIX and Linux include more security and access right features than Windows. CHAPTER Services and Components of Operating System 21 _ Different Services of Operating System. 22 System Calls- Concept, Types of system calls 2.3 OS Components : Process Management, Main Memory Management, File Management, VO System Management, Secondary Storage Management, 2.4 Use of Operating system Tools- User Management, Security policy, Device management, Performance Monitor, Task Scheduler. 2.1 __ Different Services of Operating System Following are the six services provided by operating system for efficient execution of users application and to make convenience to use computer system 1. User interface 2. Program Execution 3. 1/0 Operations 4. File System Manipulation 5._Communications 6._Error Detection 1. User Interface ‘Almost all operating systems have a user interface (Ul). Two fundamental approaches for users to interface with the ‘operating system are command-line interface and graphical user interface or GUI. Command interpreter executes next user-specified command. A GUI provides a mouse-based window and menu system as an interface. 2. Program Execution The operating system provides an environment to run users programs efficiently. The resources needed to the Programs to complete execution are provided by operating system ensuring optimum utilization of computer system Memory allocation and deallocation, processor allocation and scheduling, multitasking etc functions are performed by operating system. The operating system has all rights of resource management. User program does not given these rights. 3. 1/0 Operations ach Program requires cannot produce output without taking any input. Ths involves the use of /0. During execution, Program requires to perform /0 operations for input or output. Until 1/0 is completed, program goes in waiting state. Vo can be performed in three ways Le. programmed /0, Interrupts driven /0 and 1/0 using DMA. The underlying Services & of hardware for the 1/0 is hidden by operating system from users. These I/O operations make it convenient to execute the user program. Operating system provides this service to user program for efficient execution. 4, File System Manipulation Program takes input, processes it and produces the output. The input can be read from the files and produced output again can be written into the files. This service is provided by the operating system. All files are stored on secondary storage devices and manipulated in main memory. The user does not have to worry about secondary storage management. Operating system accomplishes the task of reading from files or writing into the files as per the ‘command specified by user. Although the user level programs can provide these services, itis better to keep it with operating system. The reason behind this is that, program execution speed is fundamental to 1/0 operations. 5. Communications During execution it is required that, the processes running on the same machines or different machines needs to ‘communicate. If the communication is across different machines, messages transit through network. It can be ‘achieved through user programs by customizing it to the hardware that helps in message transmission. Users ig the service interface to operating system to achieve communication among programs can be customized by offe processes in distributed system. Operating system kept this service with it to relieve the user program from taking care of communications. Error Detection To avoid the malfunctioning of the complete system, the operating system constantly monitors the system for detecting the errors. If these privileges would have been given to user programs, most of the user program time ‘would have elapsed in this activity leading to performance degradation. Operating system needs to perform serious tasks during this process. Serious task includes deallocation of many resources such as processor, memory etc. Again these tasks are too critical to be handed over to the user programs due to possibilities of disturbing the normal operation of operating system. 2.2 _ System Calls 2.2.1 Concepts The interface between OS and user programs is defined by the set of system calls that the operating system offers. System call is the call for the operating system to perform some task on behalf of the user's program. Therefore, system calls make up the interface between processes and the operating system. The system calls are functions used in the kernel itself. From programmer's point of view, the system call is a normal C function call. Due to system call, the code is executed in the kernel so that there must be a mechanism to change the process mode from user mode to kernel mode. In the UNIX operating system, user applications do not have direct access to the computer hardware. Applications first request to the kernel to get hardware access and access to computer resources During execution when application invokes a system call, itis interrupted and the system switches to kernel space. The kernel then saves the process execution context of interrupted process and determines purpose of the call, The kernel warily makes sure that the request is valid and that the process invoking the system calls has sufficient privilege. Some of the system calls can only be invoked by a user with super user privilege. 23 Services & of Ifthe whole thing is fine, the kernel processes the request in kernel mode and can access the device drivers in charge of controling the hardware. The data of the calling process can be read and modified by kernel, as it has access to memory in user space. But, it will not execute any code from a user application, for clear security reasons. When the kernel finishes the processing of request, it restores the process execution context that was saved when the system callwas invoked. After this, control returns to the calling program which persists executing. SPACE: Application and Libraries = Fig. 2.1.1: The kernel ‘As shown in Fig. 2.1.1 the kernel is @ central module of most computer operating systems. Its main responsibilities are to: ‘Act as a standard interface to the system hardware : For example, while reading a file, application does not have to be aware of the hard-drive model or physical geometry as kernel provides abstraction layer to the hardware Manage computer resources : As several users and programs shares machine and its devices, access to those resources must be synchronized. The kernel implements and ensures a fair access to resources such as the processor, the memory and the devices. Put into effect isolation between processes : The kernel guarantees that one process cannot corrupt the execution environment of another process. Any process cannot access the memory that the kernel has allocated to other process Implement multitasking : Each process gets the false impression that it is running without interrupted on its own processor. Actually, several processes compete constantly for system resources : the kernel keeps switching the active process for each processor behind the scene ‘There are two ways for the process to switch from the user mode to the kernel mode. These are Auser process can explicitly request to enter in kernel mode by issuing a system call During the execution of user process kernel can take over to carry out some system housekeeping task The kernel mode is both a software and hardware state. Modern processors offer a advanced execution mode, called 35 Supervisor Mode in which only kernel runs. The privileged operations are such as modifying special registers, disabling interrupts, accessing memory management hardware or computer peripherals. If itis not in supervisor mode, the processor will reject these operations. System calls take place in different ways, depending on the computer in use. Apart from the identity of the desired system call, more information is needed. The precise type and amount of information differ according to the particular Operating system and call. Consider the example of getting the input. We may require specifying the source, which can be file or device. We also need to specify the address and length of the memory buffer into which the input should be read. The device or file and length may be implicit in the call. 2-4 cite Parameters can be passed to the operating system by following three different ways ‘~ Pass the parameters in registers. = Ifthere are more parameters than registers, then the parameters are generally stored in a block, or table, land the address of the block is passed as a parameter in a register. Ths isthe approach taken by Linux and Solaris, memory, = Program can place the parameters onto the stack which then popped off the stack by the operating system, ‘Some operating systems favor the block or stack method, because those methods do not limit the number or length of parameters being passed. 2.2.2 Types of System Calls ‘System calls are categorized in five groups. These are 1. Process control 2. File manipulation 3. Device manipulation 4. Information maintenance 5. Communications utes, set rocess control | end, abort, load, execute, create process, terminate process, get process a process attributes, walt for time, wait event, signal event, allocate and free memory 2 | File manipulation | create file, delete file, open, close, read, write, reposition, get file attributes, set fle attributes 3. | Device request device, release device, read, write, reposition, get device attributes, set device manipulation _| attributes, logically attach or detach devices 4. | Information Bet time or date, set time or date, maintenance get system data, set system data, get process, file, or device attributes, set process, file, or device attributes 5. | Communications | create, delete communication connection, send, receive messages, transfer status information, | attach or detach remate devices 2.2.3 Some Examples of System Calls 1. Open : Open system call request to the operating system for using a file. The files path is used as argument to specify 2, Close : Close() informs to the operating system that file with said file descriptor 3. the file. The ‘flags' and 'mode' arguments to this call specifies the way of using the file. On successful approval by operating system, it returns a “file descriptor” which is a positive integer. Returning of value-1 indicates denial of access to file and "errno" needs to be checked to get reason of denial. used, After this, same file descriptor can be reused by operating system. itabe Read : Read) specifies to the OS the number of (size) bytes to read from the file opened in file descriptor specify to put these bytes into the location pointed to by "buf". The return value is number of bytes actually read or gs 2. Services & Cor of Operat 4, Write : Write() is similar to read{) system call, only it writes the bytes instead of reading them. It returns the number of bytes actually written, which is almost invariably "size". 5. Create process : During the execution process can create new process by using create process system call. The process which creates new process is called a parent process, and the new processes are called the children of that Process. Newly created processes may in turn create other new processes, creating a tree of processes, 2.3 _ Operating System Components Components of operating system are discussed in following sections. 2.3.1 Process Management — Aprogram or appli ion under execution is called as process. A process includes the execution context. ~ Aprogram resides on the disk. On disk it does require any resources. - _ Aprogram gets executed in main memory. So it should be transferred from disk to memory. ~ To complete execution, program needs many resources and competes for it. These resources are memory, CPU, files ete, Now it becomes process, From the computation context point of view, a process is defined by CPU state, memory contents and execution environment Process manager implements the process management functions. ~ _ Inmultiprogramming, single CPU is shared among many processes. ~ _ Hfmany processes remain busy in completing I/O, CPU is allocated to only one process at a given point of time. ~ Here some policy is required to allocate CPU to process, called as CPU scheduling ~ If multiple users are working on the system, operating system switches the CPU from one user process to other. — User gets the illusion that only he or she is using the system. Process synchronization mechanism is required to ensure that only one process should use critical section, — Process communication and synchronization, deadlock handling, suspension and resumption of processes and creation and deletion of the processes etc. are some of the activities performed in process management. Program counter contains address of the instruction from which execution resumes after context switch involve The process management acti 1. To provide control access to shared resources like file, memory, I/O and CPU 2. Control the execution of user applications. 3. Creation, execution and deletion of user and system processes. 4, Resume a process execution or cancel it. 5. Scheduling of a process. 6. Synchronization, interposes communication and deadlock handling for processes, 2.3.2 | Main Memory Management = Memory is an important resource of the computer system that needs to be managed by the operating system. To execute the program, user needs to keep the program in main memory. ~The main memory is volatile. Therefore, a user needs to store his program in some secondary storage which is non- volatile, ee SS ~ Every process needs main memory since a process code, stack, heap (dynamically-allocated structures), and dat; (variables) must all reside in memory. = The management of main memory is required to support for multiprogramming. Many executables processes exist in main memory at any given time. Different processes in main memory have diferent address space. Memory manager is the module of the operating system responsible for managing memory. — Programs after completion of execution move out of main memory or processes suspended for completion of /0 can bbe swapped out on secondary storage to free the main memory for other processes. — New processes are required to be loaded in main memory. If available main memory is sufficient to hold all processes swapping between main memory and secondary memory is done. — Memory managers move processes back and forth between memory and during execution. So it is required tha ‘operating system should have some strategy for the management of memory. — The memory management activities handled by operating system are 1. Allocation of memory to the processes. 2. Free the memory from process after completion of execution. 3. Reallocation of memory to a program after used block becomes free. 4. Keep track of memory usage by the process. 2.3.3. File Management = Following are the necessities for long term information storage : ‘© Itmust be possible to store a very large amount of information, © The information should loss after termination of the process using it © Several processes must be able to access the information simultaneously. ~ _Imorder to fulfil the above requirements, it is necessary to store information on disks and other secondary storage it units called files. ~ Afile is a named collection of related information that is recorded on secondary storage. The data cannot be wrtter directly to secondary storage unless they are within a file. Processes can then read information from the file. It also can write new information into the file if needed. ~ _ After process termination, information in file should remain retained and should vanish. A file should only vanish when its holder clearly removes it. Operating system manages the files. File system describes how files are structured named, accessed, used, protected and implemented. The file management activities of operating system consist of : 1. Creation and deletion of files and directories. 2. Provide access to files and allocation of storage space for files. 3. Maintain back-up of files. 4. File Security. 5. Providing the primitives for manipulating files and directories. 27 Services. its of 2.3.4 VO System Management ‘As we know that I/O is one of the main functions of an operating system and is used to control the entire computer's Inpur/output devices. — _ Basically it should have to issue commands to the devices, catch Interrupts, and handle errors. = _ Itshould also provide an interface between the devices and the rest of the system that is simple and easy to use. = The I/O represents a significant fraction of the total ‘operating system. Computers operate with many kinds of devices. — _Aswe know that it includes storage devices (disks, tapes), transmission devices (network cards, modems), and human- interface devices (screen, keyboard, mouse). = Following are the components of 1/0 ‘subsystem. 1. Buffering, Caching, and ‘Spooling which are memory management components. 2. Device driver interface. 3. Drivers for specific devices. 2.3.8 Secondary Storage Management — Main memory is volatile, Storage devices and 1/0 devices are used in computer system. Storage devices (disks, tapes), transmission devices (network cards, modems), and human-interface devices (screen, keyboard, mouse). ~ Two main types of storage technology used today are magnetic storage and optical storage. Primary magnetic storage devices are : Diskettes, Hard disks (both fixed and removable), High capacity floppy disks, Disk cartridges, and Magnetic tape — Primary optical storage devices are : Compact Disk, Read Only Memory (CD ROM), Digital Video Disk Read Only Memory (DVD ROM), CD Recordable (CD R), CD Rewritable (CD RW), Photo C ~ The hard disk is used as main storage device in your computer system. It is magnetic type of storage device. — Within one hard disk unit, many physical disks are present. Each disk is known as a platter. = Several metal platters are present within the hard disk and these are coated with a special magnetic material ~The platters rotate many thousands of times within a second for accessing the data, Magnetic read and write head are resent which just above the surface of the platter. ~ Material used for making the platters is aluminium, glass, or ceramic and two read/write heads are present, one for upper and lower surface. ~ Platters are arranged in stack because of which the position of the read/write heads often is referred to by its cylinder. ~ Cylinder is the location of a single track through all platters. Due to disk cache mechanism, time required to read from and write to hard disk is improved. ~ _Now days itis the part of hard disk. Hard disk can be partitioned, and each partition can be used as separate drive ‘Storage capacity of hard disk can be in gigabyte or terabytes, ‘The device management tasks include : 1. To open, close and write device drivers, 2. Communicate, control and monitor the device driver. a 2A Uso. Operating systemTools 2.4.1 User Management There are 3 types of accounts present in UNIX operating system, 1, Root : This account belongs to system administrator. This is also called superuser. Superuser has permission to run any command, 2. System Accounts : This account is required for system related components. For example, email and sshd accounts. 3. User Accounts : These accounts belong to users and group of users, General users have these accounts and these users have limited access to system files and directories. Following are four user administration files : = Jete/passwd : This file holds information about use accounts and password Jetc/shadow : This file keeps encrypted password of corresponding account /etc/group : This file holds group information for each user account. ~ _ Jete/gshadow : It contains secure group account information. Following commands are used to create and manage user, group accounts Use of command 1 useradd To add user accounts to the system | Bi usermod ‘To modify accounts attributes | 3 userdel To delete user account from the system __| 4 groupadd To add groups to the system 5 ‘groupmod To modify group attributes i 6 ‘groupdel To remove groups from the system __ | root@litmust sudoaddusernyz ‘itaus@liteus:-S sudo adduser preeti |sudo} ee for litmus: Fry, in sudo] password ew group, "oreati* 3001). fnew user ‘preeti’ (1001) with group “preeti home directory ‘/hone/preeti’ already exists. Noi copying fron * : warning: The hone directory * /hone/pr net Belong tothe user | ee ry fhome/preeti' does not belong to the user iter new UNDX password: ‘mew UNIX password: sued: aRsword updated successfully ing the user inforeation for preeti Fater the new value, or press EXTER w new value, oF press EATER for the default Room tunber Work Phone [J Howe Phone UJ: the tine information correct? {Y/nl itaus@Liteus:~$ | as To set the password for the newly created username 2. Tochange the password ‘To change the old password of the user that is already created use the following User management command Syntax Passwd The same in root will prompt you to change the root password. The other user's password can also be changed from the root, Iwill change the specific user's password and it won't ask the old password, since it’s a root, — =~ 3. Todelete a user account To delete a user account, use the following User management command Syntax userdel -r [username] Example “user a a Here, -r option is used to delete user along with the user’s home directory and mail spool /etc/passwd File The full user account information is stored in /etc/passwd file. The entries in the /etc/passwd file has seven fields Syntax ; Fisehane Tix] :[UID] :[GID} :[Comment] :[Home directory] :|Default shell] Es the information correct? LY/ jemnal tue 3 7 eS 1, Create a group All the groups are listed in /etc/groups file All default groups cannot be used for ordinary accounts and these groups are system account specific groups. ‘Syntax (sid a 8 roa Where options meaning is as given below. “gid : This option indicates group ID value. -0: This option is for adding the group with non-unique GID. -£ : This option is for adding the system account. f: This option is for exiting with success status if specified group already exists groupname : Name of the group to be created Csrwpntd es creates the group with name rajesh. 2. Modify a group Syntax : [Hiibietpined sr new modified group name old_group_name For example,to change the rajesh group name to satish following command is used. [Serepoa natin jen To change group ID to $50 following command Is used 3. Delete a group To delete the satish group, the command is ee a WY (ettooniee (Msi 219 ‘Sorvicas & nts of Operat 4. User rights/Permissions {2) The first character that | marked with an underscore is the special permission flag that can vary. {b) The following set of three characters (rw) is for the owner permissions. {c) The second set of three characters (rw) is for the Group permissions. (4) The third set of three characters (run) is for the All Users permissions. 12, Following that grouping since the integer/number displays the number of hardiinks to the file, 13, The last piece is the Owner and Group assignment formatted as Owner Group. 4, Modifying the Permissions ‘When in the command line, the permissions are edited by using the command chmod. You explicitly or by using a binary reference as described below, ‘chmod [options] mode|,mode] filed [file2 .] ‘can assign the permissions Usual implementing options include = -Rrecursive, Le. include objects in sub directories = _-Fforce, forge ahead with all objects even if errors occur = -vverbose, show objects processed ‘The r, w, and x specify the read, write, and execute access, respectively. This script can be read, written to, and ‘executed by the user, read and executed by other members of the staff group and can also be read by others. Numerical permissions an # Permission pe) 7 read, write andexecute | 111 6 |read and write 110| [5 lreadandeneete | 202 4 |read only 100 | | 3. [write and execute lou 2 |write only | eee | 2. |execute only 00: | 0 |none | 000 ‘chmod 0664 sharedFile 2.4.21 User Authentication ~ Several protection methods are developed by keeping in mind that, the system knows the recognition of each user. ‘The user authentication is the method to identify the user while logging into the system. = _Several methods of user identification are based on some user information. a ~ a |= User information can be something the user knows, something the user has and something the user's. These. directs about different authentication schemes with different complications and security properties. 1. Passwords = Username and password is simplest and most commonly used type of authentication. Password protection is simple ic understand and straightforward to implement. = The simplest implementation just maintains a central list of login-name and password pairs. = The entered login name by user is searched in the list and the ‘typed password is compared against the stored password inthe list If there is a match the login allowed otherwise tis denied = In UNIK it works like this. The login program asks the user to enter a username and Password. The password is straight away gets encrypted. Password file maintained is series ASCI lines. The login program reads Password fle until login name is found. The entered encrypted password gets compared with the stored encrypted password in password file. ‘if there is match, then login is permitted. Otherwise It is rejected. To keep the entered password secret from other ‘watching people, In Windows 2000, asterisk is displayed after each character is typed by user. With UNIX, nothing gets displayed while the password is being typed. = The crackers can Identify user name and password by trying many combinations of both. Generally, user uses their name as login name in different form. For example, Rajesh kadu can be used as Rajesh_Kadu etc. The crackers can try in the same way to know the user name. Generally, for password names, it is found that, user uses first and last names, street names, city names, words from a moderate sized dictionary; words spelled backward, license plate numbers, and short strings of random characters. ‘The work by Morris and Thompson (1979) on UNIX systems and by Klein (1990) by using above information for password name found that, 86% password matches from password list. In this way crackers can break the passwords. Morris and Thompson described a technique that makes the attack almost useless. Their idea Is to associate an n -bit random number, called me salt, with each password. The random number is changed whenever the password is changed. The random number is stored in the password file in unencrypted form, so that everyone can read it Instead ‘of just storing the encrypted password in the password file, the password and the random number are first concatenated and then encrypted together. This encrypted result Is stored in the password file. Suppose cracker wants to build up a list of likely passwords, encrypt them, and save the results in a sorted file, f, so that any encrypted password can be looked up easily. If an intruder suspects that xyz might be a password. He has to encrypt 2” strings such as xy20000, xy20001, and so on and enter all of them in f UNIX uses this method with n=12. = One-time password scheme allows the changing of password all the time. When one-time passwords are used, the User gets a book consisting of a list of passwords. Each login uses the next password in the list. If an intruder ever discovers a password, it will not do him any good, since next time a different password must be used. It Is recommended that the user try to avoid losing the password book = The other approach to password idea Is to provide each new user a list of questions and answers which are stored in ‘encrypted form. At the time of login, system asks one of the questions at random and verifies its answer ~ In challenge-response scheme, at the time of signing, user selects the algorithm, for example x°. When user log in the system, system type argument, say 5, in which case user types 125. At different time, different algorithms should be used. Physical Identification Apart from password, following approaches could be used for user authentication. ied ca Such as plastic card with magnetic stripe on it can be used for authorization of users. The card into terminal or computer and user types the password to prevent someone from using a lost or stolen caré ent 245 Services & of ‘of card and password is used in this method. Now day’s Smart cards can be used to hold mon value cards, but with much better security and universality. The cards can be loaded with money at an ATM machine or at home over the telephone using a special reader supplied by the bank. The big advantage of smart cards ‘ver, say, credit oF debit cards, is that they do not need an online connection to a bank. Forging of human physical characteristics is dificult task. Fingerprint or a voiceprint reader in the terminal could verify the user's identity. ‘Asstored known specimen signature of user gets compared with signed signature of the user. In this case user signs with special pen attached to the terminal. In other approach, pen movement is compared to get better solution against forgery. — _Adatabase of user's finger length is maintained. A special device is attached to the terminal which can measure length of the all fingers of user. User inserts the fingers in device and measured length gets compared against length in database to identify the user. 3. Countermeasures Following countermeasures should be taken. = Auser should be allowed to login only from specific terminal and fixed time slot of particular days should be given to each user. = Dial-up telephone lines can also be made secure as follows. Anyone can dial up and log in, but after a successful login, the system immediately breaks the connection and calls the user back at an agreed upon number. After three failed login attempts, the line should be -onnected for 10 minutes and security personnel notified. = All logins should be recorded. When a user logs in, the system should report the time and terminal of the previous login, so he can detect possible break ins. = In this simple approach, one special login name with an easy password is used. Whenever someone logs in using this ‘name, the system security specialists are instantly notified. All commands the intruder types are instantly displayed on the security manager's screen so he can see accurately what the intruder is up to. Other traps can be easy-to-find bugs in the operating system and related things, designed for the purpose of catching intruders in the act. 24.2.2 Administrator Role for Security itis the responsibility of administrator to set access to some of the system's services. Some of the users needs to be protected from accessing some services 1. Password Aging = Administrator in the system with /etc/shadow file can enforce the users to change the password after some predetermined time. This file contains fields that define attributes of user's password. Command used for updating the fields with appropriate options is passwd. “1 This option is used to set the minimum number of days to retain the password. °X: Sets maximum limit for number of days to retain the password. For user satish these options are given below. asswd —n 10 satish : Minimum 10 weeks before password can be changed asswd x 30 satish : Maximum 24 weeks before password must be changed. Dasswd 4 :This option is used to lock the user account asswd ~u : This option is used to restore the locked user account. = Passwd =f 2 \is option is used to force the user to change his/her password on next login. Wits 2, Shell Restriction J To control the user's activities, administrator set up the user account with a special restricted shell. If previous sy. was rsh then today, this shell name can be used as command to run the program remotely. The shell versions toss, Which are mostly used are versions rbash and rksh. Out of these two names, any name should be specified in last fey of /etc/passwd file, After this restriction user cannot carry out following activities. ‘Changing the directory with cd command Redefining the path to access other directories Redefining the shell to access nonrestricted shell. Use of patnname containing a/so that absolute or relative pathname cannot be used to execute command ‘The use of characters lke > and >> in order to create or append to file 2.4.3 Device Management 2.4.3.1 Device Drivers Linux treats each device as file. Like file, it open the device, write data to it and read data from it. After using device, OS then closes it. Device drivers are responsible for treating every device as file. Device driver is a program than controls particular device. When OS kernel writes data to particular device then device driver of that device carries out appropriate action for that device 2.4.3.2 Device Files Applications access the device by treating it as file. These files are device files and present in /dev directory. The Js command is used to see list of files present in /dev directory. The /dev directory contains files for all possible devices. Each device file is mapped to a specific device driver through major and minor numbers. Following s ‘command shows major and minor device number, = Is1/dev/hda = Following is the output of above command. — brwrw——- 1 root disk 3, 0 Feb 10 13:30 /dev/hda — Output shows major device number as 3 and minor device number as 0. Block Devices ~The first letter b in listing of device file indicates that It is a block device. Hence, letter b for /dev/hda device shows that /dev/hda is a block device. The block devices accept data in blocks of 512 bytes or 1 KB. /dev/hde refers to first IDE hard disk on the system. The examples of the block devices are hard drives, floppy drives, and CD-ROM drives. Character Devices The first letter cin listing of device file indicates that it is a character device which accepts or send data one bytt (character) at a time. Examples are serial and parallel ports. Is /dev/ttyso Services & sting of this device is given below _ ewrw— 1 root uucps, 64 Feb 10 13.30 /dev/ttyso Network Devices _ These devices do not have files. Ethernet card is named as eth0 for first card, eth1 for second card and so on. Similarly dial-up point to point protocol (PPP) is named as pppO, ppp and so on. 2.43.3 Partitions To check the partitions set up on hard disk, fdisk command is used. Boot Start End Sectors Size Id Type Pi 2048 718847 716800 350M 7 HPFS/NTFS/exFAT 718848 204802047 204083200 9736 7 HPFS/NTFS/exFAT 614402048 976771071 362369024 172.86 7 HPFS/NTFS/exFAT 204804094 614402047 409597954 195.36 5 Extended 204804096 614402047 409597952 195.36 83 Linux Above output shows that system has both Windows and Linux Linux partition is shown by /dev/sdaS. The mount ‘command is used to check the partitions that are actually being used for your Linux system. This command is used with no ‘option. Output shows partitions that are actually mounted and where they are mounted /oroc type proc (rw,nosuid,nodev,noexec,relatime) evn ‘Joex type devtmpfs (rw,nosuid,relatime,size=1703872k,nr_inodes=425968,mode=755) in /dev/pts type devpts (rw, nosuid,noexec,relatime,gid=5,mode=620, ptmxmode=000) on /run type tmpfs (rw,nosuid,noexec.relatime,size=345340k mode=755) /sda5 on / type ext (rw,relatime,errors=remount-ro,data-ordered) on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) n id type tmpfs (rw,nosuid,nodev) pe tmpfs (rw,nosuid nodev,noexec,relatime,size=5120k) Using mount Command to mount File System ~ The mount command (with no options) is used to check what file systems are at this time mounted on the local Linux system. In following example of mount command, single hard disk partition (/dev/hdal) that contains the root (/) file 2.44 Performance Monitor Performance Monitoring in Linux 1, TOP Command Linux Top command is used for monitoring the performance and used often by many system administrators to monitor Linux performance. This command is available under many Unux/Unix like operating systems. The top command displays all the running and active real-time processes in ordered list and updates it regularly. It display CPU usage, Memory usage, Swap Memory, Cache Size, Buffer Size, Process PID, User, Commands and rmuch more. It also shows high memory and cpu utilization of @ running processes. The top command is much useful for system administrator to monitor and take correct action when required. Htop is another variant of top which comes with graphical interface for process monitoring. Nmon and Monitorix are light weight tools available to monitor the performance of the CPU, memory and processes Usage of top command $root@litmus> top q ecccscea- ae qiid2y| root Foot root root root root root root root root, sce a Process Management 3.1 Process: Process States, Process Control Block (PCB) 3.2 Process Scheduling : Scheduling Queues, Schedulers, Context Switch 3.3 Inter-Process Communication (IPC) : Introduction, Shared Memory Systems and Message Passing Systems 34 Threads : Benefits, User and Kernel Threads, multithreading models: Many to one, One to One, Many to Many 3.5. Execute Process Command ke ps, wait, sleep, exit, kill 3.1__ Introduction to Process Management — Process manager implements the process management functions. In multiprogramming, single CPU is shared among many processes. — If many processes remain busy in completing 1/0, CPU is allocated to only one process at a given point of time. ~ Here some policy is required to allocate CPU to process, called as CPU scheduling. If multiple users are working on the system, operating system switches the CPU from one user process to other. ~ User gets the illusion that only he or she is using the system. Process synchronization mechanism is required to ensure that only one process should use critical section. — Process communication, deadlock handling, suspension and resumption of processes and creation and deletion of the processes etc. are some of the activities performed in process management. 3.1.1 Process = Aprogram or application under execution is called as process. A process includes the execution context. A program resides on the disk. On disk it does not require any resources. A program gets executed in main memory, So it should be transferred from disk to main memory. ~ Tocomplete execution, program needs many resources and competes for it. Now it becomes process. - From the computation context point of view, a process is defined by CPU state, memory contents and execution environment. ~ ACPU state is defined by the content of the various registers such as Instruction Register (IR), Program Counter (PC), Stack Pointer (SP) and general purpose registers, _Asmall amount of data is stored in CPU registers. Memory contains program code and its predefined data structures. = Heap is reserved memory area for dynamically allocation of memory to the program at run time. 32 Process “= «tn stack, program local variables are allocated and return values of function call are stored. Some register values ar. also saved in stack. Execution environment includes open files, communication channels to other processes etc. Following are the components of the process : — The object code that is to be executed. = Resources required by the program to complete the execution. — The data on which program will operate. — Program execution state. 3.1.2 Process States ~ During execution, process changes its state. Process state shows the current activity of the process. Process state contains five states. = _ Each process remains in one of these five states. There is a queue associated with each state of the process. — Process resides on that queue as per the state in which it resides. The states are listed below. New state Ready state Execution state Waiting (blocked) state Terminated state 1. New state The new process is being created. 2. Ready state {A process is ready to run but itis waiting for CPU being assigned to it Executing state Aprocess is said to be in running state if currently CPU is allocated to it and itis executing. 4, Waiting (blocked) state A process can’t continue the execution because it is waiting for event to happen such as I/O completion. Process is abl2 to 1un when some external event happens 5. Terminated state The process has completed execution. The process state transition diagram is shown in Fig, 3.1.2 - When the process is created, it remains in new state. After the Process admitted for execution, it goes in ready state. A brocess in this state, wait in the ready queue. Scheduler dispatches the ready process for execution i.e, CPU is now allocated to the process, rating (MSE When CPU Is executing the process, it is in executing state. After context switch, process goes from executing to ready state. If executing process Initiates an 1/0 operation before its allotted time expires, the executing process voluntarily give up the CPU. In this case process transit from executing to 10 or event completion waiting state. When the external event for which a process was walting happens, process transit from eames care. ne” Process finishes the Fig. 3.1.1 : Process state transition diagram ‘execution, it transits to terminated state. 3.1.3 Process Control Block (PCB) = Any process is identified by its process control block (PCB). PCB is the data structure used by the operating system to keep track on the processes. All the information associated with process is kept in process control block. There is separate PCB for each process ~ Traffic controller module keeps track on the status of the processes. PCB's of the processes which are in the same state (ready, executing, waiting etc) are linked together giving a specific name to the list such as ready list. fmany processes wait for the same device, then PCBs of all these processes are linked together in chain waiting for that device. If device becomes free then traffic controller checks the PCB chain to see if any process is waiting for the device. If the processes are available in that device chain, then again it is placed back to ready state to request that device again. A typical process control block is shown in Fig. 3.1.2. Pointer | Current tate Process ID ity Program counter Registers Accounting ‘Memory allocations Event information List of open files Fig. 3.1.2 : Process control block Pointer : This field points to another process control block. Pointer is used for maintaining the scheduling list. Current state : Current process state may be new, ready, executing, waiting etc as described above. Process ID : Identification number of the process. It is assigned by operating system. 5 Priority Priority of the process. Program counter: It stores the address of the next instruction to be which execution resumes after context switch. executed for this process. It Is the address from Registers: It Indicates general purpose register, index registers stack pointers and accumulators etc. number of register and type of register totally depends upon the computer architecture. The state information of these should be stored after interrupt. This information is again used by the process to resume the execution. ‘Accounting : Information for calculating the process's priority relative to other processes, This may include accounting information about resource use so far. It also includes amount of CPU time and real time used, time limits, process ‘numbers and so on. Memory allocation : This information may include the value of base and limit register. It includes paging, ‘segmentation related information depending on the memory system used. Address space allocated to the process etc Event information : For a process in the blocked state this field contains information concerning the event for which the process is wating. Lst of open files : Files opened by the process After creation of the process, loader or linker provides information. As per this provided Information, hardware registers and flags are set. Whenever that process Is blocked, the contents of the processor register are usually saved on the stack and the pointer to the related stack frame is stored in the PCB. In this way, the hardware state can be restored ‘when the process is scheduled and resume execution again. 3.2 __ Process Scheduling 3.2.41 Scheduling Queues When the process enters into the system, they are put by system in the queue called a job queue. All the processes in the system reside in job queue. When processes are ready for the execution and wait for CPU, they kept in ready queue. — The operating system also has other queues. When processes wait for particular device, they are kept in respective (0) [ee [ee |e devices queue. child Forka execute chils niorruph Wait foran occurs Interrupt Fig, 3.2.1 : Queulng-dlagram representation of process scheduling mn (MSI 25 Process Management = After allocation of CPU to the process start the execution. While executing the process, one of the numbers of events could occur. = Until the process finishes the execution, it travels between various scheduling queues. 32.2 Schedulers = The operating system selects the processes from queues based on some policy ‘This selection Is carried out by the program called as scheduler. There are three types of Schedulers 1, Long-term Scheduler 2. Short-term Scheduler 3, Medium-term Scheduler 4. Long-term Scheduler = When programs are submitted to the system for the purpose of processing, long term scheduler comes to know about It. Then its Job is to choose processes from the queue and place them into main memory for execution purpose = CPU bound processes require more CPU time and less /O time until execution completes, On the contrary, 1/0 bound processes use up more time in doing I/O and require less CPU time for computation. = The primary responsibility of the long term scheduler is to supply a reasonable mix of jobs, such as I/O bound and CPU bound, = Degree of multiprogramming is high if more number of processes are in memory for execution. It also controls the degree of multiprogramming. = If the degree of multiprogramming is steady, then the average rate of new process creation and average departure rate of processes leaving the system must be equal = The long term scheduler is not present in timesharing operating systems. When process state transition take place from new to ready, then there long term scheduler come into picture for scheduling purpose Short-term Scheduler Processes which are in ready queue wait for CPU. A short term scheduler chooses the process from ready queue and assigns it to the CPU based on some policy. These policies can be First Come First Served (FCFS), Shortest Job First (SIF), priority based and round robin etc, Main objective is increasing system performance by keeping the CPU busy = It is the transition of the process from ready state to running state. Actual allocation of process to CPU is done by dispatcher. Short term scheduler is faster than long tern scheduler and should be invoked more frequently compare to long term scheduler 3. Medium-term Scheduler Increases, medium-term scheduler swap out the processes from main memory = Ifthe degree of the multiprogrammir ‘The swapped out processes again swapped in by medium-term scheduler. ~ This is done to control the degree of multiprogramming or to free up @ memory. This is also helpful to balance the mix of different processes, some time sharing operating system have this additional scheduler 37 Process Mana; 3 Inter-Process Communication (IPC) 3.3.1 Principle of Concurrency in a single-processor multiprogramming system, processes are not executed concurrently. In order to get the appearance of concurrent execution, a fixed time slot is allocated to each process. ‘After utlization of this time slot, CPU gets allocated to other process, Such switching of CPU back and forth between processes is called as context switch. At time single process gets executed so parallel processing cannot be accomplished. Also there is a definite amount of overhead drawn in switching back and forth between processes. ‘Apart from above limitations, interleaved execution offers major benefits in processing efficiency and in program structuring, Ina multiple processor system, interleaving and overlapping the execution of multiple processes is achievable. Both interleaving and overlapping correspond to basically diverse modes of execution and present diverse problems In reality, both interleaving and overlapping can be treated as illustration of concurrent processing and both the techniques address the similar problems. The comparative speed of execution of processes depends on activities and behaviour of other processes, how the ‘operating system handles interrupts, and the scheduling policies of the operating system The difficulties that arise 1 Global resources sharing. For example, suppose two processes use the same global variable simultaneously and both carry out read and write operations on that variable, then various reads and writes execution ordering is serious. Optimal management of the resources is not easy for the operating system, Programming error tracing is not easy as results are typically non- deterministic and not reproducible Only a single user Is supported by single processor multiprogramming system at a time. While working on one application, user can switch to other application in this system The keyboard for input purpose and screen for output purpose used by each application is same. The reason is, each application needs to use the procedure echo, ‘As echo procedure is shared by each application, memory can be saved by keeping single copy of procedure in memory portion which is global for all sharing applications, In order to have efficient and close interaction among processes, sharing of primary memory among processes Is Useful, aS ee ti—S . or it in input variable chi, nee cedure. The getchar() returns its value and stores e al chap rine Na Be tees after returned value gets stored In chinput. At this instant, the mo, Process Pi gets interrupted stra rable chinput. recently entered character, m, I stored in var E, 2. After Pl gets interrupted, there Is turn of process P2 and it call up the echo procedure. Process P2 inputs ang After in h haracter n on the monitor. ee nd the value m gets overwritten in the variable chinput and as , which is transferred to variable choutput and displayed, 3. Now again, process P1 resumes its execution a! result it gets lost, The variable chinput holds value n, +n is displayed two times. All this happens due tp 4. In this way, the first character m Is lost and the second character : shared global variable, chinput. If after updating the shared global variable, one process is interrupted, another process may modify the variable before the previously interrupted process can use its value, In above example both Pi and P2 are allowed to use shared global variable chinput. However, if only one process at a time is allowed to be in procedure, above discussed sequence would result in the following : (i) Initially process P2 calls the echo procedure. The getchar() returns its value and stores it in input variable chinput Process Pi gets interrupted straight away after returned value gets stored in chinput. At this instant, the most recently entered character, m, is stored in variable chinput (ii) After Pi gets interrupted, there is turn of process P2 and it call up the echo procedure. At this situation, process Pisin suspended state and itis still inside the echo procedure. The process P2 is not allowed to enter inside the echo() procedure. Therefore, P2 is suspended until P1 comes out of the echo procedure. later on, process Pi is resumes and finishes the execution of echo procedure. The output displayed is the character m. (iv) When P1 comes out of echo() procedure, P2 becomes active. Now process P2 can successfully call the echo() procedure. Therefore it is necessary to use shared global variable by only one process at a time. 3.3.2 Introduction to Inter-process Communication Synchronization and communication are two basic requirements should be satisfied when processes communicate with each other. = Synchronization of processes is required to achieve the mutual sii tai daguen al nous ISS exclusion. Interprocess communication ~ Independent processes do not communicate with each other but cooperating processes may need to exchange information. Cooperative processes either communicates through shared memory Or message passing. 1. Shared memory 2, Message passing ~ Cooperating processes require an Interprocess Communication(IPC) Fig. 3.3.1 mechanism that will allow them to exchange data and information, = _ There are two fundamental models of iterprocess communication : a —— all - 39 Process Manas 332.1 Shared Memory System ‘e6lon of memory that's shared by ‘cooperating processes Is established hr Information by reading and writing data to the shared region. Inthe mess8g Passing model, communication takes pace by means of messages exchanged between the cooperating processes. 33.2.2 Message Passing System ‘Message passing provides both functions, Mestage passing has the further benefit that it lends itself to Implementation in distributed systems as well as in shared-memory multiprocessor and uniprocessor systems Following are the two primitives used in message passing send (destination, message) recelve (source, message) Be mI Wo 2PeretIons required for processes to send and recelve the messages Baga process sends data in the form of a message to another process indicated by a destination eine es AOEY executing the receive primitive, indicating the source and the message, untilit has been sent by another process Biimemmreproc=== blocked Unt the message is received, or it isnot after the send primitive executed by process, = Similarly, when a process issues a receive primitive, there are two possibilities = Previously sent message is received and execution continues. ~ I there is no walting message, then either (a) the process Is blocked until a message arrives, or (b) the process continues to execute, abandoning the attempt to receive Thus, both the sender and receiver can be blocking or nonblocking, Three combinations are common, although any particular system will usually have only one or two combinations implemented © The blocking send and blocking receive : Until the message Is handed over, the sender and receiver both gets blocked. The nonblocking send and blocking receive : After sending the message, the sender continues its work but Fecelver remains blocked until message is arrived to it. This permits a process to send one or more messages toa multiple destinations as quickly as possible, Here receiver is in need of message so that it can resume the execution. So it gets blacked until message arrives. © Nonblocking send, nonblocking receive : Neither party is required to wait The nonblocking send and nonblocking receive : Both sender and receiver will not wait and both will Continue the work. ~ Message passing system should give guarantee that messages will be correctly received by receiver. Receiver sends acknowledgement to sender after receiving the message. If acknowledgement not received in defined time then sender resend the message. It also offers authentication service, res ——“, 3.4 Thread * 3.4.1. Benefits ens re a0 aed? lightweight Processes aS It posse... = Athread is a single sequence stream within a process: ‘one process: some of the properties of processes. In operating system that support multithre improving the application performance. Eacl space of the process and the environment. Threads can share common data so they do not also have states like ready, executing, blocked etc. Each thread belongs (© priority thread is scheduled first, Each thread has its own Thread Control Block (TCB). Like proces contents are saved in TCB. As threads share the same a\ the various activities of the thread. Process Vs Threads ding, process c2N CO fh such thread has its own need to use interproces: priority can be assigne dress space many threads. These threads run in paras of ist ack, but they share the adi, cpu state and st communication. Like the processes, threay 4 to the threads just like process and high. «context switch occurs for the thread and rege and resources, synchronization is also required f Thread ‘Thread is part of process. It is also called as light weight process address space of process changes. weight process. 2. | Process context switch takes more time as | Thread context switch takes less time as compared to compared to thread context switch because it | process context switch because it needs only, needs interface of operating system. interrupt to kernel only. 7 3. | New Process creation takes more time as | New thread creation takes less time as compared to compared to new thread creation. new process creation 4. | New Process termination takes more time as | New thread termination takes less time as compared L compared to new thread termination. to new process termination 5. Each process executes the same code but has its | All threads can share same set of open files, child ‘own memory and file resources. processes, 6. _| If implementation is process b: i a pl pr ased, then blocking | In multithreaded server implementation, if on? of one process cause the blocking of other server | thread is bl th ; locked and waiting, second thread in the process until the first process unblocked and these | same Process could execute are not allowed to execute until blocked process is unblocked. - a 7. _ | Multiple redundant A nt processes use more resources | With compare oct than multiple threaded process, ane au cocuneant P i = ultiple threaded processes use fewer resources: _ : ntext switch flushes the MMU (TLB) registers as No need to flush TLB as address space remains 52° after context switch because threads belong same process,

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy