Skip to content

Commit

Permalink
2024秋冬季开源操作系统训练营第三阶段总结报告-王一尧
Browse files Browse the repository at this point in the history
  • Loading branch information
ridesun committed Dec 1, 2024
1 parent b9f40e9 commit d1445f8
Showing 1 changed file with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: 2024秋冬季开源操作系统训练营第三阶段总结报告-王一尧
date: 2024-12-01 12:31:47
tags:
- author:ridesun
---

# 总结
通过这段时间的学习,我对于Unikernel到宏内核再到HyperVisor有了初步的了解。并且在Lab1中深入到内存管理进行实操,但是由于调试技巧不够熟练,没有及时发现Alloc规律,在完结后才做出来理想的成绩。
希望在接下来的学习中能够对ArceOS有更深的了解,学习到更多知识。

## Unikernel
+ 单应用
+ 单地址空间
+ 单特权级
## 层次化(通过features实现)
+ crates(与ArceOS无关的公共组件)
+ modules(ax前缀,与ArceOS绑定)
+ ulib(Rust和C应用程序支持,包括有限的libc)
+ apps
已实现POSIX调用 arceos_posix_api
暂未实现rust_std和c_musl

## 灵活配置
### 最基础例子
```toml
[dependencies]
axstd = { git = "https://github.com/arceos-org/arceos.git" }
```

```rust
#![cfg_attr(feature = "axstd", no_std)]
#![cfg_attr(feature = "axstd", no_main)]

#[cfg(feature = "axstd")]
use axstd::println;

#[cfg_attr(feature = "axstd", no_mangle)]
fn main() {
println!("Hello, world!");
}
```

## 同个模块包含不同实现
[目前Apps的依赖情况](https://github.com/arceos-org/arceos-apps#list-of-rust-apps)

## 组件之间相互调用
### 上层调用底层
+ ulib -> modules/crates
+ modules -> modules/crates
+ crates -> crates
### 底层调用上层和避免依赖循环
#### crate_interface
[docs.rs](https://docs.rs/crate_interface/latest/crate_interface/)
使用Rust FFI调用
## 应用自定义组件
**在App层实现自定义组件**
无需修改已有组件
### 实现细则
基于各个modules提供的trait,自己具体实现
例子:axfs_vfs::{VfsOps,VfsNodeOps}
#### feature myfs
```rust
use crate::dev::Disk;
use alloc::sync::Arc;
use axfs_vfs::VfsOps;

/// The interface to define custom filesystems in user apps.
#[crate_interface::def_interface]
pub trait MyFileSystemIf {
/// Creates a new instance of the filesystem with initialization.
///
/// TODO: use generic disk type
fn new_myfs(disk: Disk) -> Arc<dyn VfsOps>;
}

pub(crate) fn new_myfs(disk: Disk) -> Arc<dyn VfsOps> {
crate_interface::call_interface!(MyFileSystemIf::new_myfs(disk))
}
```

## 方便的单元测试
cargo test

## Unikernel
+ 单应用
+ 单地址空间
共用一个地址空间,不区分用户空间和内核空间
+ 单特权级
不区分用户态和内核态
通常运行在Hypervisor上,由Hypervisor提供运行体之间安全隔离保护
## 组件->组件化OS
### 组件
+ 预组建
+ 可复用
+ 封装特定功能
+ 独立实体
+ 通过公开接口与外部通信
**组件Crate**
### 组件化OS
+ 基于组件来构建OS
+ 根据应用需求,选择底层(系统引导)、中层(核心功能)、上层(驱动、服务)、顶层(应用)组件来构造
**组件化OS工厂**
#### 优点
+ 构建效率
+ 稳定可靠
+ 可融合成熟设计
+ 发布前经过测试
+ 被其他环境验证
+ 安全性高
## 基于组件构建OS
只包括App的所有依赖
对于一个共同流程内的不同操作,将策略从主干中剥离出来,由单独组件处理
外部接口相同,内部实现不同
***trait***

0 comments on commit d1445f8

Please sign in to comment.