+ All Categories
Home > Documents > Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures

Date post: 15-Jan-2016
Category:
Upload: mindy
View: 28 times
Download: 0 times
Share this document with a friend
Description:
Chapter 2: Operating-System Structures. Chương 2: Cấu trúc Hệ điều hành. Chapter 2: Operating-System Structures. Operating System Services User Operating System Interface System Calls Types of System Calls System Programs Operating System Design and Implementation - PowerPoint PPT Presentation
Popular Tags:
79
Chapter 2: Operating-System Chapter 2: Operating-System Structures Structures
Transcript
Page 1: Chapter 2:  Operating-System Structures

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Page 2: Chapter 2:  Operating-System Structures

Chương 2: Cấu trúc Hệ điều hànhChương 2: Cấu trúc Hệ điều hành

Page 3: Chapter 2:  Operating-System Structures

2.3 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System Services

User Operating System Interface

System Calls

Types of System Calls

System Programs

Operating System Design and Implementation

Operating System Structure

Virtual Machines

Operating System Generation

System Boot

Page 4: Chapter 2:  Operating-System Structures

2.4 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Dịch vụ của hệ điều hành

Giao diện hệ điều hành của người dùng

System Calls

Các loại System Call

Chương trình hệ thống

Thiết kế và thực thi hệ điều hành

Cấu trúc hệ điều hành

Máy ảo

Sự hình thành của hệ điều hành

Khởi động hế thống

Page 5: Chapter 2:  Operating-System Structures

2.5 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

ObjectivesObjectives

To describe the services an operating system provides to users, processes, and other systems

To discuss the various ways of structuring an operating system

To explain how operating systems are installed and customized and how they boot

Page 6: Chapter 2:  Operating-System Structures

2.6 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Đối tượngĐối tượng

Mô tả về các dịch vụ của hệ điều hành cung cấp đến người dùng, process, và các hệ thống khác

Thảo luận về những cách khác nhau của cấu trúc hệ điều hành

Giải thích về cách hệ điều hành được cài đặt và tùy chỉnh và về cách hệ điều hành khởi động

Page 7: Chapter 2:  Operating-System Structures

2.7 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System ServicesOperating System Services

One set of operating-system services provides functions that are helpful to the user: User interface - Almost all operating systems have a user interface (UI)

Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch

Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)

I/O operations - A running program may require I/O, which may involve a file or an I/O device.

File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.

Page 8: Chapter 2:  Operating-System Structures

2.8 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Dịch vụ của hệ điều hànhDịch vụ của hệ điều hành

Một trong các dịch vụ của hệ điều hành là cung cấp những chức năng hữu dụng cho người dùng: Giao diện người dùng – Hầu hết tất cả các hệ điều hành đều có giao

diện người dùng (UI)

Khác nhau giữa Command-Line (CLI), Giao diện đồ họa người dùng (GUI), Batch

Sự thực thi chương trình – Hệ thống phải có thể nạp chương trình vào bộ nhớ và chạy chương trình đó, kết thúc chương trình cho dù nó bình thường hay không bình thường (có lỗi)

Hoạt động Nhập/Xuất- Một chương trình đang chạy có thể yêu cầu nhập/xuất, nó có thể liên quan đến một tập tin hoặc một thiết bị nhập/xuất.

Thao tác với hệ thống tập tin - Hệ thống tập tin là một phần đặc biệt. Rõ ràng, chương trình có thể đọc hoặc ghi tập tin và thư mục; tạo, xóa và tìm kiếm chúng, danh sách thông tin tập tin, quyền quản lý.

Page 9: Chapter 2:  Operating-System Structures

2.9 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System Services (Cont.)Operating System Services (Cont.)

One set of operating-system services provides functions that are helpful to the user (Cont): Communications – Processes may exchange information, on the same

computer or between computers over a network

Communications may be via shared memory or through message passing (packets moved by the OS)

Error detection – OS needs to be constantly aware of possible errors

