Presentation is loading. Please wait.

Presentation is loading. Please wait.

OPERATING SYSTEMS Chapter 1 Introduction

Similar presentations


Presentation on theme: "OPERATING SYSTEMS Chapter 1 Introduction"— Presentation transcript:

1 OPERATING SYSTEMS Chapter 1 Introduction
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved 1

2 Outline Why study operating system What is an operating system
The history of Operating System Hardware of operating system Important concepts of Operating System

3 Why study operating system
To learn how computers work To learn how complexity is managed through appropriate abstractions: infinite CPU, infinite memory, files, etc. To learn about system design performance vs. simplicity, HW vs. SW, etc. Because OSs are everywhere!

4 What Is An Operating System
A modern computer consists of: One or more processors Main memory Disks Printers Various input/output devices Managing all these components requires a layer of software – the operating system A modern computer is a complex system. It’s impossible for every application programmer to understand how all these thing work in detail. Furthermore, managing all these components and using them optimally is an exceedingly challenging job. therefore, OS is introduced to provide user programs with a better, simpler, cleaner model of the computer and handle all the resources. User uses various kinds of OS. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

5 What Is An Operating System
Figure 1. Where the operating system fits in. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

6 What is an Operating System?
Users use various OS Windows, Linux, Mac OS etc. User interacts with shell or GUI part of OS? they use OS to get their work done Is device driver part of OS?

7 What is an Operating System?
On top of hardware is OS Most computers have two modes of operation: Kernel mode and user mode OS runs in kernel mode, which has complete access to all hardware and can execute any instruction Rest of software runs in user mode, which has limited capability Shell or GUI is the lowest level of user mode software

8

9 What is an operating system?
Two functions: From top to down: provide application programmers a clean abstract set of resources instead of hardware ones From down to top: Manage these hardware resources

10 The Operating System as an Extended Machine
Architecture (instruction set, memory organization, i/o , bus structure) of most computers at machine language level is primitive and awkward to program specially for input/output. Average programmer does not want to get too immensely involved with programming of floppy disk or hard disks. Instead a programmer wants simple, higher order abstraction to deal with. Example in case of disks will be that it contains collection of named files. One of task of operating system is to hide hardware and present programs and programmers with nice abstractions to deal with Figure 1-2. Operating systems turn ugly hardware into beautiful abstractions. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

11 The Operating System as a Resource Manager
Allow multiple programs to run at the same time Manage and protect memory, I/O devices, and other resources Includes multiplexing (sharing) resources in two different ways: In time In space Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

12 The Operating System as a Resource Manager
When a resource is time multiplexed, different programs or users take turns using it. First one of them gets to use the resource, then another, and so on. For example, with only one CPU and multiple programs that want to run on it, the operating system first allocates the CPU to one program, then after it has run long enough, another one gets to use the CPU, then another, and then eventually the first one again.

13 Time mux…cont…. Determining how the resource is time multiplexed who goes next and for how long is the task of-- the operating system. Example of time multiplexing is sharing the printer. When multiple print jobs are queued up for printing on a single printer, a decision has to be made about which one is to be printed next.

14 Space Multiplexing The other kind of multiplexing is space multiplexing, instead of the customers taking turns, each one gets part of the resource. For example, main memory is normally divided up among several running programs, so each one can be resident at the same time (for example, in order to take turns using the CPU). This raises issues of fairness, protection, and so on, and it is up to the operating system to solve them.

15 The First Generation (1945-55) Vacuum Tubes and Plugboards
The first ones used mechanical relays but were very slow, with cycle times measured in seconds. Relays were later replaced by vacuum tubes. These machines were filling up entire rooms with tens of thousands of vacuum tubes, but they were still millions of times slower than even the cheapest personal computers available today.

16 The Second Generation (1955-65) Transistors and Batch Systems
The introduction of the transistor in the mid-1950s changed the picture radically. These machines, now called mainframes, were locked away in specially air conditioned computer rooms

17 Only big corporations or major government agencies or universities could afford price.
To run a job (i.e., a program or set of programs), a programmer would first write the program in FORTRAN or assembler, then punch it on cards. He would then bring the card deck down to the input room and hand it to one of the operators and go drink coffee until the output was ready.

18 When the computer finished whatever job it was currently running, an operator would go over to the printer and tear off the output and carry it over to the output room, so that the programmer could collect it later.

