1 Chapter 3 Operating System Structure 2 Operating-System Structures System Components Operating...

75
1 Chapter 3 Operating System Structure
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    264
  • download

    7

Transcript of 1 Chapter 3 Operating System Structure 2 Operating-System Structures System Components Operating...

Page 1: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

1

Chapter 3

Operating System Structure

Page 2: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

2

Operating-System StructuresSystem ComponentsOperating System ServicesSystem CallsSystem ProgramsSystem Structure Virtual MachinesSystem Design and ImplementationSystem Generation

Page 3: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

3

Common System ComponentsProcess Management Main Memory ManagementSecondary-Storage Management I/O System ManagementFile ManagementProtection SystemNetworkingCommand-Interpreter System

§3.1

Page 4: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

4

Process Management A process is a program in execution. A

process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task.

A program by itself is not a process; a program is a passive entity, such as the contents of a file stored on disk.

A process is an active entity, with a program counter specifying the next instruction to execute.

§3.1.1程序管理

Page 5: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

5

Process Management The execution of a process must be

sequential. At any time, at most one instruction is executed on behalf of the process.

The operating system is responsible for the following activities in connection with process management. Process creation and deletion. process suspension and resumption. Provision of mechanisms for:

process synchronization process communication Deadlock handling

Page 6: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

6

Main-Memory Management Memory is a large array of words or bytes, each

with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices.

The CPU reads instructions from main memory during the instruction-fetch cycle, and both reads and writes data from main memory during the data-fetch cycle.

The main memory is generally the only large storage device that the CPU is able to address and access directly.

§3.1.2

Page 7: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

7

Main-Memory Management

To improve both the utilization of the CPU and the speed of the computer’s response to its users, we must keep several programs in memory.

The operating system is responsible for the following activities in connections with memory management: Keep track of which parts of memory are currently

being used and by whom. Decide which processes to load when memory space

becomes available. Allocate and deallocate memory space as needed.

Page 8: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

8

File Management A file is a collection of related information defined

by its creator. Commonly, files represent programs (both source and object forms) and data. It may be free-form or formatted rigidly.

The operating system is responsible for the following activities in connections with file management: File creation and deletion. Directory creation and deletion. Support of primitives for manipulating files and

directories. Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media.

§3.1.3

Page 9: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

9

I/O System ManagementThe peculiarities of I/O devices are

hidden from the bulk of the OS by the I/O subsystem, which consists of: A memory-management component that

includes buffering, caching, and spooling A general device-driver interface Drivers for specific hardware devices

§3.1.4

奇特

Page 10: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

10

Secondary-Storage Management Since main memory (primary storage) is volatile and

too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory.

Most modern computer systems use disks as the principle on-line storage medium, for both programs and data.

The operating system is responsible for the following activities in connection with disk management: Free space management Storage allocation Disk scheduling

§3.1.5

Page 11: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

11

Networking A distributed system is a collection of

processors that do not share memory, peripheral devices, or a clock. Each processor has its own local memory and clock.

The processors in the system are connected through communication lines, such as high-speed buses or networks.

The communication network design must consider message routing and connection strategies, and the problem of contention and security.

§3.1.6

Page 12: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

12

NetworkingA distributed system collects physically

separate, possibly heterogeneous, system into a single coherent system, providing user access to various system resources.

Access to a shared resource allows: Computation speed-up Increased data availability Enhanced reliability

Page 13: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

13

Networking OS usually generalize network access as a

form of file access, with the details of networking being contained in the network interface’s device driver.

WWW is a new access method improving existing file-transfer protocol (FTP) and network-file system (NFS) protocol by removing the need for a user to log in before she is allowed to use a remote resource.

Using the new protocol, http, a web browser send a request to the remote web server, and the information (text, graphics, links) is returned.

Page 14: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

14

Protection SystemProtection refers to a mechanism for

controlling access by programs, processes, or users to both system and user resources.

The protection mechanism must: distinguish between authorized and

