WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Chapter-1 Introduction to operating systems What is operating system? An operating system is a program that manages a computer’s hardware. controls the execution of application programs Acts as an intermediary between the computer user and the computer hardware. run at all times on the computer—usually called the kernel. Abstract view of the components of a computer system. The objective/function of operating system is; i. Convenience: An OS makes a computer more convenient to use. ii. Efficiency: An OS allows the computer system resources to be used in an efficient manner. This includes; the allocation of main memory when an I/O device can be used by a program in execution controls access to and use of files. Elias T Page 1 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology determines how much processor time is to be devoted to the execution of a particular user program iii. Ability to evolve: An OS should be constructed in such a way as to permit the effective development, testing, and introduction of new system functions without interfering with service. Terminologies of Operating system Kernel a portion of the operating system that includes the most heavily used portions of software. Generally, the kernel is maintained permanently in main memory. The kernel runs in a privileged mode and responds to calls from processes and interrupts from devices. system programs programs associated with the operating system but are not necessarily part of the kernel. application programs include all programs not associated with the operation of the system. middleware a set of software frameworks that provide additional services to application developers. spooling The use of secondary memory as buffer storage to reduce processing delays when transferring data between peripheral equipment and the processors of a computer. Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus. Software may trigger an interrupt by executing a special operation called a system call (also called a monitor call). Trap (or an exception) A software-generated interrupt caused either by an error (for example, division by zero or invalid memory access) or by a specific request from a user program that an operating-system service be performed. Elias T Page 2 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Job a set of computational steps packaged to run as a unit. Device driver an operating system module (usually in the kernel) that deals directly with a device or i/o module. Device controllers A device connected through a common bus that provides access to shared memory. Each device controller is in charge of a specific type of device (for example, disk drives, audio devices, or video displays). The controller’s job is to convert the serial bit stream into a block of bytes and perform any error correction necessary. The block of bytes is typically first assembled, bit by bit, in a buffer inside the controller. After its checksum has been verified and the block has been declared to be error free, it can then be copied to main memory. Dual-mode and multimode operation At the very least, we need two separate modes of operation: user mode and kernel mode (also called supervisor mode, system mode, or privileged mode). A bit, called the mode bit, is added to the hardware of the computer to indicate the current mode: kernel (0) or user (1). Elias T Page 3 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology With the mode bit, we can distinguish between a task that is executed on behalf of the operating system and one that is executed on behalf of the user. At system boot time, the hardware starts in kernel mode. The operating system is then loaded and starts user applications in user mode. The dual mode of operation provides us with the means for protecting the operating system from errant users—and errant users from one another. The concept of modes can be extended beyond two modes (in which case the CPU uses more than one bit to set and test the mode). History of Operating System Historically operating systems have been tightly related to the computer architecture, it is good idea to study the history of operating systems from the architecture of the computers on which they run. Operating systems have evolved through a number of distinct phases or generations which corresponds roughly to the decades. The 1940's - First Generations The earliest electronic digital computers had no operating systems. Machines of the time were so primitive that programs were often entered one bit at time on rows of mechanical switches (plug boards). Programming languages were unknown (not even assembly languages). The 1950's - Second Generation By the early 1950's, the routine had improved somewhat with the introduction of punch cards. The General Motors Research Laboratories implemented the first operating systems in early 1950's for their IBM 701. The system of the 50's generally ran one job at a time. These were called single-stream batch processing systems because programs and data were submitted in groups or batches. The 1960's - Third Generation The systems of the 1960's were also batch processing systems, but they were able to take better advantage of the computer's resources by running several jobs at once. So operating systems designers developed the concept of multiprogramming in which several jobs are in main memory at once; a processor is switched from job to job as needed to keep several jobs advancing while keeping the peripheral devices in use. Fourth Generation With the development of LSI (Large Scale Integration) circuits, chips, operating system entered in the system entered in the personal computer and the workstation age. Microprocessor Elias T Page 4 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology technology evolved to the point that it becomes possible to build desktop computers as powerful as the mainframes of the 1970s. Two operating systems have dominated the personal computer scene: MS-DOS, written by Microsoft, Inc. for the IBM PC and other machines using the Intel 8088 CPU and its successors, and UNIX, which is dominant on the large personal computers using the Motorola 6899 CPU family. Types of Operating System Types of operating systems Following are few of the important types of operating system which are most commonly used. Batch operating system The users of batch operating system do not interact with the computer directly. Each user prepares his job on an off-line device like punch cards and submits it to the computer operator. To speed up processing, jobs with similar needs are batched together and run as a group. Thus, the programmers left their programs with the operator. The operator then sorts programs into batches with similar requirements. The problems with Batch Systems are following. • Lack of interaction between the user and job. • CPU is often idle, because the speeds of the mechanical I/O devices is slower than CPU. • Difficult to provide the desired priority. Memory layout for a simple batch system Multiprogrammed batch systems Elias T Page 5 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. OS features needed for multiprogramming • I/O routine supplied by the system. • memory management – the system must allocate the memory to several jobs. • CPU scheduling – the system must choose among several jobs ready to run. • allocation of devices. Time-Sharing Systems–Interactive Computing • The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory). • A job swapped in and out of memory to the disk. • On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard. • On-line system must be available for users to access data and code. Advantages of time sharing operating systems are following Elias T • Provide advantage of quick response. • Avoids duplication of software. • Reduces CPU idle time. Page 6 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Disadvantages of timesharing operating systems are following. • Problem of reliability. • Question of security and integrity of user programs and data. • Problem of data communication. Desktop systems • personal computers – computer system dedicated to a single user. • i/o devices – keyboards, mice, display screens, small printers. • user convenience and responsiveness. • can adopt technology developed for larger operating system’ often individuals have sole use of computer and do not need advanced CPU utilization of protection features. • may run several different types of operating systems (windows, mac OS, Unix, Linux) Parallel systems multiprocessor systems with more than on CPU in close communication. tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory. advantages of parallel system: • increased throughput • Economy of scale • increased reliability Symmetric multiprocessing (SMS) • each processor runs identical copy of the operating system. • Many processes can run at once without performance deterioration. • Most modern operating systems support SMS Asymmetric multiprocessing Elias T Page 7 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology • Each processor is assigned a specific task; master processor schedules and allocated work to slave processors. • More common in extremely large systems • Symmetric multiprocessing architecture Distributed Systems • Distribute the computation among several physical processors. • Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as highspeed buses or telephone lines. Advantages of distributed systems. Resources Sharing Computation speed up –load sharing Reliability Communications • Requires networking infrastructure. Local area networks (LAN) or Wide area networks (WAN) • May be either client-server or peer-to-peer systems. Real –Time Systems • Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems. • Well-defined fixed-time constraints. Elias T Page 8 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology • Real-Time systems may be either hard or soft real-time. Hard real-time: critical tasks complete on time. Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM) Conflicts with time-sharing systems, not supported by general-purpose operating systems. Soft real-time • are less restrictive, that is critical real-time task gets priority over other tasks and retains the priority until it completes. • Limited utility in industrial control of robotics • Useful in applications (multimedia, virtual reality) requiring advanced operating-system features. Handheld Systems • Personal Digital Assistants (PDAs) • Cellular telephones • Issues: • Limited memory • Slow processors • Small display screens. Assignment 10% 1. Dual-core, Core I3, Cori I5 and Core I7 processors 2. History of Operating System Elias T Page 9 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Common System Components Process Main Memory I/O System File Shell A processis a program in execution. A process needs certain resources, including CPU time, memory, files, and I/Odevices, to accomplish its task. •The operating system is responsible for the following activities in connection with process management. Process creation and deletion process suspension and resumption Provision of mechanisms for: process synchronization process communication Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. Main memory is a volatile storage device. It loses its contents in the case of system failure. The operating system is responsible for the following activities in connections with memory management: Keep track of which parts of memory are currently being used and by whom. Decide which processes to load when memory space becomes available Allocate and De allocate memory space as needed Elias T Page 10 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology I/O The I/O system consists of: A buffer-caching system A general device-driver interface Drivers for specific hardware devices File systems A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. •The operating system is responsible for the following activities in connections with file management: File creation and deletion. Directory creation and deletion. Support of primitives for manipulating files and directories Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media. Shall system A shell is software that provides an interface for an operating system's users to provide access to the kernel's services. On Unix-based or Linux-based operating systems, a shell can be invoked through the shell command in the command line interface (CLI), allowing users to direct operations through computer commands, text or script. Shells also exist for programming languages, providing them with independence from the operating system and allowing crossplatform compatibility. Elias T Page 11 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology System calls System calls provide the interface between a running program(applications) and the operating system. Generally available as assembly-language instructions. Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C. Bliss, PL/360) Three general methods are used to pass parameters between a running program and the operating system. i. Pass parameters in registers. ii. Store the parameters in a table in memory, and the table address is passed as a parameter in a register. iii. Push(store) the parameters onto the stackby the program, and popoff the stack by operating system. System call have three functions: Specifying the file Specifying the buffer, and Specifying the number of bytes to read. A call to READ from a C program might look like this: count = read(file, buffer, nbytes); Elias T Page 12 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Types of System Calls Six major categories Elias T Page 13 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Protection o Control access to resources o Get and set permissions o Allow and deny user access Elias T Page 14 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Operating System Services o Operating systems provide an environment for execution of programs and services to programs and users o One set of operating-system services provides functions that are helpful to the user: o User interface -Almost all operating systems have a user interface (UI). Varies between Command-Line (CLI), Graphics User Interface (GUI),Batch o Program execution -The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) o I/O operations -A running program may require I/O, which may involve a file or an I/O device One set of operating-system services provides functions that are helpful to the user (Cont.): o File-system manipulation -The file system is of particular interest. Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. o Communications–Processes may exchange information, on the same computer or between computers over a network Communications may be via shared memory or through message passing (packets moved by the OS) o Error detection –OS needs to be constantly aware of possible errors error, OS should take the appropriate action to ensure correct and consistent computing Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing •Resource allocation -When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources -CPU cycles, main memory, file storage, I/O devices. •Accounting -To keep track of which users use how much and what kinds of computer resources •Protection and security -The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other Protectioninvolves ensuring that all access to system resources is controlled Elias T Page 15 WACHAMO UNIVERSITY DURAME CAMPUS, Department of Information Technology Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts Operating System Structures System Structure –Layered Approach layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers. Layered Structure of the OS A layered design was first used in the operating system. Its six layers are as follows: Elias T Page 16