19 Given the high cost of the equipment, people quickly looked for ways to reduce the wasted time. The solution was the batch system. The idea behind it was to collect a tray full of jobs in the input room and then read them onto a magnetic tape using a small (relatively) inexpensive computer such as the IBM 1401, which was very good at reading cards, copying tapes, and printing output, but not at all good at numerical calculations. Other, much more expensive machines, such as the IBM 7094, were used for the real computing.

20

21 The Third Generation (1965-1980) ICs and Multiprogramming
The 360 was the first major computer line to use (small-scale) Integrated Circuits (ICs), thus providing a major price/performance advantage over the second-generation machines, which were built up from individual transistors. It was an immediate success, and the idea of a family of compatible computers was soon adopted by all the other major manufacturers.

22 They popularized several key techniques absent in second-generation operating systems. Probably the most important of these was multiprogramming. Having multiple jobs safely in memory at once requires special hardware to protect each job against mischief by the other ones, but the 360 and other third-generation systems were equipped with this hardware.

23

24 Another major feature present in third-generation operating systems was the ability to read jobs from cards onto the disk as soon as they were brought to the computer room. When a running job finished, the operating system could load a new job from the disk into the now-empty partition and run it. This technique is called spooling (from Simultaneous Peripheral Operation On Line) and was also used for output.

25 This desire for quick response time paved the way for timesharing, a variant of multiprogramming, in which each user has an online terminal. In a timesharing system, if 20 users are logged in and 17 of them are thinking or talking or drinking coffee, the CPU can be allocated in turn to the three jobs that want service

26 The Fourth Generation (1980-Present) Personal Computers
With the development of LSI (Large Scale Integration) circuits, chips containing thousands of transistors on a square centimetre of silicon. Where the minicomputer made it possible for a department in a company or university to have its own computer, the microprocessor chip made it possible for a single individual to have his or her own personal computer. Engelbart invented the GUI (Graphical User Interface), pronounced “gooey,” complete with windows, icons, menus, and mouse.

27 What is Multiprogramming, Multiprocessing and Multitasking.
In a multiprogramming system there are one or more programs loaded in main memory which are ready to execute. Only one program at a time is able to get the CPU for executing its instructions (i.e., there is at most one process running on the system) while all the others are waiting their turn.

28 Multiprocessing sometimes refers to executing multiple processes (programs) at the same time.
In fact, multiprocessing refers to the hardware (i.e., the CPU units) rather than the software (i.e., running processes). If the underlying hardware provides more than one processor then that is multiprocessing.

29 Multitasking Multitasking refers to having multiple (programs, processes, tasks, threads) running at the same time. The illusion of parallelism is achieved when the CPU is reassigned to another task (i.e. process or thread context switching).

30 48 THE OPERATING SYSTEM ZOO:- Mainframe Operating Systems Server Operating Systems Multiprocessor Operating Systems Personal Computer Operating Systems Real-Time Operating Systems Embedded Operating Systems Smart Card Operating Systems

31 Mainframe Operating Systems
These computers distinguish themselves from personal computers in terms of their I/O capacity. A mainframe with 1000 disks and thousands of gigabytes of data is not unusual. Mainframes are also making something of a comeback as high-end Web servers, servers for large-scale electronic commerce sites, and servers for business-to-business transactions

32 Server Operating Systems
They run on servers, which are either very large personal computers, workstations, or even mainframes. They serve multiple users at once over a network and allow the users to share hardware and software resources. Servers can provide print service, file service, or web service. Internet providers run many server machines to support their customers and Web sites use servers to store the Web pages and handle the incoming requests. Typical server operating systems are UNIX and Windows Linux is also gaining ground for servers.

33 Multiprocessor Operating Systems
An increasingly common way to get major-league computing power is to connect multiple CPUs into a single system. These systems are called parallel computers, multicomputer, or multiprocessors.

34 Personal Computer Operating Systems
Their job is to provide a good interface to a single user. They are widely used for word processing, spreadsheets, and Internet access. Common examples are Windows 98, Windows 2000, the Macintosh operating system, and Linux.

35 Real-Time Operating Systems
These systems are characterized by having time as a key parameter. For example, in industrial process control systems, real-time computers have to collect data about the production process and use it to control machines in the factory. Often there are hard deadlines that must be met. For example, if a car is moving down an assembly line, certain actions must take place at certain instants of time, if a welding robot welds too early or too late, the car will be ruined. If the action absolutely must occur at a certain moment (or within a certain range), we have a hard real-time system.

36 Another kind of real-time system is a soft real-time system, in which missing an occasional deadline is acceptable. Digital audio or multimedia systems fall in this category.

