Ipc Spec

IPC Philosophy Separates the object instances (which are process-specific) from the data they manage (which is shared). This design allows each process to have its own interface objects while manipulating the same underlying shared memory structures through atomic operations. Each process initiates the different object instances with the same memory data. We should use the spin, atomic and any inter-process synchronization to ensure this. No Ownership: The handle doesn’t own the shared data Pointer-Based: Use NonNull<T> to reference shared memory Safe Drop: Only cleanup process-local resources, never touch shared memory Multiple Handles: Many processes can have handles to the same queue data Memory Layout Refer Claude ...

September 20, 2025 · nostalgia

Uring Investigation

Record of Learning of Uring What is uring? [Week 1] uring SQ: Submission queue based on circular queue CQ: Completion queue based on circular queue SQE/CQE: the entry of SQ/CQ In linux design, SQ only store the serial number of SQEs, CQ store the whole data. Submission: Put SQE in SQEs, record cardinal, update SQ tail. Repeat for multiple task. Completion: Kernel complete task, update CQ head. User receive task, update CQ tail. What is a lock free ring buffer? ring [Week 2] ...

September 20, 2025 · nostalgia

2025 Spring Opencamp of Kernel-Summary

开源操作系统训练营第四阶段总结 - Axembassy 模块化 起步 作为一名物理学学生,对于内核等相关方向一无所知,而进行异步方向的选择则仅仅因为第四阶段并没有更为清晰的介绍。但不论如何,学习任何知识,进行思考都不会有害。 尝试进行Embassy的组件化实际上只是最初的粗糙想法,并非深思熟虑的思考。但至少在初步的实践上迈出的这一步,不论坚实与否。 过程 刚开始的时候并未和老师联系,自己在一个人摸索。 在初步的摸索中尝试先进行用户态的Executor设计,参照源代码使用CondVar。这一部分的探索在Arceos中构建出CondVar后便结束。接下来想尝试注册时间相关的功能逻辑,在过程中因为对基础知识不熟悉,走了相当的弯路。代码应该少而精,而摸索总是草率和混乱的。 运行时植入线程的过程也并不顺利,特别是对于_pender()过程的思考过于复杂,无形中浪费了很多时间。这时向老师推荐我去阅读ArielOS的源码。在阅读和理清思路后,这一推进简洁了不少。 但是测试的结果虽然近似预期,但是测试的逻辑存在问题,这一问题则是在之后才发现并修正,在当时完成后便按照老师要求尝试进行优先级的构建。 优先级的构建仍有波折,主要的关键在于确定通过改变概率分布的方式调整poll的概率分布之后,如何动态调整优先级的检查以保证任务的抽取不会饥饿。这一点思考在几天后有了一定想法,各个优先级具有吸引优先级检查的能力,通过不同的吸引力来保证动态的可持续。 在进行包含优先级的测试时发现之前的测试出现问题,便着手在此重新完全测试。测试的结果显示出协程的一定优势。但是因为期末考试的冲突总结的完成迟迟滞后,老师推荐我尽量复习为重,但是老师也不断强调阶段性的成果展示,所以还是硬着头皮参加了最后的总结,成了反例。:( 未完待续 老师在最后总结也强调,阶段性的成果重要但不是真正的要求。学习和思考是持续不断的,所以这篇总结在现在完成,迟了半月却并非结束,而是未完待续。 雄关漫道真如铁,而今迈步从头越。

July 3, 2025 · nostalgia

Embassy Investigation

Embassy Investigation Asynchronous Future Trait will be given with a poll to check pending or ready. And the ability to prod Waker to poll again in the future. Runtime/Exectutor: The real implementation to dispatch/poll Future. async/await is the simplification workflow of callback. Which await will pause and return control to the executor until the production of output. But the whole workflow requires no need for manual callback handling. Whole process doesn’t require multiple independent stack which will grows in heavy concurrency. ...

July 3, 2025 · nostalgia

AxEmbassy Report

◀ Prev Next ▶ Page 1 / ? ⬇ Download

July 2, 2025 · nostalgia

AxEmbassy Preempt

AxEmbassy-Preempt Development Embassy use head insertion to add a new task, adn poll every task in sequence. In order to add preemption, we can’t modify embassy itself due to self-referent structure. Another strategy is to modify Future itself with a priority system to change the probability of polling distribution. To ensure a trace of future, we use TaskId. After a initiation of future, we insert it in Scheduler. struct PrioScheduler { // u64 is the count of task in given prio level. prios: BTreeMap<Prio, u64>, tasks: BTreeMap<TaskId, Prio>, } impl<F: Future> Future for PrioFuture<F> { ... fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let this = unsafe { self.get_unchecked_mut() }; // Register on first poll if !this.registered { SCHEDULER.lock().insert(this.prio, this.id); this.registered = true; } ... } } A given task has a priority level, we use reverse order, higher priority corresponds to smaller number. ...

June 12, 2025 · nostalgia

AxEmbassy Measure

AxEmbassy-Measure We consider embassy task instance, which is async as same work unit as native thread. Thus we let them do same work, measure the deviation from the expected sleep time as the standard. (async) fn busy_work(iters: u64) -> u64 { let mut total = 0; for _ in 0..iters { total = black_box(total + 1); (yield_now.await/yield_now()) } black_box(total) } Above code is the busy work each thread/task need to do. With yield_now as a await point to fully exploit the mechanism of async. ...

June 7, 2025 · nostalgia

AxEmbassy Development

AxEmbassy-Development Design and Background AxEmbassy module is the incorporation of Embassy and Arceos. Mainly for aiding Arceos by async runtime of Embassy. We know, usually there are 3 ways for executor implementation. SWI software interrupt: Based on InterruptExecutor. Single thread: Based on Executor without threads interaction, immediately trapped in async process. Multi-thread: Based on Executor with threads interaction(waited to be designed) We choose last two methods, and tackle the design for multi-thread as the priority. Rather the reason to relinquish the first is due to the complicated and tough coding for implementation basic hardware interface, which is beyond. ...

June 7, 2025 · nostalgia

Ariel Embassy

Embassy on Ariel-OS Executor Types They are multiple ways to implement and integrate embassy functionality. Embassy is a runtime existing in whole life time of program. Thus any async execution will be entrapped in runtime scheduling. First is the most simple, we directly entrap everything in such runtime scheduling. This means a sole thread. #[cfg(feature = "executor-single-thread")] #[unsafe(export_name = "__ariel_os_embassy_init")] fn init() -> ! { use static_cell::StaticCell; debug!("ariel-os-embassy::init(): using single thread executor"); let p = hal::init(); static EXECUTOR: StaticCell<hal::Executor> = StaticCell::new(); EXECUTOR .init_with(|| hal::Executor::new()) .run(|spawner| spawner.must_spawn(init_task(p))) } ...

May 30, 2025 · nostalgia

Special Relativity

Special Relativity Symmetry $$ t' = \gamma(t - \frac{v}{c^2}x) \\ x' = \gamma(x - vt) $$or: $$ ct' = \gamma(ct - \beta x) \\ x' = \gamma(x - \beta ct) $$Which is same for interval as a vector. What does it say? It means we describe the 4-vector component in another frame $\Sigma’$ by $\Sigma$. That’s means basis will changes reversely($t’ \hat{t’} + r’ \hat{r’}$). It’s symmetric that $x’^\mu = \Lambda^\mu_\nu x^\nu \lrarr x^\mu = \Lambda^{-1 \mu }_\nu x^\nu$. ...

April 22, 2025 · nostalgia