May occur in the CPU and memory hardware, in I/O devices, in user program

For each type of error, OS should take the appropriate action to ensure correct and consistent computing

Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system

Page 10: Chapter 2:  Operating-System Structures

2.10 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Dịch vụ của hệ điều hành (tiếp theo)Dịch vụ của hệ điều hành (tiếp theo)

Một trong các dịch vụ của hệ điều hành là cung cấp những chức năng hữu dụng cho người dùng (tiếp theo): Giao tiếp – Process có thể thay đổi thông tin trên cùng một máy tính

hoặc giữa các máy tính trên mạng

Giao tiếp có thể thông qua bộ nhớ được chia sẻ hay những tin nhắn được chấp nhật (gói tin được chuyển bởi HĐH)

Sự phát hiện lỗi – HĐH cần thường xuyên nhận dạng những lỗi có thể xảy ra

Có thể xảy ra trên CPU và phần cứng bộ nhớ, trên thiết bị nhập/xuất, chương trình người dùng

Đối với mỗi loại lỗi, hệ điều hành nên dùng những hành động thích hợp để đảm bảo tính chính xác và phù hợp với máy tính

Phương tiện gỡ lỗi nâng cao hóa khả năng của người dùng và lập trình viên để khai thác hệ thống hiệu quả

Page 11: Chapter 2:  Operating-System Structures

2.11 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System Services (Cont.)Operating System Services (Cont.)

Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing Resource allocation - When multiple users or multiple jobs running

concurrently, resources must be allocated to each of them Many types of resources - Some (such as CPU cycles,mainmemory,

and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code.

Accounting - To keep track of which users use how much and what kinds of computer resources

Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other

Protection involves ensuring that all access to system resources is controlled

Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts

If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.

Page 12: Chapter 2:  Operating-System Structures

2.12 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Dịch vụ của hệ điều hành (tiếp theo)Dịch vụ của hệ điều hành (tiếp theo)

Một thiết lập khác của HĐH là làm sao cho hệ thống hoạt động hiệu quả thông qua việc chia sẻ tài nguyên Cấp phát tài nguyên – Khi nhiều người dùng hay nhiều việc chạy đồng thời,

tài nguyên phải được cấp phát tương ứng Có nhiều loại tài nguyên - Một vài thiết bị (như CPU, bộ nhớ chính, bộ lưu

trữ tập tin) có thể có mã cấp phát đặc biệt, một số khác (như thiết bị nhập/xuất) có thể có những truy vấn chung chung và mã phổ biến.

Tài khoản - theo dõi người dùng dùng bao nhiêu tài nguyên trên máy tính An ninh và bảo mật – Chủ sở hữu của thông tin trên một đa người dùng hoặc

hệ thống mạng máy tính có thể điều khiển và dùng thông tin đó, đồng thời lúc đó những process cũng không có can thiệp hay có tác động gì qua lại

An ninh đảm bảo tất cả truy cập vào tài nguyên hệ thống đều được giám sát

Bảo mật của hệ thống từ những người bên ngoài yêu cầu sự chứng thực của người dùng, mở rộng để đảm bảo các truy xuất không hợp lệ của các thiết bị nhập/xuất

Nếu một hệ thống được bảo vệ và đảm bảo, biện pháp phòng ngừa phải luôn được tiến hành xuyên suốt. Một chuỗi chỉ mạnh như liên kết yếu nhất của nó.

Page 13: Chapter 2:  Operating-System Structures

2.13 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

User Operating System Interface - CLIUser Operating System Interface - CLI

CLI allows direct command entry

Sometimes implemented in kernel, sometimes by systems program

Sometimes multiple flavors implemented – shells

Primarily fetches a command from user and executes it

– Sometimes commands built-in, sometimes just names of programs

» If the latter, adding new features doesn’t require shell modification

Page 14: Chapter 2:  Operating-System Structures

2.14 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Giao diện hệ điều hành người dùng - Giao diện hệ điều hành người dùng - CLICLI

CLI cho phép nhập lệnh trực tiếp

Đôi khi được thực hiện trên kernel, đôi khi bởi chương trình hệ thống

Đôi khi có nhiều flavor được thực thi – shells

Chủ yếu là nhập lệnh từ người sử dụng và thực thi nó Đôi khi xây dựng dòng lệnh, đôi khi từ tên của chương trình

» Nếu sau này, khi thêm tính năng mới thì không yêu cầu thay đổi shell

Page 15: Chapter 2:  Operating-System Structures

2.15 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

User Operating System Interface - GUIUser Operating System Interface - GUI

User-friendly desktop metaphor interface

Usually mouse, keyboard, and monitor

Icons represent files, programs, actions, etc

Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder)

