中国高校课件下载中心 》 教学资源 》 大学文库

《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 3 Process Concepts & Operations(part1)

文档信息
资源类别:文库
文档格式:PDF
文档页数:84
文件大小:1.79MB
团购合买:点击进入团购
内容简介
• Process Concept – Program vs process – Process in memory & PCB – Process state • Processes Operations – Process creation, program execution, process termination – UNIX example: fork(), exec*(), wait()
刷新页面文档预览

OperatingSystemsChapter 3Process Concepts & Operations1

Operating Systems Chapter 3 Process Concepts & Operations 1

Outline· Process Concept-ProgramvsprocessProcessinmemory&PCB-Processstate·Processes Operations- Process creation, program execution, processtermination-UNIX example: fork(), exec*(), wait()2

2 Outline • Process Concept – Program vs process – Process in memory & PCB – Process state • Processes Operations – Process creation, program execution, process termination – UNIX example: fork(), exec*(), wait()

Whatisaprocess?Informally, a process is a program in executionProcessDifferences?ProgramRelationship?Execution?3

What is a process? 3 Process Relationship? Differences? Execution? Program Informally, a process is a program in execution

What is a program?Program4

4 Program What is a program?

Whatisaprogram?. What is a program?- A program is a just a piece of code But, which code do you mean?- High-level language code: C or C++?- Low-level language code: assembly code?- Not-yet an executable: object code?- Executable: machine code?5

What is a program? • What is a program? – A program is a just a piece of code. • But, which code do you mean? – High-level language code: C or C++? – Low-level language code: assembly code? – Not-yet an executable: object code? – Executable: machine code? 5

Flowof buildingaprogram(1of 2)Ccode:hello.cExpandedCcode:hello.cPre-processor#define TXT "hello"int main(void)printf("%s\n",TXT);1return ;Compiler&OptimizerAssemblycode:hello.s6

Flow of building a program (1 of 2) 6 Pre-processor Compiler & Optimizer Assembly code: hello.s C code: hello.c Expanded C code: hello.c #define TXT “hello” int main(void) { printf(“%s\n”, TXT); return 0; }

(Still...1of2)Pre-processor. The pre-processor expands:一#define,#include,#ifdef,#ifndef,#endif,etc.Try:“gcc -E hello.c"#defineTxThello"int main(void)intmain(void)hello)printf("%s\n"Pre-processorprintf("%s\n",TXT);return e;return ;子7gcc -E hello.cOriginal codeExpandedcode

(Still.1 of 2) Pre-processor • The pre-processor expands: – #define, #include, #ifdef, #ifndef, #endif, etc. – Try: “gcc –E hello.c” 7 #define TXT “hello” int main(void) { printf(“%s\n”, TXT); return 0; } Pre-processor int main(void) { printf(“%s\n”, "hello"); return 0; } Original code Expanded code gcc –E hello.c

(Still...1of2)Pre-processorAnotherexample:themacro!#define SWAP(a,b)(intc;c=a;a=b;b =cj)int main(void){inti=10,j=20;printf("before swap:i=%d,j=%d\n",i,j);SWAP(i,j);printf("after swap:i =%d,j=%dln",i,j);int main(void)(inti=10,j=20;printf("before swap:i=%d,j =%d\n",i,j);intcjc=ii=jij=cPre-processorprintf("afterswap:i=%d,j=%d\n",i,j);8

(Still.1 of 2) Pre-processor • Another example: the macro! 8 #define SWAP(a,b) { int c; c = a; a = b; b = c; } int main(void) { int i = 10, j = 20; printf("before swap: i = %d, j = %d\n", i, j); SWAP(i, j); printf("after swap: i = %d, j = %d\n", i, j); } Pre-processor int main(void) { int i = 10, j = 20; printf("before swap: i = %d, j = %d\n", i, j); { int c; c = i; i = j; j = c; }; printf("after swap: i = %d, j = %d\n", i, j); }

(Still...1 of 2) Pre-processorHow about: #include?#include "header.h"int main(void){int add fun(int a,int b)add_fun(1,2);return (a + b);return o;Program:include.cPre-processorint main(void) (add_fun(1,2);return ;子int add fun(int a,int b)return (a +b);2Program:header.h9

(Still.1 of 2) Pre-processor • How about: #include? 9 #include “header.h” int main(void) { add_fun(1,2); return 0; } int add_fun(int a, int b) { return (a + b); } int add_fun(int a, int b) { return (a + b); } int main(void) { add_fun(1,2); return 0; } Pre-processor Program: include.c Program: header.h

(Still...1of2)CompilerandOptimizer? The compiler performs:- Syntax checking and analyzing; If there is no syntax error, construct intermediate codes,i.e., assembly codes;The optimizer optimizes codes-It improvesstupid codes!"-o"means to optimize.- Check the parameter of gccThe number followed is theoptimization level.Max is level3,i.e.,"-03".Default is levelis"-01""-oo":means no optimization.10

(Still.1 of 2) Compiler and Optimizer • The compiler performs: – Syntax checking and analyzing; – If there is no syntax error, construct intermediate codes, i.e., assembly codes; • The optimizer optimizes codes – It improves stupid codes! – Check the parameter of gcc 10 “-O” means to optimize. The number followed is the optimization level. Max is level 3, i.e., “-O3”. Default is level is “-O1”. “-O0”: means no optimization

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档