Chapter 2, Operating System Structures
description
Transcript of Chapter 2, Operating System Structures
![Page 1: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/1.jpg)
1
Chapter 2, Operating System Structures
![Page 2: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/2.jpg)
2
2.1 Operating System Services
• Overview List:– User interface– Program execution– File system– Communications– Error detection– Efficiency functionality– Security
![Page 3: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/3.jpg)
3
• User interface:– Command line– Batch– Graphical user interface
• Program execution– Load– Run– End successfully or not
![Page 4: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/4.jpg)
4
• I/O operations– Access to physical devices (usually protected—a
system service)• File system manipulation, files, directories– Read, write– Make, delete– Find, navigate
![Page 5: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/5.jpg)
5
• Communications– Inter-process communication– Same computer or different systems– Message passing– Or shared memory
• Error detection– In CPU– In memory– In user program– Detect and handle gracefully, allowing continued use of the
system.
![Page 6: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/6.jpg)
6
• O/S functions to promote efficiency, especially on multi-user systems– Resource allocation
• Scheduling CPU cycles• memory access• I/O• file system, etc.
– Accounting• How much of each resource used by each user• In what pattern• At what times• Billling and system configuration
![Page 7: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/7.jpg)
7
• Protection and security– Logins and rwx type permissions– Protecting one process from another (in memory)– Protecting from outside intrusions
![Page 8: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/8.jpg)
8
2.2 User Operating System Interface
• Overview List:• Command interpreter function• Command interpreter architecture• GUI• Choice of interface
![Page 9: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/9.jpg)
9
• Command interpreter function– Setup for a command line interface– Gives the prompt– Takes in the command and takes action
• Command interpreter architecture– May be part of the kernel– May be run as a separate program– May include the code to be run as subroutines– May call separate system programs based on the
command entered
![Page 10: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/10.jpg)
10
• GUI—no important new information here• Choice of interface– User preference– Note power of programming in a command line
interface vs. a GUI
![Page 11: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/11.jpg)
11
2.3 System Calls
• Overview list:– Explicit system calls– Embedded system calls– Implicit system calls– Passing parameters in the system– System calls in Java
![Page 12: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/12.jpg)
12
• Explicit system call– Example: copying a file– Entered from command line or through GUI– One user system call may result in a sequence of
internal system calls• Embedded system call– In ASM, C, C++, etc., it is possible to include lines
of code containing system calls
![Page 13: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/13.jpg)
13
• Implicit system calls– The compiler translates user instructions to
machine instructions– At run time, machine instructions which are
protected trigger system calls– The classic example is file I/O
![Page 14: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/14.jpg)
14
• Passing parameters in the system– Stored in registers– Stored in memory, memory address stored in
register– Pushed onto the stack
• Note that this heading is relevant to the topic of system calls
• Various system calls require that parameters be passed when (before) the call is made
![Page 15: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/15.jpg)
15
• System calls in Java– Write a method in Java declared “native”– Let the native method be a holder for C or C++
(system language) code– The C/C++ code can call system programs– Note that the Java code is now platform
dependent, not portable
![Page 16: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/16.jpg)
16
2.4 Types of System Calls
• Overview List:– Process control– File management– Device management– Information management– Communications
![Page 17: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/17.jpg)
17
• Process control– End, abort– Load, execute– Create, terminate– Get attributes, set attributes– Wait for time– Wait for even, signal event– Allocate and free memory
![Page 18: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/18.jpg)
18
• File management– Create, delete– Open, close– Read, write, reposition– Get attributes, set attributes
• Device management– Request, release– Read, write, reposition– Get attributes, set attributes– Logically attach or detach
![Page 19: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/19.jpg)
19
• Information management– Get time or date, set time or date– Get system data, set system data– Get process, file, or device attributes– Set process, file, or device attributes
• Communications– Create, delete communication connection– Send, receive messages– Transfer status information– Attach or detach remote devices
![Page 20: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/20.jpg)
20
2.5 System Programs
• Representative of O/S code that’s not in the kernel
• Some items are interfaces to call system services
• Some are distinct system programs or collections of programs
![Page 21: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/21.jpg)
21
• Six categories (overlapping with previously presented lists)– File management– Status information– File modification– Programming language support (compilers,
assemblers, interpreters, debuggers)– Program loading and execution (absolute loaders,
relocatable loaders, linkers, etc.)– Communications
![Page 22: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/22.jpg)
22
2.6 Operating System Design and Implementation
• Overview List:– Parameter 1: What kind of hardware?– Parameter 2: What kind of system?– Parameter 3: User requirements– Parameter 4: Developer requirements– Mechanisms and policies– Examples– O/S implementation
![Page 23: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/23.jpg)
23
• Parameter one: What kind of hardware?• Parameter two: What kind of system?– Single user– Multi-user– Distributed– Real-time, etc.
![Page 24: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/24.jpg)
24
• Parameter three: User requirements– Easy to learn, use, etc.– Fast, safe, reliable, etc.– Note that there is no obvious connection between
these requirements and how you code the system in order to meet them
• Parameter four: Developer requirements– Easy to design, implement, maintain, etc.
![Page 25: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/25.jpg)
25
• Mechanisms and policies• Software design principle, separate the two– Policy = what to do– Mechanism = how to do it
• In other words, don’t hardcode policy• Implement mechanisms that can enforce
different policies depending on input parameters
![Page 26: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/26.jpg)
26
• Examples• Unix– The micro-kernel can support batch, time-sharing, real-time,
or any combination– What is supported depends on values in tables loaded at start-
up• Windows takes the opposite approach– Mechanism and policy are tightly coupled– The system is relatively inflexible– There is a reason for this: It enforces the same look and feel
across all installations
![Page 27: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/27.jpg)
27
• O/S implementation• Originally: assembly language• Modern systems• ~10% assembly language– Context switching– Possibly process scheduling– Possibly memory management
• ~90% C—all remaining system functionality
![Page 28: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/28.jpg)
28
2.7 Operating System Structure
• Overview List:– Simple structure/no structure/monolithic– The layered approach– Modular design (object-oriented)
![Page 29: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/29.jpg)
29
• Simple structure = not well structured– Simple systems that grew without a plan– Systems where immediate performance needs
were paramount– Monolithic systems in general
![Page 30: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/30.jpg)
30
MS DOS example
![Page 31: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/31.jpg)
31
• The left hand set of arrows represents a layered path through the software
• The right-hand, non-layered path enabled performance, but made the system error-prone
![Page 32: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/32.jpg)
32
Original Unix example
![Page 33: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/33.jpg)
33
• The original Unix was no better• Superficially layered• The layers contained lots of stuff• Internally the layers were undisciplined in
design
![Page 34: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/34.jpg)
34
The Layered Approach
![Page 35: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/35.jpg)
35
• Design functionality from the top down (from the outside in)
• Code and debug from the bottom up (from the inside out)
• Each layer has data structures, code, and interface• The implementation of the layers can change as long as
the interface discipline is maintained• Somewhat object-oriented• Less general because each layer interacts with two
neighbors only
![Page 36: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/36.jpg)
36
• The fundamental challenge of layered systems is breaking it into layers and getting the dependencies straight
• Each upper layer can only be implemented with calls to its lower neighbor
• Sorting this out in the kernel is not trivial. Which is lowest, process scheduling, memory management, or some other function?
• The practical disadvantage of layering is the performance cost of going down through the layers
![Page 37: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/37.jpg)
37
• Microkernels contain the bare minimum of system code– Process management– Memory management– Message passing
• The kernel remains small and fast and manageable by developers
![Page 38: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/38.jpg)
38
• All other system code written into modules– Modules run like user applications– But they are privileged to make system calls– Communication between them is managed by the
kernel• All other system programs can be changed
without affecting the kernel
![Page 39: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/39.jpg)
39
Modular Design (Solaris)
![Page 40: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/40.jpg)
40
• Object-oriented design• Kernel and other modules can be dynamically
loaded and linked to provide needed services• Different objects/modules can communicate
with each other• Modern Unix systems take this approach
![Page 41: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/41.jpg)
41
Mac OS X
![Page 42: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/42.jpg)
42
• BSD = Berkeley Standard Distribution (kernel)• Mach = Carnegie Mellon (micro-kernel)• Different O/S functions are handled by the
two• Mac OS X is a hybrid system
![Page 43: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/43.jpg)
43
2.8 Virtual Machines
• Logical conclusion of multi-user, multi-tasking• Logical conclusion of layering idea• Each user has access to a simulated hardware
interface• Each user can load a different O/S, access
different virtual peripherals, etc.
![Page 44: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/44.jpg)
44
• The challenge in implementation is keeping track of real system mode vs. user mode and virtual system mode vs. user mode
• With only one underlying machine there is only one real system mode, but there are many virtual system modes, one for each virtual machine
• Sharing and communication between virtual machines is also an important challenge in implementation
• A diagram follows
![Page 45: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/45.jpg)
45
![Page 46: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/46.jpg)
46
Benefits of virtual machines
• Users can run different O/S’s• Users are completely isolated from each other• System developers can work on O/S and other
system code on one virtual machine while users run on the others
• The original VM system—IBM mainframe—now configured to run Linux as well as CMS
• VMware runs on Intel systems, making it possible to load >1 O/S on a system at a time
![Page 47: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/47.jpg)
47
2.9 Java
• Java has three parts– Programming language specification– Application programming interface (API)– Virtual machine specification
![Page 48: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/48.jpg)
48
• Programming language characteristics– Object-oriented– Architecture neutral– Distributed– Multi-threaded– Secure– With automatic garbage collection
![Page 49: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/49.jpg)
49
• Java API editions– JSE = standard edition• Desktop applications and network applets• Graphics, I/O, security, db connectivity, networking
– EE = enterprise edition• Server applications with db support
– ME = micro edition• Applications on phones, pagers, handheld devices…
![Page 50: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/50.jpg)
50
• The Java Virtual Machine = JVM• The Java platform =– An implementation of the JVM specification for any
given hardware environment– Plus the Java API
• The Java platform can be implemented– On top of a host O/S– In a browser– Or the JVM can be implemented in hardware
![Page 51: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/51.jpg)
51
About the JVM• In a software environment, when main() is called in an
application, this causes an instance of the JVM to be created• Each separate application or applet in execution has its own
JVM• The JVM consists of a loader and an interpreter. The loader
loads a .class file containing Java byte code• The interpreter, or just in time compiler, translates Java code
into the commands and calls necessary in a given environment
• Implementations of the JVM differ across environments, but not the specification
![Page 52: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/52.jpg)
52
Running a Java Program
![Page 53: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/53.jpg)
53
Random additional comments
• For development purposes a Java Development Environment would consist of a compiler plus a Java Runtime Environment (JRE)
• In theory you might write an O/S with a microkernel in C/ASM and the rest in Java, using Java’s type safety mechanism for security. JX is an example
• The MS .NET framework is similar to the Java approach
![Page 54: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/54.jpg)
54
2.10 Operating System Debugging
• This is a new section in the latest edition of the book• It can be summarized as, “If you ever had to debug
an operating system, it might be the hardest thing you ever had to do.”
• Kernighan’s Law appears here, and it’s memorable• Failure analysis and performance tuning are
worthwhile concepts, but the details are unimportant
• DTrace is of no particular consequence to use
![Page 55: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/55.jpg)
55
2.11 Operating System Generation
• System generation = installing and setting up an O/S on a machine
• Most O/S’s can function on multiple hardware platforms
![Page 56: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/56.jpg)
56
• Installation requires setting parameters:– What CPU, how many, which instruction set(s)?– How much main memory?– What attached devices, type and model,
numerical designation, interrupt number– O/S parameters: scheduling algorithm, number of
I/O buffers, number of processes allowed, etc.
![Page 57: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/57.jpg)
57
• Approaches to system generation fall into a range:– Set parameters in source, compile O/S, install– Select precompiled modules from libraries– Table driven—select options after O/S is up and
running
![Page 58: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/58.jpg)
58
• O/S performance parameters– Ease and speed of installation and set-up– Performance speed and memory size at run time– Ease of modification
![Page 59: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/59.jpg)
59
• Ease of modification– Most systems probably have elements of both:• Major modifications: Change settings, recompile,
reinstall• Minor modifications: Change settings from table
options on the fly
![Page 60: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/60.jpg)
60
2.12 System Boot
• Already covered while going over chapter 1
![Page 61: Chapter 2, Operating System Structures](https://reader035.fdocuments.us/reader035/viewer/2022062315/5681632e550346895dd3a870/html5/thumbnails/61.jpg)
61
The End