Invented at Xerox PARC

Many systems now include both CLI and GUI interfaces

Microsoft Windows is GUI with CLI “command” shell

Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available

Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

Page 16: Chapter 2:  Operating-System Structures

2.16 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Giao diện hệ điều hành người dùng - GUIGiao diện hệ điều hành người dùng - GUI

Máy tính để bàn thân thiện với người dùng

Chuột, bàn phím, và màn hình

Các icon mô tả hóa tập tin, chương trình, hành động, v.v..

Những nút chuột khác nhau được xem như là đối tượng trong giao diện tạo ra những hành động khác nhau (cung cấp thông tin, tùy chọn, thực thi chức năng, mở thư mục (được biết như là một folder)

Được phát minh tại Xerox PARC

Nhiều hệ thống bây giờ có cả CLI và giao diện GUI

Microsoft Windows là GUI với CLI “command” shell

Apple Mac OS X như “Aqua” giao diện GUI với bên dưới kernel của UNIX và những shell có sẵn

Solaris là CLI với tùy chọn là giao diện GUI (Java Desktop, KDE)

Page 17: Chapter 2:  Operating-System Structures

2.17 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System CallsSystem Calls

Programming interface to the services provided by the OS

Typically written in a high-level language (C or C++)

Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use

Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM)

Why use APIs rather than system calls?

(Note that the system-call names used throughout this text are generic)

Page 18: Chapter 2:  Operating-System Structures

2.18 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System CallsSystem Calls

Giao diện lập trình đến dịch vụ được cung cấp bởi HĐH

Đặc trưng được viết trong ngôn ngữ cấp cao (C hoặc C++)

Hầu hết được truy xuất bằng chương trình thông qua giao diện chương trình ứng dụng (API) cấp cao thay vì trực tiếp sử dụng system call

Ba API phổ biến là Win32 API cho Windows, POSIX API cho hệ thống chuẩn POSIX (bao gồm hầu tất cả các phiên bản của UNIX, Linux, và Mac OS X), và Java API cho máy ảo Java (JVM)

Tại sao dùng API thay vì là system calls?

(Chú ý rằng những cái tên của system-call được dùng trong suốt văn bản này là những tên chung)

Page 19: Chapter 2:  Operating-System Structures

2.19 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Example of System CallsExample of System Calls

System call sequence to copy the contents of one file to another file

Page 20: Chapter 2:  Operating-System Structures

2.20 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Ví dụ về Những System CallVí dụ về Những System Call

System call liên tục sao chép nội dung của một tập tin đến một tập tin khác

Page 21: Chapter 2:  Operating-System Structures

2.21 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Example of Standard APIExample of Standard API

Consider the ReadFile() function in the Win32 API—a function for reading from a file

A description of the parameters passed to ReadFile() HANDLE file—the file to be read LPVOID buffer—a buffer where the data will be read into and written from DWORD bytesToRead—the number of bytes to be read into the buffer LPDWORD bytesRead—the number of bytes read during the last read LPOVERLAPPED ovl—indicates if overlapped I/O is being used

Page 22: Chapter 2:  Operating-System Structures

