introduction to operating systems chapter 1. cs431 -cotter2 lecture objectives understand the...
TRANSCRIPT
Introduction toOperating Systems
Chapter 1
cs431 -cotter 2
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 3
Basic Computer System Operation
c acheCPU (*N)
device
Instructionsand data
Memory
Instructions
data
I/O R
equest
data
interrupt
DMA
cs431 -cotter 4
PC Hardware Review
cs431 -cotter 5
CPU Pipelining
Figure 1-7. (a) A three-stage pipeline. (b) A superscalar CPU.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 6
Figure 1-8. (a) A quad-core chip with a shared L2 cache. (b) A quad-core chip with separate L2 caches.
Multithreaded and Multicore Chips
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 7
Figure 1-9. A typical memory hierarchy. The numbers are very rough approximations.
Memory (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 8
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.
Memory (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 9
Figure 1-10. Structure of a disk drive.
Disks
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 10
Figure 1-11. (a) The steps in starting an I/O device and getting an interrupt.
I/O Devices
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 11
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 12
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 13
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 14
Figure 1-12. The structure of a large Pentium system
Buses
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 15
• Processes• Address spaces• Files• Input/Output• Protection• The shell• Evolution repeats itself
• Large memories• Protection hardware• Disks• Virtual memory
Operating System Concepts
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 16
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.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 17
Figure 1-14. A file system for a university department.
Files (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 18
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.
Files (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 19
Figure 1-16. Two processes connected by a pipe.
Files (3)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 20
Figure 1-17. The 11 steps in making the system call read(fd, buffer, nbytes).
System Calls
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 21
Figure 1-18. Some of the major POSIX system calls.
System Calls for Process Management
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 22
Figure 1-18. Some of the major POSIX system calls.
System Calls for File Management (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 23
Figure 1-18. Some of the major POSIX system calls.
System Calls for File Management (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 24
Figure 1-18. Some of the major POSIX system calls.
Miscellaneous System Calls
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 25
Figure 1-19. A stripped-down shell.
A Simple Shell
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 26
Figure 1-20. Processes have three segments: text, data, and stack.
Memory Layout
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 27
Figure 1-21. (a) Two directories before linking /usr/jim/memo to ast’s directory. (b) The same directories after linking.
Linking
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 28
Figure 1-22. (a) File system before the mount. (b) File system after the mount.
Mounting
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 29
Figure 1-23. The Win32 API calls that roughly correspond to the UNIX calls of Fig. 1-18.
Windows Win32 API
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 30
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.
Operating Systems Structure
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 31
Figure 1-24. A simple structuring model for a monolithic system.
Monolithic Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 32
Figure 1-25. Structure of the THE operating system.
Layered Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 33
Figure 1-26. Structure of the MINIX 3 system.
Microkernels
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 34
Figure 1-27. The client-server model over a network.
Client-Server Model
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 35
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 36
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 37
Figure 1-28. The structure of VM/370 with CMS.
Virtual Machines (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 38
Figure 1-29. (a) A type 1 hypervisor. (b) A type 2 hypervisor.
Virtual Machines (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 39
39
JAVA Virtual Machines
Java program
Java program
VM
Java Cmds
Java program
VM
Java Cmds
Java program
VM
Java Cmds
SPARC PowerPC Intel
cs431 -cotter 4040
Virtual MachineAdvantages / 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 41
• The C language• Header files• Large programming projects• The model of run time
The World According to C
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 42
Figure 1-30. The process of compiling C and header files to make an executable.
The Model of Run Time
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
cs431 -cotter 43
Summary
• Overview of Computer Hardware
• Different OS types
• OS Components– Concepts– System Calls– Structure
• OS Programming Language
cs431 -cotter 44
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 What is the difference between user mode and kernel mode?and kernel mode?
• Why are Virtual Machines becoming popular today in PCs?
• How is the Client / Server model being used today?