Computer System Structures
Download
Report
Transcript Computer System Structures
Introduction to
Operating Systems
Chapter 1
Lecture Objectives
• Understand the relationship between computing
hardware, operating system, and user level
applications
• Be able to discuss the different categories of
system calls common to Linux or Windows
operating systems.
• Discuss how the evolution of computing
hardware and the evolution of operating systems
have affected each other.
cs431 -cotter
2
Basic Computer System
Operation
CPU (*N)
cs431 -cotter
interrupt
data
I/O Request
device
c
a
c
h
e
Instructions
Instructions
and data
data
DMA
Memory
3
PC Hardware Review
cs431 -cotter
4
CPU Pipelining
Figure 1-7. (a) A three-stage pipeline. (b) A superscalar CPU.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
5
Multithreaded and Multicore Chips
Figure 1-8. (a) A quad-core chip with a shared L2 cache.
cs431 -cotter (b) A quad-core chip with separate L2 caches.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
6
Memory (1)
cs431 -cotter
Figure 1-9. A typical memory hierarchy.
The numbers are very rough approximations.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
7
Memory (2)
Questions when dealing with cache:
•
•
•
•
When to put a new item into the cache.
Which cache line to put the new item in.
Which item to remove from the cache when a
slot is needed.
Where to put a newly evicted item in the larger
memory.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
8
Disks
Figure 1-10. Structure of a disk drive.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
9
I/O Devices
Figure 1-11. (a) The steps in starting an I/O device and
getting an interrupt.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
10
Interrupt functions
• Most operating systems are interrupt driven
• Interrupt transfers control to interrupt service
routine through the interrupt vector
• Save address of interrupted instruction
• Disable interrupts during processing
• A trap is a software generated interrupt
cs431 -cotter
11
I/O Structure
• Control returns to user when I/O completes
– wait instruction idles CPU
– wait loop (contention for memory)
– only 1 I/O request outstanding at any time
• Control returns to user without waiting for I/O
– system call
– device-status table
– OS modifies table entry to include interrupt
cs431 -cotter
12
Hardware Protection Schemes
• Dual-Mode Operation
– user mode
– monitor mode / kernel mode
• I/O Protection
• Memory Protection
– base register
– limit register
• CPU Protection
–
timer
cs431 -cotter
13
Buses
Figure 1-12. The structure of a large Pentium system
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
14
Operating System Concepts
•
•
•
•
•
•
•
Processes
Address spaces
Files
Input/Output
Protection
The shell
Evolution repeats itself
•
•
•
•
Large memories
Protection hardware
Disks
Virtual memory
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
15
Processes
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.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
16
Files (1)
Figure 1-14. A file system for a university department.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
17
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
cs431
-cotter
18
hierarchy.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Files (3)
Figure 1-16. Two processes connected by a pipe.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
19
System Calls
Figure 1-17. The 11 steps in making the system call
cs431 -cotter
read(fd, buffer, nbytes).
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
20
System Calls for Process Management
Figure 1-18. Some of the major POSIX system calls.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
21
System Calls for File Management (1)
Figure 1-18. Some of the major POSIX system calls.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
22
System Calls for File Management (2)
Figure 1-18. Some of the major POSIX system calls.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
23
Miscellaneous System Calls
Figure 1-18. Some of the major POSIX system calls.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
24
A Simple Shell
Figure 1-19. A stripped-down shell.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
25
Memory Layout
Figure 1-20. Processes have three segments:
text, data, and stack.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
26
Linking
Figure 1-21. (a) Two directories before linking /usr/jim/memo to
ast’s directory. (b) The same directories after linking.27
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Mounting
Figure 1-22. (a) File system before the mount.
(b) File system after the mount.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
28
Windows Win32 API
Figure 1-23. The Win32 API calls that roughly correspond
to the UNIX calls of Fig. 1-18.
cs431 -cotter
29
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Operating Systems Structure
Monolithic systems – basic structure:
•
•
•
A main program that invokes the requested
service procedure.
A set of service procedures that carry out the
system calls.
A set of utility procedures that help the service
procedures.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
30
Monolithic Systems
Figure 1-24. A simple structuring model for a monolithic system.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
31
Layered Systems
Figure 1-25. Structure of the THE operating system.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
32
Microkernels
Figure 1-26. Structure of the MINIX 3 system.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
33
Client-Server Model
Figure 1-27. The client-server model over a network.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
34
Virtual Machines
• Pushes the layered concept to the next step
• Treats OS and hardware as though they were
both hardware by providing a software
(virtual) interface to the OS that is identical to
the hardware interface
• OS creates the illusion of several different
processes, each executing on its own
processor with its own (virtual) memory
cs431 -cotter
35
Virtual Machines
• CPU scheduling creates the appearance
that each process has its own processor.
• Spooling and a file system can provide
“virtual” line printers and “virtual” card
readers
cs431 -cotter
36
Virtual Machines (1)
Figure 1-28. The structure of VM/370 with CMS.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
37
Virtual Machines (2)
Figure 1-29. (a) A type 1 hypervisor. (b) A type 2 hypervisor.
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
38
JAVA Virtual Machines
Java program
Java program
Java program
Java program
Java Cmds
Java Cmds
Java Cmds
VM
SPARC
VM
VM
PowerPC
Intel
cs431 -cotter
39
39
Virtual Machine
Advantages / Disadvantages
• Provides complete isolation and protection of
resources between processes. (This also can
affect the ability to share between processes).
• Provides a good vehicle for reducing system
level complexity of IT systems
• Requires hardware support to allow execution
of privileged instructions in user mode.
cs431 -cotter
40
40
The World According to C
•
•
•
•
The C language
Header files
Large programming projects
The model of run time
cs431 -cotter
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
41
The Model of Run Time
Figure 1-30. The process of compiling C and header files to
make an executable.
cs431 -cotter
42
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Summary
• Overview of Computer Hardware
• Different OS types
• OS Components
– Concepts
– System Calls
– Structure
• OS Programming Language
cs431 -cotter
43
Questions:
• What is multi-programming? Why is it
important in OSs?
• What is the difference between a system
call and a local function call?
• What is the difference between user mode
and kernel mode?
• Why are Virtual Machines becoming
popular today in PCs?
• How is the Client / Server model being
used today?
cs431 -cotter
44