37 Embedded Operating Systems
A palmtop computer or PDA (Personal Digital Assistant) is a small computer that fits in a shirt pocket and performs a small number of functions such as an electronic address book and memo pad. Embedded systems run on the computers that control devices that are not generally thought of as computers, such as TV sets, microwave ovens, and mobile telephones. Examples of such operating systems are PalmOS and Windows CE (Consumer Electronics).

38 Smart Card Operating Systems
The smallest operating systems run on smart cards, which are credit card-sized devices containing a CPU chip. They have very severe processing power and memory constraints. Some of them can handle only a single function, such as electronic payments, but others can handle multiple functions on the same smart card.

39 Computer Hardware Review
Figure 1-6. Some of the components of a simple personal computer. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

40 Hardware: processor Brain of computer
Fetches instruction from memory and execute Cycle of CPU: fetch, decode, execute CPU has registers to store variable and temporary result: load from memory to register; store from register to memory Program counter: next instruction to fetch Stack pointer: the top of the current stack PSW: program status word, priority, mode(User and kernel)…

41 Figure 1-7. (a) A three-stage pipeline. (b) A superscalar CPU.
CPU Pipelining Superscalar CPU :Superscalar describes a microprocessor design that makes it possible for more than one instruction at a time to be executed  . Figure 1-7. (a) A three-stage pipeline. (b) A superscalar CPU. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

42 Figure 1-9. A typical memory hierarchy.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

43 Disks Cheap and large: two orders better than RAM
Slow: three orders worse than RAM Mechanical movement to fetch data Disk helps to implement Virtual Memory

44 Disks Tracks are divided into sectors (512 bytes)
Multiple tracks form a cylinder. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

45 Memory Management Unit
Many computer support a scheme known as virtual memory It makes possible to run programs larger than physical memory by placing them on disk and using main memory as kind of cache for the most heavily executed parts. This scheme requires remapping memory addresses on the fly to convert the address the program generated to the physical address in RAM where the word is located. This mapping is done by a part of the CPU called the MMU (Memory Management Unit)

46 I/O Devices Controller runs a device-accepts commands from the OS and executes them Complicated business Eg. Gets command to read sector x on disk y. Must convert to (cylinder, sector, head) address, move arm to correct cylinder, wait for sector to rotate under the head, read and store bits coming off the drive, compute checksum, store bits as words in memory Controller contains a computer to run its device

47 Device Driver OS software that talks to controller-gives commands, accepts responses Each controller manufacturer supplies a driver for each OS Driver runs in kernel mode Controller has registers which are used to communicate with the driver Three modes of communication Polling Interrupts DMA

48 I/O by polling device Driver issues command to controller
Driver polls device until it is ready Eg Send character to printer controller and poll until it is ready to accept the next character Big use of CPU Called programmed I/O-not really used any more

49 Generate an interrupt when I/O is finished.
I/O by Interrupts Generate an interrupt when I/O is finished. Eg When character is finished being printed, interrupt CPU. Allows CPU to do something else while character is being printed

50 I/O by DMA Special (controller) chip
Avoids using the CPU as part of the transfer to/from memory CPU tells chip to set up transfer and take care of it Chip does as it it told and interrupts CPU when it is finished

51 The bus hierarchy In the beginning there was one bus-couldn’t handle the traffic when cpu and memories got faster and bigger Create a hierarchy of faster buses (PCI) and specialized buses (SCSI-Small Computer System Interface) and USB(Universal Serial Bus-used to connect slow devices )

52 The Operating System Zoo
Mainframe operating systems Server operating systems Multiprocessor operating systems Personal computer operating systems Handheld operating systems Embedded operating systems Sensor node operating systems Real-time operating systems Smart card operating systems

53 Operating System Concepts
Processes Address spaces Files Input/Output Protection The shell others Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

54 processes Process A process is fundamentally a container that holds information for a program to run

55 Processes Figure A process tree. Process A created two child processes, B and C. Process B created three child processes, D, E, and F. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved 55

56 Address Space The memory used by a process, in concept
Some processes need more memory than physically available– virtual memory

57 Figure 1-14. A file system for a university department.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

58 Files (2) Figure (a) Before mounting, the files on the CD-ROM are not accessible. (b) After mounting, they are part of the file hierarchy. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

59 Figure 1-16. Two processes connected by a pipe.
Files (3) Figure Two processes connected by a pipe. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

