Skip to content

Commit 1b6d906

Browse files
committed
add per_cpu
1 parent bce529f commit 1b6d906

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

2023/08/arceos.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,17 @@ b) 申请内存: 移动next位置指针, allocations加一,返回移动前
124124
c) 释放内存: allocations减一。如果归零,复位next到起始位置。
125125
d) 需要检查,分配和释放是否越界。
126126
```
127+
128+
## arceos 标准库集成
129+
130+
### 侵入式实现
131+
arceos 目前稳定版的实现是这样的,所有用到的第三方库用到标准库的都要加以下这行
132+
133+
> use axstd as std
134+
135+
### add arceos to target
136+
在 arceos 的激进仓库 <github.com/arceos-os/arceos>
137+
138+
next/nightly/激进版的代码在 `github.com/arceos-os`
139+
140+
(据说这个组织最近在等 github 验证,所以组织变成 private 不可见了)

2023/09/per_cpu.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# [per_cpu](/2023/09/per_cpu.md)
2+
3+
Rust for Linux 最大的遗憾是 C 的 per_cpu 相关宏无法使用,因为需要修改 linker
4+
5+
Linux 看门狗喂狗 ping 回调函数中用到了 `DEFINE_PER_CPU(bool, initialized) = false``per_cpu(initialized,cpu_num)`
6+
[How per_cpu this_cpu_ptr() impl](https://stackoverflow.com/questions/16978959/how-are-percpu-pointers-implemented-in-the-linux-kernel)
7+
8+
## per_cpu 的替代方案
9+
10+
OSTEP 第二种 per_cpu 的实现方法,如果已经知道处理器个数,创建 static 数组,数组索引就是 smp_processor_id() `linux/smp.h`
11+
12+
用户态获取当前在第几个处理器的办法:
13+
- `/proc/<pid>/task/<tid>/status`
14+
- getcpu()
15+
16+
## arceos per_cpu 实现
17+
18+
<https://github.com/rcore-os/arceos/blob/main/crates/percpu/test_percpu.x>

0 commit comments

Comments
 (0)