Operating System

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 49

Operating Systems

1
Administration

 Text Books :
• Applied Operating System Concepts –
Silberschatz/Galvin/Gagne
http://www.bell-labs.com/topic/books/aos-book
• Modern Operating Systems –
Tanenbaum
• Linux Programming –
Stones/Matthew
• Advanced Windows –
Richter
Introduction 2
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 3
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 4
Abstract View of System Components

Introduction 5
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 6
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 7
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 8
Operating System as a resource
manager
 Itis 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 9
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 10
A bit of history
 The First Generation
(1945-55) –
Vacuum Tubes and
Plugboards

Introduction 11
History (ctd.)
 The Second
Generation (1955-65)
Transistors and Batch
Systems
• Using FORTRAN and
assembly language
• OS – FMS , IBSYS
(for IBM7094)

Introduction 12
History (ctd.)
 The Third Generation (1965-1980) –
Multiprogramming and Spooling
The 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 13
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 14
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 15
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 16
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 17
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 18
Windows - History

•DOS 1.00: 4000 lines of assembly language


Introduction 19
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 20
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 GUI
16 million lines of C code

Introduction 21
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 22
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 23
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 24
Multiprogramming vs. multiprocessing

Introduction 25
Operating Systems Concepts

1. Process
2. Memory management
3. Information protection & security
4. Scheduling and resource management
5. The Shell

Introduction 26
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 27
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 28
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 29
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 30
Major elements of OS
Short-term: In memory, ready
to run on the CPU
Operating System
Service Call Service
Scheduler picks one from Process Call Handler

OS moves jobs from long-term


to short-term queues without
overcommitting memory or Interrupt Long- Short- I/O
from Process Interrupt Term Term Queues
processor Interrupt Handler Queue Queue
from I/O
Short-Term
I/O Queue for each I/O device Scheduler
OS also decides assigning
Processes to IO devices
Pass Control
An interrupt or a service call to Process
invokes scheduler to pick a
Process for execution
Introduction 31
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 32
Passing of Parameters As A Table

Introduction 33
Passing of Parameters by the Stack
Library
6 Return to caller
Procedure
4 Trap to the kernel
5 Put code for read in register read
11 10
User Increment SP
space Call Read
3 User program
Push fd
2 Calling read
Push &buffer
1 Push nbytes
1 9

Kernel Dispatch Sys call


7 8 handler
space
(OS)

Introduction 34
Some Major POSIX system calls
 Process management

Call Description
pid = fork() Create a child process identical to
the parent
pid = waitpid(pid,&statloc,options) Wait for a child to terminate

s = execve(name,argv,environp) Replace a process

exit(status) Terminate process execution and


return status

Introduction 35
Some Major POSIX system calls
 File management
Call Description
fd = open(file,how,…) Open a file for read/write

s = close(fd) Close an open file

n = read(fd,buffer,nbytes) Read data from a file into a buffer

n = write(fd,buffer,nbytes) Write data from a buffer into a file

Introduction 36
System Calls for Process Management
Example: 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 37
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 38
Process Segments

Stack FFFF

Gap

Data

Text
0000

Introduction 39
MS-DOS Execution

Introduction 40
UNIX Running Multiple Programs

Introduction 41
System Structure – Simple Approach

 MS-DOS – written to
provide the most
functionality in the least
space

Introduction 42
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 43
Windows NT

 Kernel mode only


has access to
System data and
hardware
 Modular flexible
structure.

Introduction 44
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 45
The Java Virtual Machine

Introduction 46
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 47
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 48
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 49

You might also like