500 likes | 602 Views
Operating Systems. University of Haifa Extension Division. Administration. Lecturer – Aspis Ofir ofiras@netvision.net.il Course Home Page – Yet to come…. Administration. Text Books :
E N D
Operating Systems University of Haifa Extension Division Introduction
Administration • Lecturer – • Aspis Ofirofiras@netvision.net.il • Course Home Page – • Yet to come… Introduction
Administration • Text Books : • Applied Operating System Concepts –Silberschatz/Galvin/Gagnehttp://www.bell-labs.com/topic/books/aos-book • Modern Operating Systems –Tanenbaum • Linux Programming –Stones/Matthew • Advanced Windows –Richter Introduction
What is Operating System ? • A program that acts as an intermediary between a user of a computer and the computer hardware. • Operating system goals: • A program that controls the execution of application programs • Make the computer system convenient to use. • Use the computer hardware in an efficient manner. Introduction
Computer System Components 1. Hardware – provides basic computing resources (CPU, memory, I/O devices). 2. Operating system – controls and coordinates the use of the hardware among the various application programs for the various users. 3. Applications programs – define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs). 4. Users (people, machines, other computers). Introduction
Abstract View of System Components Introduction
Operating System Definitions • Resource allocator – manages and allocates resources. • Control program – controls the execution of user programs and operations of I/O devices . • Kernel – the one program running at all times (all else being application programs). Introduction
User-Services Provided by the Operating System • Program creation • Editor and debugger utility programs • Program execution • Loading instructions, initializing I/O devices • Access to I/O devices • Making it a simple R/W command • Controlled access to files • Media technology, file format, controlling access Introduction
User-Services Provided by the Operating System • Error detection and response • internal and external hardware errors • memory error • device failure • software errors • arithmetic overflow • access forbidden memory locations Introduction
Operating System as a resource manager • It is actually a program that is executed by the processor to control the processor! • Directs the processor in the use of system resources • Directs the processor when executing other programs • Processor stops executing the operating system in order to execute other programs and, then, gives the control back to the operating system Introduction
Operating System as a resource manager • Memory management is decided by the operating system and memory management hardware in the processor. • The operating system decides about the access of programs and files to I/O devices. • In case of multiple processors, it decides for them all Introduction
A bit of history • The First Generation (1945-55) –Vacuum Tubes and Plugboards Introduction
History (ctd.) • The Second Generation (1955-65)Transistors and Batch Systems • Using FORTRAN and assembly language • OS – FMS , IBSYS(for IBM7094) Introduction
History (ctd.) • The Third Generation (1965-1980) –Multiprogramming and SpoolingThe Primary development : PDPs computer and UNIX os • Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. • Spooling - While executing one job, the OS: • Reads next job from card reader into a storage area on the disk (job queue). • Outputs printout of previous job from disk to printer. • Job pool – data structure that allows the OS to select which job to run next in order to increase CPU utilization. Introduction
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. Introduction
Example JOB1 JOB2 JOB3 Type of job Heavy compute Heavy I/O Heavy I/O Duration 5 min. 15 min. 10 min. Memory required 50K 100 K 80 K Need disk? No No Yes Need terminal No Yes No Need printer? No No Yes Introduction
Effects of Multiprogramming Uniprogramming Multiprogramming Processor use 17% 33% Memory use 30% 67% Disk use 33% 67% Printer use 33% 67% Elapsed time 30 min. 15 min. Throughput rate 6 jobs/hr 12 jobs/hr Mean response time 18 min. 10 min. • The secret is the supporting hardware for I/O interrupts and DMA Introduction
Time sharing advantages • Using multiprogramming (multi-tasking) to handle multiple interactive jobs • Processor’s time is shared among multiple users • Multiple users simultaneously access the system through terminals • The objective is to minimize response time to the user commands Introduction
History (cont.) • The Fourth Generation(1980 – Present) –Personal Computers • 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 Introduction
Windows - History • DOS 1.00: 4000 lines of assembly language Introduction
Windows - History • DOS 2.0 in 1983, supported a hard disk, one directory, max 64 files • DOS 3.0 ran on Intel’s 286 processor, memory protection features and hard disk • DOS 3.1, 1984, supported networking • DOS 3.3, 1987, supported 386 processor • Windows 3.0, 1990, PC Graphical User Interface (GUI) for the 1st time Introduction
Windows - History • Windows NT developed from scratch to provide a multitasking single user environment. Version 3.1, 1993. • Windows 95-98 :Multitasking single user – not full 32bit • Win NT 4.0, 1996 – win95 GUI16 million lines of C code Introduction
Characteristics of Modern Operating Systems 1. Microkernel architecture • Assigns only a few essential functions to the kernel • address space • interprocess communication (IPC) • basic scheduling • Other functions run in user mode and treated like any other application Introduction
Characteristics of Modern Operating Systems 2. Multithreading • process is divided into threads that can run simultaneously • Thread • dispatchable unit of work • executes sequentially and is interruptable • Process is a collection of one or more threads • Useful when there is no need to serialize, e.g., database that deals with several clients Introduction
Characteristics of Modern Operating Systems 3. Symmetric multiprocessing • there are multiple processors transparent to the user • these processors share same main memory and I/O facilities • All processors can perform the same functions • Better performance (speed), availability (fault tolerance), growth, scaling (wide price range) Introduction
Multiprogramming vs.multiprocessing Introduction
Operating Systems Concepts • Process • Memory management • Information protection & security • Scheduling and resource management • The Shell Introduction
Process • A process consists of 3 components: • an executable program • associated data • execution context (PC, registers & status) • Improper synchronization • Status ensures that a process waiting for an I/O device receives the signal • Failed mutual exclusion • Priorities are included in context • Nondeterminate program operation • program should only depend on its input, not relying on common memory or order of running with others • Deadlocks • 2 or more programs awaiting each others! More later Introduction
Memory Management principals • Process isolation • Automatic allocation and management • Supporting long-term means of storage • achieves all of the above thru virtual memory and file system Introduction
Categories of Security and Protection • Access control • regulate user access to the system and data, e.g., permissions • Information flow control • regulate flow of data within the system and its delivery to users • Certification • proving that access and flow control perform according to specifications, e.g., passwords Introduction
Scheduling and Resource Management • Fairness • give equal and fair access to all processes that are charged the same rate • Differential responsiveness • discriminate between different classes of jobs • Efficiency • maximize throughput, minimize response time, and accommodate as many users as possible • Operations-research management problems Introduction
Operating System Service Call Handler Service Call from Process Long- Term Queue Interrupt from Process Short- Term Queue I/O Queues Interrupt Handler Interrupt from I/O Short-Term Scheduler Pass Control to Process Major elements of OS Short-term: In memory, ready to run on the CPU Scheduler picks one OS moves jobs from long-term to short-term queues without overcommitting memory or processor I/O Queue for each I/O device OS also decides assigning Processes to IO devices An interrupt or a service call invokes scheduler to pick a Process for execution Introduction
System Calls • System calls provide the interface between a running program 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. from C,C++ , or Perl programs) • Three general methods are used to pass parameters between a running program and the operating system. • Pass parameters in registers. • Store the parameters in a table in memory, and the table address is passed as a parameter in a register. • Push (store) the parameters onto the stack by the program, and pop off the stack by operating system. Introduction
Passing of Parameters As A Table Introduction
Increment SP Call Read Push fd Push &buffer Push nbytes Passing of Parameters by the Stack Library Procedure read 6 Return to caller 4 Trap to the kernel 5 Put code for read in register 10 11 User space User program Calling read 3 2 1 1 9 Dispatch Sys call handler Kernel space (OS) 7 8 Introduction
Some Major POSIX system calls • Process management Introduction
Some Major POSIX system calls • File management Introduction
System Calls for Process ManagementExample: UNIX/LINUX(POSIX) while(1) { type_prompt(); read_command(command,parameters); if(fork()!=0){ /*Parent code. */ waitepid(-1,&status,0); }else{ /*Child code */ execve(command,parameters,0); } } Introduction
Same Example in Win32 #include <stdio.h> #include <process.h> #include <windows.h> void main() { char s[80]; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); while(1){ printf("Shell: "); gets(s); if(!CreateProcess(NULL,s,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) fprintf(stderr, "CreateProcess failed." ); } /* // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); */ } Introduction
Process Segments FFFF Stack Gap Data Text 0000 Introduction
MS-DOS Execution Introduction
UNIX Running Multiple Programs Introduction
System Structure – Simple Approach • MS-DOS – written to provide the most functionality in the least space Introduction
System Structure – UNIX • UNIX – The kernel • Consists of everything below the system-call interface and above the physical hardware • Provides the file system, CPU scheduling, memory management, and other operating-system functions. Introduction
Windows NT • Kernel mode only has access to System data and hardware • Modular flexible structure. Introduction
Virtual Machines • A virtual machine provides an interface identical to the underlying bare hardware. • The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.. Introduction
The Java Virtual Machine Introduction
The operating System Zoo • Mainframe Operating Systems – • High-End Servers • Processes routine jobs without any interactive user present • OS/390 for example • Server Operating Systems • Run on Large PC or even on Mainframes • Print , file or web services • Unix , Windows 2000 , Linux Introduction
The operating System Zoo • Multiprocessor Operating Systems • Windows 2000 (up to 32 CPUs) , SunOS • PC Operating Systems • Running users applications • Multimedia support • Windows 98/Me/Xp • Real-Time Operating Systems • Time as a key parameter (hard dead line) • VxWorks , QNX Introduction
The operating System Zoo • Embedded Operating Systems • Run on a computer not generally thought of as computer, like TV ,microwave etc. • Have some characteristics of real-time systems • PalmOS , Windows CE • Smart Card Operating Systems • Very small - run on a credit card sized device • Some are Java Oriented (based on JVM) Introduction