Download 讲稿5 - 天津大学计算机科学与技术学院

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Library (computing) wikipedia , lookup

Compiler wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Object-oriented programming wikipedia , lookup

Programming language wikipedia , lookup

Go (programming language) wikipedia , lookup

Parallel computing wikipedia , lookup

Structured programming wikipedia , lookup

Interpreter (computing) wikipedia , lookup

Assembly language wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Transcript
Chapter 7
Operating
Systems
天津大学软件学院
A computer is a system made of two major components:
hardware and software. Computer hardware is the physical
equipment. Software is the collection of programs that
allows the hardware to do its job.
Computer software is divided into two broad categories: the
operating system and application programs.
计算机导论
• Application Software(应用软件):
programs for performing tasks particular to the machine’s
utilization
• System Software(系统软件):
performs those tasks that are common to computer
system in general
system software provides the environment in which the
application software resides(为应用软件提供运行环境)
utility software: consists of software units that extend the
capabilities of the operating system(扩展操作系统的功能)
计算机导论
计算机导论
操作系统能干什么—1
例: 在计算机上看DVD
1. 将影碟放入DVD驱动器
2. 执行DVD播放软件
– 操作系统从磁盘某个目录将播放程序调入内存
– 操作系统创建一个进程, 执行该播放程序
3. DVD播放软件读取DVD驱动器中的内容
4. 将数据送到屏幕和声卡的驱动程序
5. 用户享受DVD
计算机导论
操作系统能干什么—2
• DVD驱动器=⇒ I/O设备管理
• 执行DVD播放软件
– 磁盘上的播放程序: =⇒ 文件系统
– 创建播放进程: =⇒ 进程管理、内存管理
• 驱动屏幕和声卡: =⇒ I/O设备管理
• 用户用鼠标进行操作: =⇒ 人机接口
计算机导论
7.1 DEFINITION
An operating system is so complex that is difficult to give a
simple universal definition. Instead, here is some common
definition:
 An operating system is an interfacebetween the hardware of a computer and the user (program or humans).
(人机之间的接口)
 An operating system is a program (or a set of program)
that facilitates the execution of other programs(使其它程序执
行更有效的程序).
 An operating system acts as a general manager
supervising the activity of each component in the
computer system(管理计算机系统中每个部件的活动).
计算机导论
Two major design goals of an operating system are
1. Efficient use of hardware(有效地使用硬件).
2. Easy to use resources(容易的使用资源).
计算机导论
7.3 COMPONENTS
A modern operating system has at least four duties: memory
manager, process manager, device manager and file
manager. The user interface is responsible for
communication outside the operating system (like a public
relations department).
memory manager:内存管理
process manager:进程管理
device manager:设备管理
file manager:文件管理
user interface:用户界面
计算机导论
DEVICE MANAGER
计算机导论
USER INTERFACE
计算机导论
Getting it Started
The booting process
计算机导论
涉及到的课程:
• 必修课:操作系统原理,
UNIX/LINUX操作系统
• 选修课:嵌入式操作系统
计算机导论
Chapter 9
Programming
Languages
天津大学软件学院
9.1 EVOLUTION
To write a program for a computer, you must use a computer
language. A computer language is a set of predefined words
that are combined into a program according to predefined
rules (syntax)
Over the years, computer languages have evolved from
machine language to natural languages. A time line for
computer languages is presented in Figure 9.1.
计算机导论
Program in machine language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
00000000
00000100
0000000000000000
01011110 00001100110000100000000000000010
11101111 000101100000000000000101
11101111 10011110 0000000000001011
11111000 10101101
11011111 0000000000010010
0110001011011111 0000000000010101
11101111 00000010
11111011 0000000000010111
11110100 1010110111011111 0000000000011110
0000001110100010
11011111 0000000000100001
11101111 00000010
11111011 0000000000100100
01111110 11110100 10101101
11111000 10101110 110001010000000000101011
0000011010100010
11111011 0000000000110001
11101111 00000010
11111011 0000000000110100
00000100
0000000000111101
00000100
0000000000111101
The only language understood by
a computer is machine language.计算机导论
DSEG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SEGMENT PARA 'Data'
dw ?
array
dw 3,5,13h,23h,37h,49h,52h,65h,78h,99h,105h
count
equ $-array_head
n
dw 32h
DSEG
ENDS
CSEG
SEGMENT PARA 'Code'
assume cs:CSEG, ds:DSEG,ss:SSEG
MAIN: mov ax,dseg
mov ds,ax
mov es,ax
mov ax,n
mov si,0
mov cx,count
repeat: mov bx,array[si]
cmp bx,ax
jae insert
;n较小,则转插入操作
mov array[si-2],bx
;数组元素前移1字单元
inc si
inc si
loop repeat
insert: mov array[si-2],ax
;将n加入到数组中
mov ax,4C00H
int 21h
CSEG
ENDS
END MAIN
;set entry point
Program in symbolic language
计算机导论
Program in C++ language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
This program reads two integer numbers from the
keyboard and prints their product.
*/
#include <iostream.h>
int main (void)
{
// Local Declarations
int number1;
int number2;
int result;
//
Statements
cin >> number1;
cin >> number2;
result = number1 * number2;
cout << result;
return 0;
}
// main
计算机导论
9.2 BUILDING A PROGRAM
There are three steps in this
process:
1.Writing and editing the
program (source program)
2. Compiling the program
(object program)
(translation)
3. Linking the program with
the required library modules
计算机导论
The translation process
相关的课程:
编译技术(选修)
编译原理
计算机导论
9.3 PROGRAM EXECUTION
To execute your program you use an operating system
command to load your program into primary memory and
execute it. Getting the program into memory is the function of
an operating system program known as the loader. It locates
the executable program and reads it into memory. When
everything is ready, control is given to the program, and it
begins execution.
计算机导论
9.4 CATEGORIES OF LANGUAGES
•
Today, computer languages are categorized according to the
approach they use in solving a problem and the category of problems
they solve. (根据解决问题的方法和解决问题的种类)
•
We divide computer languages into five categories : procedural
(imperative) languages(过程化), object-oriented languages(面向对象),
functional languages(函数型), declarative languages(说明性), and
special languages(专用).
计算机导论
PROCEDURAL (IMPERATIVE) LANGUAGES
FORTRAN ( FORmula TRANslation )
COBOL (COmmon Business-Oriented Language)
Pascal (structured programming approach)
C
计算机导论
OBJECT-ORIENTED LANGUAGS
In object-oriented programming, the objects and the
operations to be applied to them are tied together.
C++
Java
计算机导论
FUNCTIONAL LANGUAGES
LISP (LISt Programming)
Scheme
DECLARATIVE (LOGIC) LANGUAGES
A declarative language uses the principle of logical
reasoning to answer queries.
Prolog ( PROgramming in LOGic)
计算机导论
SPECIAL LANGUAGES
HTML (超文本链接标示语言)
HTML (Hypertext Markup Language) : An HTML file is made
of text and tags. A tag is enclosed in two angle brackets and
usually comes in pairs. An HTML file (page) is stored on the
sever and can be downloaded by a browser.
SQL (Structured Query Language,结构化查询语言)
计算机导论
相关课程
• 必修:
– C/C++程序设计
– 汇编语言程序设计
• 选修:
– C#程序设计语言
– Java语言程序设计
计算机导论
作业
•
•
•
•
•
•
7-21——7-28
7-37——7-40
7-46
9-31——9-35
9-38,9-39
9-41,9-42,9-43,9-469-55
计算机导论
SUMMARY
 An operating system facilitates the execution of other