2.22 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Ví dụ về chuẩn của APIVí dụ về chuẩn của API

Xét hàm ReadFile() Win32 API—một chức năng cho việc đọc một tập tin

Mô tả của các tham số được truyền vào hàm ReadFile() File HANDLE — tập tin để đọc Vùng đệm LPVOID—Vùng đệm là nơi mà dữ liệu sẽ được đọc và

được ghi tại đó DWORD bytesToRead—số byte được đọc vào vùng đệm LPDWORD bytesRead—số byte được đọc trong thời gian đọc cuối LPOVERLAPPED ovl—chỉ ra nếu nhập/xuất chồng chéo được dùng

Page 23: Chapter 2:  Operating-System Structures

2.23 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System Call ImplementationSystem Call Implementation

Typically, a number associated with each system call

System-call interface maintains a table indexed according to these numbers

The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values

The caller need know nothing about how the system call is implemented

Just needs to obey API and understand what OS will do as a result call

Most details of OS interface hidden from programmer by API

Managed by run-time support library (set of functions built into libraries included with compiler)

Page 24: Chapter 2:  Operating-System Structures

2.24 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Thực thi System CallThực thi System Call

Tiêu biểu là mỗi system call đều liên kết với một số

Giao diện system-call duy trì một bảng chỉ mục theo những con số

Giao diện system call gọi system call dự định trong kernel xủa HĐH và trả về trạng thái của system call và những giá trị bất kỳ

Bộ gọi không cần được biết về cách mà system call thực thi

Just needs to obey API and understand what OS will do as a result call

Hầu hết các chi tiết của giao diện HĐH đều ẩn do các lập trình viên sử dụng API

Được quản lý bởi thư viện hỗ trợ run-time (tập hợp các chức năng được xây dựng trong các thư viện kèm với trình biên dịch)

Page 25: Chapter 2:  Operating-System Structures

2.25 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

API – System Call – OS RelationshipAPI – System Call – OS Relationship

Page 26: Chapter 2:  Operating-System Structures

2.26 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Quan hệ của API – System Call – OSQuan hệ của API – System Call – OS

Page 27: Chapter 2:  Operating-System Structures

2.27 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Standard C Library ExampleStandard C Library Example

C program invoking printf() library call, which calls write() system call

Page 28: Chapter 2:  Operating-System Structures

2.28 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Ví dụ về thư viện chuẩn của CVí dụ về thư viện chuẩn của C

Chương trình C gọi thư viện printf(), thư viện thì gọi system call write()

Page 29: Chapter 2:  Operating-System Structures

2.29 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System Call Parameter PassingSystem Call Parameter Passing

Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and

call Three general methods used to pass parameters to the OS

Simplest: pass the parameters in registers In some cases, may be more parameters than registers

Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This approach taken by Linux and Solaris

Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system

Block and stack methods do not limit the number or length of parameters being passed

Page 30: Chapter 2:  Operating-System Structures

2.30 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Truyền tham số cho System CallTruyền tham số cho System Call

Thông thường, nhiều thông tin được yêu cầu hơn là sự nhận dạng đơn giản của system call được gọi Kiểu chính xác và lượng thông tin khác nhau tùy theo HĐH và

cách gọi Có 3 cách thường được dùng để truyền tham số cho HĐH

Đơn giản nhất: truyền tham số trong thanh ghi Trong một vài trường hợp, có thể có nhiều tham số trong

thanh ghi Tham số được lưu trong một khối, hoặc bảng, trong bộ nhớ, và

địa chỉ của khối được truyền như là một tham số trong thanh ghi Cách tiếp cận này lấy của Linux và Solaris

Tham số được đặt, hoặc được đẩy vào stack (ngăn xếp) bởi chương trình và bỏ đi stack bởi hệ điều hành

Phương pháp khối và stack không giới hạn số hay độ dài của số được truyền

Page 31: Chapter 2:  Operating-System Structures

2.31 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Parameter Passing via TableParameter Passing via Table