unauthorized usage. specify the controls to be imposed. provide a means of enforcement.

§3.1.7

Page 15: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

15

Command-Interpreter SystemMany commands are given to the

operating system by control statements which deal with: process creation and management I/O handling secondary-storage management main-memory management file-system access protection networking

§3.1.8

Page 16: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

16

Command-Interpreter SystemThe program that reads and interprets

control statements is called variously: control-card interpreter command-line interpreter shell (in UNIX)

Its function is to get and execute the next command statement.

With a user-friendly shell making the system more agreeable to some users Mac, Windows and DOS, UNIX

Page 17: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

17

Operating System Services Program execution – system capability to load a

program into memory and to run it. I/O operations – since user programs cannot execute

I/O operations directly, the operating system must provide some means to perform I/O.

File-system manipulation – program capability to read, write, create, and delete files.

Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing.

Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs.

§3.2

Page 18: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

18

Additional Operating System FunctionsAdditional functions exist not for helping the user, but rather for ensuring efficient system operations.

• Resource allocation – allocating resources to multiple users or multiple jobs running at the same time.

• Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics.

• Protection – ensuring that all access to system resources is controlled.

Page 19: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

19

System Calls System calls provide the interface between a

running program and the operating system. Generally available as assembly-language

instructions. Languages defined to replace assembly language

for systems programming allow system calls to be made directly (e.g., C, C++, Perl)

Example: UNIX system calls may be invoked directly from a C or C++ program.

Example: System calls are part of the Win32 API, which is available for use by all the compilers written for Windows.

§3.3系統呼叫

Win32 is an application programming interface that is common to all Microsoft's 32-bit Windows operating systems. These include: Windows 95, Windows 98, Windows NT and

Windows CE.

Page 20: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

20

System CallsJava does not allow system calls to be

made directly, because a system call is specific to an OS and results in platform-specific code.

However, Java can call the “native” method, written in another language such as C or C++, to make the system call.

本土

Page 21: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

21

System Calls Three general methods are used to pass parameters

between a running program and the operating system. Pass parameters in registers. Store the parameters in a block or table in

memory, and the table address of the block is passed as a parameter in a register. (Figure 3.1)

Push (store) the parameters onto the stack by the program, and pop off the stack by operating system.

Block or stack methods are preferred because they do not limit the number or length of parameters being passed.

Page 22: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

22

Passing of Parameters– As A Table

Back

Page 23: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

23

System CallsSystem calls can be grouped roughly

into five major categories: Process control File manipulation Device manipulation Information maintenance communications

Page 24: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

24

Process Control A running program needs to be able to halt its

execution either normally (end) or abnormally (abort).

A process or job executing one program may want to load and execute another program.

If multiprogrammed, to create a new job or process (create process)

For controlling the execution, determine (get process attribute) and reset (set process attribute) the attributes of a job or process, and terminate the job or process we created (terminate process).

§3.3.1

Page 25: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

25

Process ControlHaving created new jobs or processes,

we may want to wait for a certain amount of time (wait time) for them to finish, or wait for a specific event to occur (wait event).

The jobs or processes should then signal when the event has occurred (signal event).

Page 26: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

26

Process Control MS-DOS Execution

At System Start-up Running a Program

Page 27: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

27

Process Control – UNIX UNIX is a multitasking system. When a user

logs on to the system, the shell (command interpreter) of the user’s choice is run.

The shell may continue while another program is executed.

To start a new process, the shell executes a fork system call. Then the selected program is loaded into memory via an exec system call, and the program is then executed.

The shell can either waits for the process to finish, or runs the process “in the background.”

多工

Page 28: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

28

Process Control – UNIX Running Multiple Programs

Page 29: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

29

Process Control – UNIX When a process is running in the

background, it cannot receive input directly from the keyboard, because the shell is using this resource. I/O is therefore done through files, or through a mouse and windows interface.

