Introduction
Chapter 1
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Components of a Modern
Computer
– One or more processors
– Main memory
– Disks
– Printers
– Keyboard
– Mouse
– Display
– Network interfaces
– I/O devices
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Components of a Modern
Computer (2)
Figure 1-1. Where the operating system fits in.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Four Components of a Computer
System
People,
machines,
other
computers
CPU, memory,
I/O devices
The Operating System as an
Extended Machine
Figure 1-2. Operating systems turn ugly hardware into
beautiful abstractions.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The Operating System as a
Resource Manager
• Top down view
– Provide abstractions to application programs
• Bottom up view
– Manage pieces of complex system
• Alternative view
– Provide orderly, controlled allocation of resources
• Sharing resources in time
• Sharing resources in space
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
What is an Operating System?
• A program that acts as an intermediary between a
user of a computer and the computer hardware
• Operating system goals:
– Execute user programs and make solving user problems
easier
– Provide abstractions to application programs: make
computer system convenient to use
– Provide orderly, controlled, efficient allocation of resources
History of Operating Systems
• The first generation (1945–55) vacuum tubes
• The second generation (1955–65) transistors
and batch systems
• The third generation (1965–1980) ICs and
multiprogramming
• The fourth generation (1980–present) personal
computers
• The fifth generation (1990–present) mobile
computers
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Glen Beck
and
Betty Snyder
program
ENIAC. (U.S.
Army photo)
ENIAC (Electronic Numerical Integrator And Computer)
was the first electronic general-purpose computer. It was
Turing-complete, digital, and can be reprogrammed to solve "a large
class of
IBM/360 (2 million, 5 billion to built (budget 2 million)),
jewel of the office, Batch system
1970s, Unix System, PDF-7 (mini-computer)
DOS for Apple II: Contract
Current Generation OS
• Mobile devices (Smartphone, wearable
computers…)
– Limited power
– Different I/O: touch screen, cecullar communicaiton,
sensors, …
• Android, iOS, Windows
– Android's kernel is based on one of the Linux
kernel's long-term support (LTS) branches
• iOS (based upon Mac OS)
– iPhone, iPod, iPad, …
• …
Computer System Organization
• One or more CPUs, device controllers connected
through common bus providing access to shared
memory
Basic Hardware Elements
• Processor or Central Processing Unit (CPU)
– Controls operation, performs data processing
• Memory (main/primary memory)
– Volatile, i.e., data is typically lost when power is removed
– Used to store data and instructions
• I/O Modules: disk controller, USB controller, ...
– Moves data between computer and external device such
as storage (e.g. hard drive), communication equipment,
terminals
• System Bus
– Wires or backplane connecting CPUs, I/O modules and
main memory
Processor (CPU)
• CPU: the physical heart of entire computer system
– Execute instructions
• Instruction set: the set of machine instructions that a
processor can execute, main categories:
– Processor-memory: move data between memory and
processor
– processor-I/O: move data between peripheral device and
CPU
– Data processing: arithmetic or logic operation on data
– Control: alter execution sequence (jump, if and loop
structure)
• Some instructions are privilege instructions (can only be
executed by os kernel).
Registers of Processor
• Program Counter
– Memory address of the next instruction to be fetched
• Stack Pointer
– Points to the top of the current stack in memory
• PSW
– Contains the condition code bits
Processors
Figure 1-7. (a) A three-stage pipeline. (b) A superscalar CPU.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Singleprocessor & Multiprocessor
Most systems use a single general-
purpose processor
Multiprocessors systems growing
in use and importance
parallel systems, tightly-coupled
systems
Advantages include
1.Increased throughput
2.Economy of scale
3.Increased reliability – graceful
degradation or fault tolerance
Memory
Figure 1-9. A typical memory hierarchy. The numbers are
very rough approximations.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Memory Hierarchy
• CPU register
• CPU L1 cache
• Main memory, RAM – volatile storage media that CPU can
access directly
– Random access: take same amount of time to access any
part of the memory
• Hard disk: Large nonvolatile storage capacity
– disk controller: determines logical interaction between the
device and the computer
• Magnetic tape:
– sequential access: recall that you have to rewind VCR?
Why so many different
• memory/storage
Major constraints in memory
– Amount, Speed, Expense
• Generally:
– Faster access time, greater cost per bit
ns: nanosecond (10-9 seconds), 1 billionth second
Memory Hierarchy
• Goal: to obtain good
trade-off between cost
and performance
• Going down hierarchy
– Decreasing cost per bit
– Increasing capacity
– Increasing access time
– Decreasing frequency of
access
Caching
Figure 1-8. (a) A quad-core chip with a shared L2 cache.
(b) A quad-core chip with separate L2 caches.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Cashing
Caching system issues:
1. When to put a new item into the cache.
2.Which cache line to put the new item in.
3.Which item to remove from the cache when a
slot is needed.
4.Where to put a newly evicted item in the
larger memory.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Disks
Figure 1-10. Structure of a disk drive.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Input/Output Device Controller
• Device Controller:
• A chip or sets of chip that control I/O device to perform I/O
• Special purpose processor: execute concurrently with CPU
• Basic functionalities: moving data between device and
controller’s local buffer
• Has local buffer (registers): CPU communicates with device
controller through these, e.g., command, status,
input/output data
• Device driver: software that talks to device controller
I/O operation modes
Coordination between CPU and Device Controller
Programmed I/O: I will wait here until you are done with
this, “busy waiting”
Problem: most I/O devices are slower than CPU => inefficient for
CPU to wait for I/O to complete
Interrupt-driven I/O: let me know as soon as you are done...
Direct memory access (DMA): Work on the reports and when
you are done, put them in my mail box, and let me know...
Needs a mechanism to change the sequential instruction
execution of CPU
I/O Devices
Figure 1-11. (a) The steps in starting an I/O device
and getting an interrupt.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
I/O Devices
Figure 1-11. (b) Interrupt processing involves taking the interrupt,
running the interrupt handler, and returning to the user program.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Simple Interrupt Processing
Different Types of Interrupts
• Program generated: arithmetic overflow, division by zero,
illegal machine instruction, reference outside of user’s
allowed memory space, also called exception, trap or
software interrupt
• Timer: generated by a timer with CPU
• I/O: generated by I/O controller to signal completion of
operation or error condition
– Delivered to CPU via bus, together with device number
• Hardware failure: triggered by power failure, memory parity
error…
An operating system is interrupt driven.
Interrupt-driven I/O
• When CPU encounters an I/O related instruction
– it executes that instruction by issuing a command to
appropriate I/O module, and ask I/O module to give an
interrupt when done
– CPU continues to do its work without waiting for I/O
completion (maybe running other programs if it’s a blocking
call, such as cin, scanf…)…
– After I/O device controller finish I/O operation, it generate an
interrupt to inform CPU
– CPU, in interrupt handler, read data from device controller or
write next block of data to device controller, and wake up
processes waiting for the interrupt...
Direct Memory Access (DMA) I/O
• DMA: allow device to access memory for reading and/or
writing independently of CPU.
– Used in high-speed I/O devices: disk controllers, graphics
cards, network cards and sound cards
• DMA module (DMA device controller)
– Transfers blocks of data from buffer storage directly to
main memory
– Only one interrupt is generated per block
• CPU only involved at beginning and ending transfer.
– Less CPU intervention => much more efficient in terms of
processing times
Buses
Figure 1-12. The structure of a large x86 system
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Booting the computer
• Bios
– Low-level I/O software
• Bios Check
– Scanning PCIs
• Determine boot device
• Get configuration information
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The Operating System Zoo
• Mainframe Operating Systems
• Server Operating Systems
• Multiprocessor Operating Systems
• Personal Computer Operating Systems
• Handheld Computer Operating Systems
• Embedded Operating Systems
• Sensor Node Operating Systems
• Real-Time Operating Systems
• Smart Card Operating Systems
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Processes (1)
• Key concept in all operating systems
• Definition: a program in execution
• Process is associated with an address space
• Also associated with set of resources
• Process can be thought of as a container
– Holds all information needed to run program
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Processes (2)
Figure 1-13. A process tree. Process A created two child processes,
B and C. Process B created three child processes, D, E, and F.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Files (1)
Figure 1-14. A file system for a university department.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Files (2)
Figure 1-15. (a) Before mounting, the files on the CD-ROM are not
accessible. (b) After mounting, they are part of the file hierarchy.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Files (3)
Figure 1-16. Two processes connected by a pipe.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls (1)
Figure 1-17. The 11 steps in making the system call
read(fd, buffer, nbytes).
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls (2)
Figure 1-18. Some of the major POSIX system calls. The return code s
is −1 if an error has occurred. The return codes are as follows: pid is a
process id, fd is a file descriptor, n is a byte count, position is an offset
within the file, and seconds is the elapsed time.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls for Process
Management
Figure 1-19. A stripped-down shell. Throughout this book,
TRUE is assumed to be defined as 1.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Segments of Processes
• Text segment
– Program code
• Data segment
– variables
• Stack segment
Figure 1-20. Processes have three
segments:
text, data, and stack
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls (3)
Figure 1-18. Some of the major POSIX system calls. The return code s
is −1 if an error has occurred. The return codes are as follows: pid is a
process id, fd is a file descriptor, n is a byte count, position is an offset
within the file, and seconds is the elapsed time.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls (4)
Figure 1-18. Some of the major POSIX system calls. The return code s
is −1 if an error has occurred. The return codes are as follows: pid is a
process id, fd is a file descriptor, n is a byte count, position is an offset
within the file, and seconds is the elapsed time.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls for Directory
Management
Figure 1-21. (a) Two directories before linking usr/jim/memo
to ast’s directory. (b) The same directories after linking.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls for Directory
Management (2)
Figure 1-22. (a) File system before the mount.
(b) File system after the mount.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
System Calls (5)
Figure 1-18. Some of the major POSIX system calls. The return code s
is −1 if an error has occurred. The return codes are as follows: pid is a
process id, fd is a file descriptor, n is a byte count, position is an offset
within the file, and seconds is the elapsed time.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The Windows Win32 API (1)
Figure 1-23. The Win32 API calls that roughly correspond to
the UNIX calls of Fig. 1-18.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The Windows Win32 API (2)
Figure 1-23. The Win32 API calls that roughly correspond to
the UNIX calls of Fig. 1-18.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems (1)
Basic structure of OS
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.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems (2)
Figure 1-24. A simple structuring model
for a monolithic system.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Layered Systems
Figure 1-25. Structure of the THE operating system.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Client-Server Model
Figure 1-27. The client-server model over a network.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines
Figure 1-28. The structure of VM/370 with CMS.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines Rediscovered
Figure 1-29. (a) A type 1 hypervisor. (b) A pure type 2
hypervisor. (c) A practical type 2 hypervisor.
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
End
Chapter 1
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.