Page 32: Chapter 2:  Operating-System Structures

2.32 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Truyền tham số thông qua bảngTruyền tham số thông qua bảng

Page 33: Chapter 2:  Operating-System Structures

2.33 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Types of System CallsTypes of System CallsCác loại System CallCác loại System Call

Process control

File management

Device management

Information maintenance

Communications

Điều khiển process

Quản lý tập tin

Quản lý thiết bị

Bảo trì thông tin

Giao tiếp

Page 34: Chapter 2:  Operating-System Structures

2.34 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

MS-DOS executionMS-DOS execution

(a) At system startup (b) running a program

Page 35: Chapter 2:  Operating-System Structures

2.35 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Thực thi trong MS-DOSThực thi trong MS-DOS

(a) At system startup (b) running a program

Page 36: Chapter 2:  Operating-System Structures

2.36 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

FreeBSD Running Multiple ProgramsFreeBSD Running Multiple Programs

Page 37: Chapter 2:  Operating-System Structures

2.37 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

FreeBSD chạy nhiều chương trìnhFreeBSD chạy nhiều chương trình

Page 38: Chapter 2:  Operating-System Structures

2.38 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System ProgramsSystem Programs

System programs provide a convenient environment for program development and execution. The 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

Page 39: Chapter 2:  Operating-System Structures

2.39 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Chương trình hệ thốngChương trình hệ thống

Chương trình hệ thống cung cấp một môi trường thuận lợi cho việc phát triển và thực thi chương trình. Có thề được chia như sau:

Thao tác với tập tin

Thông tin trạng thái

Thay đổi tập tin

Hỗ trợ ngôn ngữ lập trình

Nạp và thực thi chương trình

Sự giao tiếp

Chương trình ứng dụng

Hầu hết người dùng xem các hệ thống hoạt động được xác định bởi các chương trình hệ thống, không là các system call thực

Page 40: Chapter 2:  Operating-System Structures

2.40 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Solaris 10 dtrace Following System CallSolaris 10 dtrace Following System Call

Page 41: Chapter 2:  Operating-System Structures

2.41 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Chương trình hệ thốngChương trình hệ thống

Cung cấp một môi trường thuận lợi cho việc phát triển và thực thi chương trình

Một vài chương trình thì đơn giản giao diện người dùng đến system call; một số chương trình khác thì phức tạp

Quản lý tập tin – Tạo, xóa, sao chép, đổi tên, in, kết xuất, danh sách, và cá thao tác chung về tập tin và thư mục

Thông tin trạng thái

Một vài yêu cầu hệ thống cho thông tin - ngày, giờ, lượng bộ nhớ có sẵn, không gian đĩa, số người dùng

Một số khác cung cấp chi tiết về thực thi, đăng nhập, và gỡ lỗi thông tin

Thường thì những dạng chương trình này and print the output to the terminal or other output devices

Một số hệ thống thực thi thanh ghi – được dùng để lưu trữ và nhận thông tin cấu hình

Page 42: Chapter 2:  Operating-System Structures

2.42 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System Programs (cont’d)System Programs (cont’d)

File modification Text editors to create and modify files Special commands to search contents of files or perform

transformations of the text Programming-language support - Compilers, assemblers,

debuggers and interpreters sometimes provided Program loading and execution- Absolute loaders, relocatable

loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language

Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systems Allow users to send messages to one another’s screens,

browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another

Page 43: Chapter 2:  Operating-System Structures

2.43 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Chương trình hệ thống (tiếp theo)Chương trình hệ thống (tiếp theo)

Thay đổi tập tin Trình chỉnh sửa văn bản để tạo và thay đổi tập tin Những lệnh đặc biệt để tìm nội dung của tập tin hoặc thực hiện

việc thay đổi văn bản Hỗ trợ ngôn ngữ lập trình – Trình biên dịch, assemblers, trình bắt