When the process is done, it executes an exit system call to terminate, returning to the invoking process a status code of 0, or a nonzero error code.

Page 30: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

30

File ManagementFirst need to be able to create or delete files, once created, we need to read, write, or reposition. Finally, need to close the file.

For determine the values of various attributes, two system calls, get file attribute and set file attribute, are required.

§3.3.2

Page 31: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

31

Device Management A running program may need additional

resources, such as memory, tape drives, access to files, and so on, to proceed.

If there are multiple users, we must first request the device. Once requested, we can read, write, and reposition the device. After finished with the device, we must release it.

The similarity between I/O device and files cause many OS, including UNIX and MS-DOS, to merge the two into a combined file-device structure.

§3.3.3

Page 32: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

32

Information MaintenanceFor transferring information between the

user program and the OS, such as the current time and date.

Other system calls may return info about the system, such as the number of current users, the OS version, the amount of free memory or disk space.

§3.3.4

Page 33: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

33

Communication Models

Message Passing Shared Memory

Message-passing modelShared-memory model

§3.3.5

Page 34: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

34

Message-Passing Model In this model, information is exchanged

through an interprocess-communication facility provided by the operating system.

For establishing the connection, the name of other end must be known.

Each computer in a network has a host name, such as an IP name. Similarly, each process has a process name which is translated by get hostid and get processid to identifier recognized by the OS.

Page 35: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

35

Message-Passing Model The recipient process give permission for

communication with an accept connection call.

System programs, daemons, receiving the connections by executing a wait for connection call and are awakened when a connection is made.

The source of the comm., the client, and the receiving daemon, known as a server, then exchange messages by read message and write message system calls. The close connection call terminates the communication.

Page 36: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

36

Shared-Memory Model In this model, processes use map memory system calls to gain access to regions of memory owned by other processes.

It requires that they agree to remove the restriction of preventing one process from accessing another process’ memory.

Page 37: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

37

Message passing is useful when smaller numbers of data need to be exchanged, because no conflicts need to be avoided.

Shared memory allows maximum speed and convenience of communication, as it can be done at memory speeds when within a computer. Problem exist, however, in the areas of protection and synchronization.

Communication Models

Page 38: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

38

System Programs System programs provide a convenient

environment for program development and execution. They can be divided into: File manipulation Status information File modification Programming language support Program loading and execution Communications Application programs

Most users’ view of the operation system is defined by system programs, not the actual system calls.

See Fig. 1-1

§3.4系統程式

Page 39: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

39

Fig. 1-1System Components

Back

Page 40: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

40

System UtilitiesMost OS supplies programs, known as

system utilities or application programs, useful in solving common problems or in performing common operations.

Command Interpreter is an important system program for an OS. Its main function is to get and execute the next user-specified command.

系統設施

指令解譯器

Page 41: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

41

Implementing Commands There are two ways to implement a command

issued by the user – contains the code in command interpreter itself implement by system programs, as in UNIX.

The command interpreter merely uses the command to identify a file to be loaded into memory and execute. Example: rm G In this way, new commands can be added to the system easily.

Problems of the second approach? THINK

Page 42: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

42

易受傷的

System Structure – Simple ApproachMS-DOS – written to provide the most

functionality in the least space not divided into modules Although MS-DOS has some structure, its

interfaces and levels of functionality are not well separated

Application programs are able to access the basic I/O routines and make system vulnerable to errant programs.

MS-DOS was limited by the hardware of its era:Intel 8088 provides no dual mode and no hardware protection, it has no choice but to leave the base

hardware accessible.

§3.5

Page 43: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

43

MS-DOS Layer Structure

Page 44: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

44

UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts. Systems programs 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; a large number of functions for one level.

System Structure – Simple Approach

§3.5.1

Page 45: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

45

UNIX System Structure

Enormous amount of functionality combined into one level. New version of

UNIX are designed to use more advanced hardware and the OS may be broken into pieces that are smaller and

more appropriate.