software, acts as the general manager of a computer
system, and ensures the efficient use of hardware and
software resources.
 The evolution of operating systems has included batch
operating system, time-sharing system, singer-user
operating system, parallel system and distributed systems.
 The operating system oversees the memory manager, the
process manager, the device manager, the file manager, and
the user interface.
 In monoprogramming, most of memory capacity is
dedicated to one single program.
 In multiprogramming, more than one program is in
memory at the same time.
计算机导论
SUMMARY (continued)
 In partitioning, memory is divided into variable length
sections, each of which holds one program.
 In paging, memory is divided into equally sized sections
called frames and the program is divided into equally sized
sections called pages. Pages of program need not be
contiguous, but all pages must be present in memory for
execution.
 Demand paging is similar to paging except that all pages
need not be in memory.
 Demand segmentation is similar to paging except that,
instead of equally sized sections, the program is divided to
match the program divisions.
 Demand paging and demand segmentation can be
combined to further improve the efficiency of a computer
system.
计算机导论
SUMMARY (continued)
 The sum of the size of all the programs in memory is
virtual memory.
 A program is a nonactive set of instructions written by a
programmer and stored on disk or tape.
 A job is a program that is selected for execution.
 A process is a job residing in memory.
 A state diagram shows the relationship between a
program, job, and process. A job can be in the hold,
terminated, read, running, or waiting state. A process can be
in one of the latter three states.
 The job scheduler creates a process from a job and
changes a process back to a job.
 The process scheduler moves a process from one state to
another.
计算机导论
SUMMARY (continued)
 Jobs and processes wait in queues.
 Deadlock is a situation in which a process is unable to
execute due to unrestricted use of resources by other
processes.
 Starvation is a situation in which a process is unable to
execute due to too many restrictions on resources.
 The device manager controls access to I/O devices.
 The file manager controls access to files.
 The user interface is software that accepts requests from
processes and interprets them for the rest of the operating
system.
 Windows 2000, UNIX, and Linux are three popular
operating systems.
计算机导论
SUMMARY
 The only language understood by a computer is machine
language
 A symbolic language uses symbols to represent various
machine language instructions. Symbolic languages are also
called assembly languages.
 A high-level language is portable from one computer type
to another and frees the programmer from hardware
concerns. BASIC, Pascal, Ada, C, C++, and Java are highlevel languages.
 The steps to building a program include writing, editing,
compiling, and linking code.
 There are five categories of computer languages:
procedural, object-oriented, functional, declarative, and
special.
计算机导论
SUMMARY (continued)
 In a procedural language, an algorithm is translated into
code. The code manipulates data and controls the execution
of instructions. FORTRAN, COBOL, Pascal, C, and Ada are
all procedural languages.
 In an object-oriented language such as C++ and Java, the
objects and the operations applied to the objects are tied
together.
 C++ uses the concepts of encapsulation, inheritance, and
polymorphism.
 In a functional language, the algorithm is mathematical in
nature. LISP and Scheme are functional languages.
 A declarative language uses the principles of logical
reasoning. Prolog is a declarative language.
计算机导论
SUMMARY (continued)
 A special language cannot be categorized into one of the
other four groups. HTML, PERL, and SQL are special
languages.
 C is considered the mother of languages such as C++,
Java, and PERL.
计算机导论