Operating System
Operating System
Operating System
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 ?
Introduction 3
Computer System Components
Introduction 5
Operating System Definitions
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
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
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
Introduction 14
Example
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
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
Introduction 20
Windows - History
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
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
Introduction 29
Scheduling and Resource
Management
Fairness
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
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
Introduction 35
Some Major POSIX system calls
File management
Call Description
fd = open(file,how,…) Open a file for read/write
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
Introduction 44
Virtual Machines
Introduction 45
The Java Virtual Machine
Introduction 46
The operating System Zoo
Introduction 49