lỗi và trình phiên dịch Thực thi và nạp chương trình – trình nạp tuyệt đối, trình nạp tái

định vị, trình chỉnh sửa liên kết, và trình nạp chồng, hệ thống bắt lỗi cho cấp độ cao hơn và ngôn ngữ máy tính

Giao tiếp – Cung cấp cơ cấu tạo kết nối ảo trong số những process, người dùng, và hế thống máy tính Cho phép người dùng gửi thông báo đến màn hình máy khác,

duyệt web, gửi thông báo thư điện tử, đăng nhập từ xa, chuyển tập tin từ một máy đến một máy khác

Page 44: Chapter 2:  Operating-System Structures

2.44 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System Design and ImplementationOperating System Design and Implementation

Design and Implementation of OS not “solvable”, but some approaches have proven successful

Internal structure of different Operating Systems can vary widely

Start by defining goals and specifications

Affected by choice of hardware, type of system

User goals and System goals

User 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

Page 45: Chapter 2:  Operating-System Structures

2.45 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Thiết kế và thực thi hệ điều hànhThiết kế và thực thi hệ điều hành

Thiết kế và thực thi HĐH không “giải quyết được”, nhưng một giải pháp gần đúng đã chứng minh thành công

Cấu trúc bên trong của những hệ điều hành khác nhau có thể khác nhau

Bắt đầu bằng cách định ngĩa mục đích và đặc điểm kỹ thuật

Bị ảnh hướng bởi việc chọn phần cứng, kiểu hệ thống

Mục đích của người dùng và hệ thống

Mục đích của người dùng – hệ điều hành thì thuận tiện để dùng, dễ dàng để học, tin cậy, an toàn, và nhanh

Mục đích của hệ thống – hệ điều hành dễ dàng thiết kế, thực thi, bảo trì, linh hoạt, tin cậy, không lỗi, và có hiệu quả

Page 46: Chapter 2:  Operating-System Structures

2.46 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System Design and Implementation (Cont.)Operating System Design and Implementation (Cont.)

Important principle to separate

Policy: What will be done? Mechanism: How to do it?

Mechanisms determine how to do something, policies decide what will be done

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

Page 47: Chapter 2:  Operating-System Structures

2.47 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Thiết kế và thực thi hệ điều hành (tiếp theo)Thiết kế và thực thi hệ điều hành (tiếp theo)

Nguyên tắc quan trọng là tách biệt

Chính sách: Điều gì sẽ được thực hiện? Cơ chế: Làm thế nào để làm điều đó?

Cơ chế xác định làm thế nào để làm điều gì đó, chính sách quyết định những gì sẽ được thực hiện Việc tách của chính sách từ cơ chế là nguyên tắc rất quan

trọng, nó cho phép linh hoạt tối đa nếu quyết định của chính sách có thay đổi sau đó

Page 48: Chapter 2:  Operating-System Structures

2.48 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Simple Structure Simple Structure

MS-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

Page 49: Chapter 2:  Operating-System Structures

2.49 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Cấu trúc đơn giảnCấu trúc đơn giản

MS-DOS – được viết để cung cấp nhiều chức năng trong không gian giới hạn

Không được phân chia thành các phần

Mặc dù MS-DOS có một vài cấu trúc, giao diện và chức năng của nó chưa được tách biệt

Page 50: Chapter 2:  Operating-System Structures

2.50 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

MS-DOS Layer StructureMS-DOS Layer Structure

Page 51: Chapter 2:  Operating-System Structures

2.51 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Cấu trúc tầng của MS-DOSCấu trúc tầng của MS-DOS

chương trình hệ thống thường trực

chương trình ứng dụng

trình điều khiển thiết bị của MS-DOS

trình điều khiển thiết bị ROM-BIOS

Page 52: Chapter 2:  Operating-System Structures

2.52 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Layered ApproachLayered ApproachPhương pháp phân tầngPhương pháp phân tầng

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.

With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers

Hệ điều hành được chia thành một số tầng (các cấp), mỗi tầng được xây dựng trên các tầng thấp hơn. Tầng dưới cùng (tầng thứ 0), là phần cứng; tầng cao nhất (tầng thứ N) là giao diện người dùng.

Với mô đun, các tầng được chọn sao cho mỗi chức năng sử dụng (hoạt động) và dịch vụ của các tầng có cấp thấp hơn

Page 53: Chapter 2:  Operating-System Structures

2.53 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Layered Operating SystemLayered Operating System

Page 54: Chapter 2:  Operating-System Structures

2.54 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Hệ điều hành phân tầngHệ điều hành phân tầng

tầng thứ Ngiao diện người dùng

tầng thứ 1

tầng thứ 0phần cứng

Page 55: Chapter 2:  Operating-System Structures

2.55 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

UNIXUNIX

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

Page 56: Chapter 2:  Operating-System Structures

2.56 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

UNIXUNIX

UNIX – giới hạn bởi chức năng của phần cứng, tổ chức hệ điều hành UNIX có giới hạn về cấu trúc. HĐH UNIX gồm có hai phần riêng biệt

Chương trình hệ thống

The kernel

Gồm mọi thứ trên giao diện system-call và trên phần cứng vật lý

Cung cấp tập tin hệ thống, lịch trình hóa của CPU, quản lý bộ nhớ, và các chức năng khác của hệ điều hành; một số lượng lớn các chức năng cho một cấp

Page 57: Chapter 2:  Operating-System Structures

2.57 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

UNIX System StructureUNIX System Structure

Page 58: Chapter 2:  Operating-System Structures

2.58 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Microkernel System Structure Microkernel System Structure

Moves as much from the kernel into “user” space

Communication takes place between user modules using message passing

Benefits:

Easier to extend a microkernel

Easier to port the operating system to new architectures

More reliable (less code is running in kernel mode)

More secure

Detriments:

Performance overhead of user space to kernel space communication

Page 59: Chapter 2:  Operating-System Structures

2.59 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Mac OS X StructureMac OS X Structure

Page 60: Chapter 2:  Operating-System Structures

2.60 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

ModulesModules

Most modern operating systems implement kernel modules

Uses object-oriented approach

Each core component is separate

Each talks to the others over known interfaces

Each is loadable as needed within the kernel

Overall, similar to layers but with more flexible

Page 61: Chapter 2:  Operating-System Structures

2.61 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Solaris Modular ApproachSolaris Modular Approach

Page 62: Chapter 2:  Operating-System Structures

2.62 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Phương pháp mô đun hóa của SolarisPhương pháp mô đun hóa của Solaris

Page 63: Chapter 2:  Operating-System Structures

2.63 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Virtual MachinesVirtual Machines

A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware

A virtual machine provides an interface identical to the underlying bare hardware

The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory

Page 64: Chapter 2:  Operating-System Structures

2.64 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Máy ảoMáy ảo

A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware

Một máy ảo cung cấp một giao diện giống với phần cứng cơ bản

The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory

Page 65: Chapter 2:  Operating-System Structures

2.65 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Virtual MachinesVirtual Machines (Cont.) (Cont.)

The 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 66: Chapter 2:  Operating-System Structures

2.66 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Máy ảo (tiếp theo)Máy ảo (tiếp theo)

Tài nguyên của máy tính vật lý được chia sẻ để tạo máy ảo

Lịch trình của CPU có thể tạo ra giao diện cho người dùng thao tác lên đó

Spooling và hệ thống tập tin có thể cung cấp bộ đọc thẻ ảo và máy in dạng ảo

Time-sharing của người dùng bình thường kết thúc phục vụ như console thao tác của máy ảo

Page 67: Chapter 2:  Operating-System Structures

2.67 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Virtual Machines (Cont.)Virtual Machines (Cont.)

(a) Nonvirtual machine (b) virtual machine

Non-virtual Machine Virtual Machine