60 I/O, Protection/Shell I/O-big part of OS
Protection-UNIX uses rwx bits for each file 3 bits for owner, 3 for group, 3 for everyone else Shell (command interpreter) UNIX Has lots of flavors-sh,bash,csh, ksh Sort<file1>file2 Cat file 1 file 2 file3 | sort > /dev/lp

61 System calls The goal of interface between user programs and the operating system is primarily about dealing with the abstractions. System calls is the interface users contact with OS and hardware

62 Example of read system call
It has three parameters: the first one specifying the file, the second one pointing to the buffer, and the third one giving the number of bytes to read. Call from C program will look like count = read(fd, buffer, nbytes); The system call (and the library procedure) return the number of bytes actually read in count

63 If the system call cannot be carried out owing to an invalid parameter or a disk error, count is set to −1

64 Steps Step 1-3: The first and third parameters are called by value, but the second parameter is passed by reference, meaning that the address of the buffer (indicated by &) is passed, not the contents of the buffer. Step 4 :Then comes the actual call to the library procedure. This instruction is the normal procedure-call instruction used to call all procedures

65 Step 5 : library procedure puts the system-call number in a register
Step 6: Then it executes a TRAP instruction to switch from user mode to kernel mode and start execution at a fixed address within the kernel Step 7: The kernel code that starts following the TRAP examines the system-call number and then dispatches to the correct system-call handler, usually via a table of pointers to system-call handlers indexed on system-call number

66 Step 8: the system-call handler runs
Step 9: Once it has completed its work, control may be returned to the user-space library procedure at the instruction following the TRAP instruction Step 10: This procedure returns to the user program in the usual way procedure calls return Step 11: To finish the job, the user program has to clean up the stack, as it does after any procedure call

67 System Calls Figure The 11 steps in making the system call read(fd, buffer, nbytes).

68 System Calls for Process Management
The waitpid() system call suspends execution of the current process until a child specified by pid argument has changed state. By default,waitpid() waits only for terminated children, but this behaviour is modifiable via the options argument, as described below. OPTIONS:return immediately if no child has exited. Statloc:Specifies the location to which the child process' exit status is stored EXECVE:envp is an array of strings, conventionally of the form key=value, which are passed as environment to the new program. Figure Some of the major POSIX system calls.

69 Fork System call Fork is used to create a new process. It creates an exact duplicate of the original process The fork call returns a value, which is zero in the child and equal to the child’s PID (Process IDentifier) in the parent. After creation of process both parent and child starts execution from next instruction.

70 Main() { fork(); printf(“hi”); }

71 System Calls for File Management (1)
Figure Some of the major POSIX(The Portable Operating System Interface) system calls.

72 System Calls for File Management (2)
Figure Some of the major POSIX system calls. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

73 Miscellaneous System Calls
The kill() system call can be used to send any signal to any process group or process. If pid is positive, then signal sig is sent to the process with the ID specified by pid. If pid equals 0, then sig is sent to every process in the process group of the calling process. If pid equals -1, then sig is sent to every process for which the calling process has permission to send signals, except for process 1 (init), but see below. Figure Some of the major POSIX system calls.

74 Figure 1-20. Processes have three segments: text, data, and stack.
Memory Layout Figure Processes have three segments: text, data, and stack.

75 Operating Systems Structure
Operating system from inside has following types: Monolithic systems Layered systems Microkernels Client-server systems Virtual machines Exo-kernels.

76 Operating Systems Structure
Monolithic systems – basic structure: The operating system is written as a collection of procedures, linked together into a single large executable binary program. Each procedure in the system is free to call any other one. A main program that invokes the requested service procedure.

77 In terms of information hiding, there is essentially none—every procedure is visible to every other procedure. The services (system calls) provided by the operating system are requested by putting the parameters in a well-defined place (e.g., on the stack) and then executing a trap instruction. This instruction switches the machine from user mode to kernel mode and transfers control to the operating system

78 Having thousands of procedures that can call each other without restriction may also lead to a system that is difficult to understand. A crash in any of these procedures will take down the entire operating system Example : Unix , DOS .

79 Basic structure for the operating system:
1. A main program that invokes the requested service procedure. 2. A set of service procedures that carry out the system calls. 3. A set of utility procedures that help the service procedures

80 For each system call there is one service procedure that takes care of it and executes it.

81 A simple structuring model for a monolithic system.

82

