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

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
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 2 Operating System Structures.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 1 Overview of an Operating System.pdf
- 《计算机网络》课程教学资源(PPT课件)第六章 应用层.pptx
- 《计算机网络》课程教学资源(PPT课件)第五章 传输层.pptx
- 《计算机网络》课程教学资源(PPT课件)第四章 网络层.pptx
- 《计算机网络》课程教学资源(PPT课件)第三章 数据链路层.pptx
- 《计算机网络》课程教学资源(PPT课件)第二章 物理层.pptx
- 《计算机网络》课程教学资源(PPT课件)第一章 概述.pptx
- 《智能算法设计与应用》课程教学大纲 Intelligent Algorithm Design and Application.docx
- 《数字导航技术》课程教学资源(书籍文献)计算机视觉-马颂德.pdf
- 《C语言程序设计》课程参考文献:Programming languages — C(PDF电子书,英文版).pdf
- 《操作系统》课程教学资源(PPT课件)课程简介 Operating System.pptx
- 《操作系统》课程教学资源(PPT课件)第1章 操作系统引论.pptx
- 《操作系统》课程教学资源(PPT课件)第2章 进程的描述和控制.pptx
- 《操作系统》课程教学资源(PPT课件)第3章 处理机调度与死锁.pptx
- 《操作系统》课程教学资源(PPT课件)第5章 虚拟存储器.pptx
- 《操作系统》课程教学资源(PPT课件)第6章 输入输出系统.pptx
- 《操作系统》课程教学资源(PPT课件)第7章 文件管理.pptx
- 《操作系统》课程教学资源(PPT课件)第8章 磁盘存储器的管理.pptx
- 《操作系统》课程教学资源(PPT课件)第4章 存储器管理.pptx
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 3 Process Concepts & Operations(part2)from Kernel's Perspective.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 4 Threads.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 5 Process Communication & Synchronization(part1).pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 5 Process Communication & Synchronization -Part 2.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 6 Process Scheduling.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 7 Memory Management part1.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 7 Memory Management part2.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 8 Mass Storage.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 9 File Systems part1.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 9 File Systems part2.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 10 Details of FAT32.pdf
- 《操作系统原理与设计 Operating System Principles and Implementation》课程教学课件(英文讲稿)Chapter 10 Details of Ext2/3 File System.pdf
- 北京工业大学:信息科学技术学院《C#程序设计基础》课程教学大纲 Fundamentals of Programming Principle and Practice in C#.pdf
- 北京工业大学:计算机学院本科课程教学大纲汇编(2024).pdf
- 揭阳职业技术学院:《计算机应用基础》课程授课教案(讲义,2025).pdf
- 《C语言程序设计》课程教学课件(PPT讲稿)第10章 对文件的输入输出.pptx
- 《C语言程序设计》课程教学课件(PPT讲稿)第01章 程序设计和C语言.pptx
- 《C语言程序设计》课程教学课件(PPT讲稿)第02章 算法——程序的灵魂.pptx
- 《C语言程序设计》课程教学课件(PPT讲稿)第03章 最简单的C程序设计——顺序程序设计.pptx
- 《C语言程序设计》课程教学课件(PPT讲稿)第04章 选择结构程序设计.pptx
