Skip to content

Commit 4f3b338

Browse files
committed
temp sub
1 parent dc097b3 commit 4f3b338

9 files changed

Lines changed: 84 additions & 0 deletions

File tree

cpp/1.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
#include <stdio.h>
3+
4+
extern const int a;
5+
6+
int main() {
7+
printf("%d\n", a);
8+
return 0;
9+
}

cpp/1.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#include "1.h"
3+
4+
#include <iostream>
5+
6+
#include "2.h"
7+
#include "3.h"
8+
9+
int main() {
10+
std::cout << x << std::endl;
11+
std::cout << "get2: " << get2() << std::endl;
12+
std::cout << "get3: " << get3() << std::endl;
13+
14+
std::cout << "set2: " << std::endl;
15+
set2(123);
16+
17+
std::cout << x << std::endl;
18+
std::cout << "get2: " << get2() << std::endl;
19+
std::cout << "get3: " << get3() << std::endl;
20+
21+
return 0;
22+
}

cpp/1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
static int x = 0;

cpp/2.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
#include "2.h"
3+
4+
#include "1.h"
5+
6+
void set2(int v) {
7+
x = v;
8+
}
9+
10+
int get2() {
11+
return x;
12+
}

cpp/2.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
void set2(int v);
4+
int get2();

cpp/3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
const int a = 1234;

cpp/3.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
#include "3.h"
3+
4+
#include "1.h"
5+
6+
void set3(int v) {
7+
x = v;
8+
}
9+
10+
int get3() {
11+
return x;
12+
}

cpp/3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
void set3(int v);
3+
int get3();

cpp/readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11

2+
# 操作系统提高CPU的利用率
3+
```
4+
单道程序:
5+
多道程序: 非抢占式
6+
分时系统: 抢占式
7+
实时系统
8+
```
9+
10+
#
11+
预处理:
12+
g++ -o 1.i -E 1.cc # 预处理
13+
g++ -o 1.s -S 1.cc # 编译, 词法分析, 语法分析, 语义分析, 优化, 得到汇编
14+
g++ -o 1.o -c 1.cc # 汇编, 得到目标文件, 汇编->机器语言
15+
16+
编译
17+
汇编
18+
链接
19+
220
# 程序内存结构
321
```
422
* 正文段(text)

0 commit comments

Comments
 (0)