83 Layered Systems A generalization of the approach is to organize the operating system as a hierarchy of layers, each one constructed upon the one below. Layer 0 deals with allocation of the processor, switching between processes when interrupts occurred. Above layer 0, the system consisted of sequential processes, each of which could be programmed without having to worry about the fact that multiple processes were running on a single processor

84 Layered Systems Layer 1 handles memory management. Layer 2 handled communication between each process and the operator console (that is, the user). Layer 3 took care of managing the I/O devices and buffering the information streams to and from them.

85 The system operator process was located in layer 5.
Layered Systems Layer 4 was where the user programs were found. They did not have to worry about process, memory, console, or I/O management. The system operator process was located in layer 5. Example: THE system

86 Figure 1-25. Structure of the THE operating system.
Layered Systems Figure Structure of the THE operating system.

87 Microkernel The basic idea behind the microkernel design is to achieve high reliability by splitting the operating system up into small, well-defined modules, only one of which—the microkernel—runs in kernel mode and the rest run as relatively powerless ordinary user processes. Example : MINIX3

88 In Minix 3 Outside the kernel, the system is structured as three layers of processes all running in user mode. The lowest layer contains the device drivers. Since they run in user mode, they do not have physical access to the I/O port space and cannot issue I/O commands directly.

89 Above the drivers is another user-mode layer containing the servers
Above the drivers is another user-mode layer containing the servers. One or more file servers manage the file system(s), the process manager creates, destroys, and manages processes User programs obtain operating system services by sending short messages to the servers asking for the POSIX system calls.

90 One interesting server is the reincarnation server, whose job is to check if the other servers and drivers are functioning correctly. In the event that a faulty one is detected, it is automatically replaced without any user intervention. In this way, the system is self healing and can achieve high reliability.

91 The system has many restrictions limiting the power of each process.
drivers can touch only authorized I/O ports

92 Figure 1-26. Structure of the MINIX 3 system.
Microkernels Figure Structure of the MINIX 3 system.

93 Figure 1-27. The client-server model over a network.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

94 Idea is to have two classes of processes, the servers, each of which provides some service, and the clients, which use these services. This model is known as the client-server model. Communication between clients and servers is often by message passing.

95 A PC sends a request for a Web page to the server and the Web page comes back. This is a typical use of the client-server model in a network. Thus the client-server model is an abstraction that can be used for a single machine or for a network of machines.

96 Virtual Machines Virtualization: When a Web hosting company offers virtual machines for rent, a single physical machine can run many virtual machines, each of which appears to be a complete machine. Customers who rent a virtual machine can run whatever operating system and software they want to, but at a fraction of the cost of a dedicated server Another use of virtualization is for end users who want to be able to run two or more operating systems at the same time, say Windows and Linux, because some of their favorite application packages run on one and some run on the other.

97 Virtual Machines Type 2 hypervisor makes uses of a host operating system and its file system to create processes, store files, and so on. After a type 2 hypervisor is started, it reads the installation CD-ROM (or CDROM image file) for the chosen guest operating system and installs the guest OS on a virtual disk, which is just a big file in the host operating system’s file system.

98

99 Exokernel Rather than cloning the actual machine, as is done with virtual machines, another strategy is partitioning it, giving each user a subset of the resources. At the bottom layer, running in kernel mode, is a program called the exokernel. Its job is to allocate resources to virtual machines and then check attempts to use them to make sure no machine is trying to use somebody else’s resources. Example: VM/360

100 Exokernel The advantage of the exo-kernel scheme is that it saves a layer of mapping. In the other designs, each virtual machine thinks it has its own disk, with blocks running from 0 to some maximum, so the virtual machine monitor must maintain tables to remap disk addresses (and all other resources). With the exokernel, this remapping is not needed.

101 The World According to C
The C language Header files Large programming projects The model of run time Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

102 World according to C Operating systems are large C programs consisting of many pieces written by many programmers C language Data types, variables, control statements… Header files: declaration, definition, macros… For a large programming project

103 The Model of Run Time Figure The process of compiling C and header files to make an executable.

104 A View of Operating System Services

105 Operating System Services (Cont)
One set of operating-system services provides functions that are helpful to the user (Cont): Communications – Processes may exchange information, on the same computer or between computers over a network Error detection – OS needs to be constantly aware of possible errors For each type of error, OS should take the appropriate action to ensure correct and consistent computing

106 Operating System Services (Cont)
Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them 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 Protection involves ensuring that all access to system resources is controlled Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts


Download ppt "OPERATING SYSTEMS Chapter 1 Introduction"

Similar presentations


Ads by Google