OS retain greater control over the computer and over the applications that using the computer. Implementors are

free to make changes to the inner working of the system. Information

hiding also leaves programmers free to implement the low level routines.

Page 46: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

46

System Structure – Layered Approach The operating system is divided into a

number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.

Main Adv: modularity. Layers are selected such that each uses functions (operations) and services of only lower-level layers.

This approach simplifies debugging and system verification. A layer can be debugged without any concern for the lower layer, which is assumed correct already.

§3.5.2

分層法

Page 47: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

47

An Operating System Layer

Page 48: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

48

Problems of Layered Approach

1. Careful planning is needed in order to give each layer appropriate definition.

2. Tend to be less efficient. Recently, fewer layers with more

functionality are being designed, providing most of the advantages of modularized code while avoiding the difficult problems of layer definition and interaction.

Page 49: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

49

Examples on layered approach

OS/2 – descendant of MS-DOS that adds multitasking and dual-mode operation with more layered fashion.

OS/2 advantages: Direct user access to low-level facilities is

not allowed. Providing more control over the hardware

and more knowledge of which resources each user program is using.

….

Page 50: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

50

OS/2 Layer Structure

Page 51: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

51

Examples on layered approach

Windows NT – The first release has low performance compared to Windows 95 for highly layer-oriented organization.

Windows NT 4.0 partially redressed the performance problem by moving layers from user space to kernel space and more closely integrating them.

Page 52: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

52

Microkernels Adopted by operating system Mach early in

1980s. Nonessential components are removed to

achieve a smaller kernel. Main function: provide a communication

facility between the client program and the various services.

Benefits: Extending the OS is easier. Easier to port from one hardware design to

another. More security and reliability.

§3.5.3微核心 Implemented as

system and user-level program

Page 53: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

53

MicrokernelsExample:

Digital UNIX – provides a UNIX interface to the user, but is implemented with a Mach kernel.

Apple MacOS X Server – based on the Mach kernel.

Windows NT – a hybrid structure. It is designed to run various applications, including Win32 (native Windows applications), OS/2, and POSIX. It provides a server that runs in user space for each application type.

Layer + Microkernel

Page 54: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

54

Windows NT Client-Server Structure

Page 55: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

55

Virtual MachinesA virtual machine takes the layered

approach to its logical conclusion. OS creates the illusion that a process has its own processor with its own (virtual) memory….a (virtual) copy of the underlying computer.

The VM operating system for IBM systems is the best example of the virtual-machine concept.

§3.6虛擬機器

Page 56: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

56

Virtual MachinesThe resources of the physical computer

are shared to create the virtual machines. CPU scheduling can create the

appearance that users have their own processor.

Spooling and a file system can provide virtual card readers and virtual line printers.

A normal user time-sharing terminal serves as the virtual machine operator’s console.

Page 57: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

57

System Models

Non-virtual Machine Virtual Machine

Page 58: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

58

Benefits of Virtual Machines The virtual-machine concept provides

complete protection of system resources since each virtual machine is isolated from all other virtual machines.

A virtual-machine system is a perfect vehicle for operating-systems research and development. System research and development is done on the virtual machine, instead of on a physical machine and, so, does not disrupt normal system operation.

§3.6.2

Page 59: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

59

Virtual Machines – examples Virtual Intel machine on top of Sun or DEC

computer in order to run MS-DOS programs. When a MS-DOS program is running in Sun or DEC computer, its Intel instructions are translated into the native instruction set.

PowerPC-based Apple Macintosh includes a Motorola 68000 virtual machine to allow execution of binary codes that were written for the older 68000-based Macintosh.

Key feature of Java – it runs on a virtual machine.

Page 60: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

60

JavaJava is a technology introduced by Sun

Microsystems in late 1995.Three essential components:

Programming-language specification Application-programming interface (API) Virtual-machine specification

§3.6.3

Page 61: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

61

Java Programming Language Object-oriented

