440 likes | 458 Views
Chapter 1: Introduction. What is the aim of the subject? Why are OSes important? What is an OS? A bit of history Some basic OS concepts How does an OS work? OS Structures. The Aim of the Subject. WILL NOT TEACH YOU HOW TO USE AN OPERATING SYSTEM. It will examine
E N D
Chapter 1: Introduction • What is the aim of the subject? • Why are OSes important? • What is an OS? • A bit of history • Some basic OS concepts • How does an OS work? • OS Structures
The Aim of the Subject WILL NOT TEACH YOU HOW TO USE AN OPERATING SYSTEM. • It will examine • the way in which an OS works • the algorithms and data structures inside an OS • the problems, solutions and trade offs in designing an OS TO ACHIEVE AN UNDERSTANDING OF HOW AN OPERATING SYSTEM WORKS.
Computer System Components • Application Software : Bank automation system, airline reservations, payroll etc. • System Software : OS, data base, compilers, editors etc.
What is SYSTEM SOFTWARE? • System software provides the environment and the tools to create the application software (sort of virtual machine) • It is also the interface between the hardware and the applications
Why is the OS Important? • The operating system is the foundation upon which all computing work is performed. • Knowledge of the internals of an OS is essential to achieve efficiency in • building software applications • deciding upon a computing platform
What is an Operating System? • A big, complex program (sometimes many) • It has two main purposes in life • An interface between the user and the hardware (provides a virtual machine) • Provide efficient, safe management of computing resources
Life without an OS • Every programmer would • have to know the hardware • be able to access the hardware • Every program • would contain code to do the same thing • probably do something wrong
Where does the OS Fit? System Calls Users and User Programs Operating System CPU & Memory Hardware I/O Devices
History :First Generation (1945-1955) • Vacuum tubes • No operating system • Programming is done by wiring a plug board • Applications are mostly numerical calculations (trajectory computations, computation of tables such as sine, cosine etc.)
History:Second Generation (1955-1965) • Transistors • Commercially produced computers • Very expensive and very slow computers compared with your old PC at home • Batch operation (collect jobs, run in one go, print all outputs)
Spooling (Simultaneous Peripheral Operation On-line) • off-line spooling • on-line spooling • Off-line spooling : replace slow I/O devices with I/O dedicated computers so that the main system sees these machines as its I/O devices
Early Batch Systems • bring cards to 1401 • read cards to tape • put tape on 7094 which does computing • put tape on 1401 which prints output
Applications are mostly scientific and engineering calculations (eg., solution of partial differential equations) • High level languages such as FORTRAN and COBOL
History:Third Generation (1965-1980) • Integrated circuits (small scale) packed as chips • I/O processors (channels) which can work in parallel with CPU - Multiprogramming
On-line spooling (using channels) • Time-sharing (TTY terminals and VDU’s) • Multics OS - original UNIX Minicomputers - Cheaper than mainframes but with limited hardware (eg. DEC PDPx)
History:Fourth Generation (1980-1990) • Large scale integration • Personal computers • CP/M, MS DOS, Unix operating systems • Networks
Now! • Client/Server computation • Clients : PCs, workstations running under Windows and UNIX operating systems • Servers : systems that run under UNIX and Windows NT • Internet and intranet networking (WWW)
Links for More History • http://www.old-computers.com • http://www.hitmill.com/computers/history/index.html • http://www.computerhistory.org/
Important Points • OS provides • a simpler, more powerful interface • higher level services • OS services only accessed via system calls • Users and programs can’t directly access the hardware Set of System Calls (APIs) is what programs think the operating system is.
Some OS Concepts • Kernel • The main OS program. Contains code for most services. Always in primary memory • Device Drivers • Programs that provide a simple, consistent interface to I/O devices • Typically part of the kernel
Some OS Concepts • Program • A static file of machine code on a disk • Process • A program in execution. • The collection of OS data structures and resources owned by a program while it is running.
Producing an Executable Source Code Object File Executable Compile Link Libraries and other Object files
A Simple Program to print a directory • #include <sys/types.h> • #include <dirent.h> • #include "ourhdr.h" • int main(int argc, char *argv[]) • { • DIR *dp; • struct dirent *dirp; • if (argc != 2) • err_quit("a single argument (the directory name) is required"); • if ( (dp = opendir(argv[1])) == NULL) • err_sys("can't open %s", argv[1]); • while ( (dirp = readdir(dp)) != NULL) • printf("%s\n", dirp->d_name); • closedir(dp); • exit(0); • } Functions supplied by system libraries. These functions will contain a trap instruction.
User Program #2 User Mode RAM 1.Program performs trap 2. OS determines service number 3. Service is located and executed. 4. Control returns to user program. User Program #1 trap 002 4 1 3 Based on a diagram from “Modern Operating Systems” by Andrew Tanenbaum. 2 Kernel System/Kernel Mode
Steps in Making a System Call There are 11 steps in making the system call : read (fd, buffer, nbytes)
A System Call Example • A stripped down shell: while (TRUE) { /* repeat forever */ type_prompt( ); /* display prompt */ read_command (command, parameters) /* input from terminal */ if (fork() != 0) { /* fork off child process */ /* Parent code */ waitpid( -1, &status, 0); /* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0); /* execute command */ } }
OS Structures • Monolithic systems • Hierarchy of layers • Virtual machines • Micro-kernel (client/server) model
SVC Program Interrupt Handler Service routine Monolithic System • OS has no structure but is a collection of procedures with well defined calling interfaces • Program - OS interface is via supervisor calls (SVC)
Monolithic System (Cont.) • OS code is a binded object program and its source code may be logically divided into • OS main program • System call service routines • Utility procedures which help service routines
Layered System • Structure of “THE” OS (a batch OS)
Layered System (Cont.) 0. Process switching, multi programming, CPU scheduling 1. Memory and swap space (disk) management (“segment controller”) 2. Message interpretation, job control (JCL) functions 3. I/O management (virtual peripherals) 4. User programs 5. Operator
Layered System (Cont.) • Synchronisation between layers : Hardware and software (semaphores) interrupts • Each layer provides some sort of a “virtual machine”
User Programs OS1 OS2 OS3 OS4 Virtual Machine PhysicalHardware Virtual Machines • VM provides “n” duplicates of physical hardware using software. So different Oses can work in the same machine at the same time
What is wrong so far? • OS is one large program that provides all the required services. • Anytime you add a new device you must • get a device driver for the device • recompile the kernel with the new device driver • reboot the machine so the new kernel will be used
Micro-Kernel (Client/Server) Model • OS is a minimal core known as Kernel.
The kernel contains the minimum of function • memory management • basic CPU management • inter-process communication (messages) • I/O support • Other functionality provided by user level processes
Characteristics of Kernel • Makes use of message passing • Easy to replace server processes • Easier to write and port OS • Design is perfect for distributed systems • Less performance