Page 68: Chapter 2:  Operating-System Structures

2.68 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Máy ảo (tiếp theo)Máy ảo (tiếp theo)

(a) không phải máy ảo (b) máy ảo

Non-virtual Machine Virtual Machine

Page 69: Chapter 2:  Operating-System Structures

2.69 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Virtual MachinesVirtual Machines (Cont.) (Cont.)

The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources.

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

The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine

Page 70: Chapter 2:  Operating-System Structures

2.70 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Máy ảoMáy ảo (tiếp theo) (tiếp theo)

Khái niệm máy ảo cung cấp sự bảo vệ toàn diện cho tài nguyên hệ thống, mỗi máy ảo đều được tách biệt với các máy ảo khác. Sự tách biệt này không có phép chia sẻ tài nguyên một cách trực tiếp.

Hệ thống máy ảo là một phương tiện hoàn hảo cho hệ điều hành dùng để nguyên cứu và phát triển. Sự phát triển hệ thống hoàn tất trên máy ảo, thay vì là trên một máy thật và chính vì vậy hệ thống thật vẫn hoạt động bình thường mà không bị ảnh hưởng.

Khái niệm máy ảo thì khó khăn để thực hiện vì kết quả đã đạt được cung cấp một bản sao chính xác cho máy cơ bản

Page 71: Chapter 2:  Operating-System Structures

2.71 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Cấu trúc VMwareCấu trúc VMware

Page 72: Chapter 2:  Operating-System Structures

2.72 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

The Java Virtual MachineThe Java Virtual Machine

Page 73: Chapter 2:  Operating-System Structures

2.73 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Máy ảo JavaMáy ảo Java

Page 74: Chapter 2:  Operating-System Structures

2.74 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Operating System GenerationOperating System Generation

Operating systems are designed to run on any of a class of machines; the system must be configured for each specific computer site

SYSGEN program obtains information concerning the specific configuration of the hardware system

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

Page 75: Chapter 2:  Operating-System Structures

2.75 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Sự hình thành của Hệ điều hànhSự hình thành của Hệ điều hành

Hệ điều hành được thiết để chạy trên bất kỳ lớp trên máy; hệ thống phải được cấu hình cho mỗi điểm máy tính đặc biệt

Chương trình SYSGEN chứa thông tin cấu hình đặc biệt của hệ thống phần cứng

Khởi động – bắt đầu chạy máy tính bằng cách nạp kernel

Chương trình khởi động – mã được lưu trên ROM có thể phát hiện vị trí kernel, nạp chúng lên bộ nhớ, và bắt đầu thực thi

Page 76: Chapter 2:  Operating-System Structures

2.76 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

System BootSystem Boot

Operating system must be made available to hardware so hardware can start it

Small piece of code – bootstrap loader, locates the kernel, loads it into memory, and starts it

Sometimes two-step process where boot block at fixed location loads bootstrap loader

When power initialized on system, execution starts at a fixed memory location

Firmware used to hold initial boot code

Page 77: Chapter 2:  Operating-System Structures

2.77 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Jan 14, 2005

Khởi động hệ thốngKhởi động hệ thống

Hệ điều hành phải được tạo sẵn cho phần cứng, vì phần cứng hoạt động được nhờ nó.

Bộ phận nhỏ của mã – trình nạp khởi động, định vị kernel, nạp nó vào bộ nhớ, và bắt đầu chạy nó

Đôi khi hai bước của quá trình mà tại đó khối khởi động được cố định vị trí nạp trình nạp khởi động

Khi năng lượng được khởi tạo trên hệ thống, sự thực thi bắt đầu cố định vị trí bộ nhớ

Firmware được dùng để chứa mã khởi động ban đầu

Page 78: Chapter 2:  Operating-System Structures

End of Chapter 2End of Chapter 2

Page 79: Chapter 2:  Operating-System Structures

Kết thúc chương 2Kết thúc chương 2


Recommended