Objects are specified with the class construct; a Java program consists of one or more classes.

Architecture-neutral Java compiler produces bytecode output (.class) file that

will run on any implementation of the Java virtual machine. Applets programs with limited resource access run within

a web browser. Distributed

Provide high level support for networking and distributed objects.

Multithreaded A Java program may have several different threads, or

flows, of control.

Page 62: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

62

Java APIThe API for java consists of:Base API

provides basic language support for graphics, I/O, utilities, and networking. Example: java.lang, java.awt, java.io, and java.net.

Standard extension APIincludes support for enterprise, commerce, security, and media.

As language evolves, many packages that were once part of the standard extension API are becoming part of the base API

Page 63: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

63

Java Virtual Machine (JVM)JVM is a specification for an abstract

computer.JVM consists of a class loader and a

Java interpreter that executes the bytecodes.

The class loader loads .class files from both the Java program and the Java API for execution by the Java interpreter.

Page 64: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

64

Java Virtual Machine

Page 65: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

65

Java Virtual Machine

Page 66: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

66

Java Virtual MachineJava interpreter may be a software

interpreter that interprets the bytecodes one at a time,

or it may be a just-in-time (JIT) compiler that turns the bytecodes into native machine language for the host computer.

The interpreter can also be implemented in a hardware chip that executes Java bytecodes natively.

Page 67: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

67

Java Virtual MachineThe Java platform consists of the JVM

and Java API. The Java platform may be implemented

on top of a host operating system, such as UNIX or Windows, as part of a web browser; or in hardware.

Page 68: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

68

System Design GoalsUser goals – operating system should

be convenient to use, easy to learn, reliable, safe, and fast.

System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient.

§3.7.1

Page 69: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

69

Mechanisms and Policies Mechanisms determine how to do something,

policies decide what will be done. Ex: Timer construct

The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later.

Ex: I/O Intensive programs have priority over CPU intensive programs?

Ex: Microkernel-based OS. It’s basic building blocks are almost policy free.

§3.7.2

Page 70: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

70

System ImplementationTraditionally written in assembly

language, operating systems can now be written in higher-level languages.

Code written in a high-level language: can be written faster. is more compact. is easier to understand and debug.

An operating system is far easier to port (move to some other hardware) if it is written in a high-level language.

§3.7.3

Page 71: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

71

ExampleMS-DOS was written in Intel 8088

assembly language. Consequently, it is available on only the Intel family of CPUs. The UNIX written in C is available on a number of different CPUs, including Intel 80X86, Motorola 680X0, SPARC, and MIPS RX000.

Page 72: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

72

System Implementation Major complaint about higher-level language

are reduced speed and increased storage requirements. (However….)

Modern processors can handle complex dependencies that can overwhelm the limited ability of the assembly-language programmer to keep track of details.

Major performance improvements in operating systems are more likely to be the result of better data structures and algorithms than of excellent assembly-language code.

Page 73: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

73

System Generation (SYSGEN) Operating systems are designed to run on

any of a class of machines; the system must be configured or generated for each specific computer site, a process known as system generation (SYSGEN).

SYSGEN program obtains information concerning the specific configuration of the hardware system, including What CPU is to be used? How much memory is available? What devices are available? What OS options are desired?

§3.8

Page 74: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

74

Hardware configuration information can be used in several ways: Used to modify a copy of the source code

of the OS and have it re-compiled. Used to create tables and modules from a

precompiled library. The needed modules are linked together to form the generated OS.

System generation is faster but the resulting system may be overly

general. Construct a system that is completely table driven. All the code is always part of the system, and selection occurs at execution time.

System Generation

Page 75: 1 Chapter 3 Operating System Structure 2 Operating-System Structures  System Components  Operating System Services  System Calls  System Programs.

75

System Generation

Major differences among above?Booting – starting a computer by

loading the kernel.Bootstrap program – code stored in

ROM that is able to locate the kernel, load it into memory, and start its execution.

THINK