phil-opp / blog_os

Writing an OS in Rust

Home Page:http://os.phil-opp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Scheduler tutorial

afaq-optimtec opened this issue · comments

Scheduler is an integral part of an OS, can you make a tutorial for that?

Also make some small tutorials for raspberry pi, Os Wiki has rust bare metal tutorial, can you do something like that?

Regards

The generator/coroutine based method (untested) that I use in my kernel would make a great starting point for a preemptive multitasking tutorial. Would need to completely rewrite the blog from scratch in the RPi case however given how different ARM is from x86 at the assembly level.

The generator/coroutine based method (untested) that I use in my kernel would make a great starting point for a preemptive multitasking tutorial.

The last post of blog os is about async/await: https://os.phil-opp.com/async-await/

Would need to completely rewrite the blog from scratch in the RPi case however given how different ARM is from x86 at the assembly level.

True, there are quite some differences between ARM and x86 in terms of how many low level things that OSes require are implemented. For example page tables have a different format, the interrupt controller is different (and even differs between different soc's for arm although somewhat recently arm made a standard interrupt controller. not everyone uses it yet.), there is no vga text mode in arm (instead you have to write a display controller driver for the specific display controller of the soc to set up a framebuffer, or a serial port driver), there is no BIOS emulation of a PS/2 keyboard with dedicated interrupts (instead you likely have to write a full USB driver, or a serial port driver) and much more. For display output and keyboard input you may be able to use UEFI instead, but not every arm system has the option to run UEFI and in the case of keyboard input you must not exit boot services, which means that you can't do a lot of things expected from an OS like running usermode programs. Before exitting boot services you are effectively a program running under the UEFI "OS".

The generator/coroutine based method (untested) that I use in my kernel would make a great starting point for a preemptive multitasking tutorial.

The last post of blog os is about async/await: https://os.phil-opp.com/async-await/

That's cooperative, not preemptive. This unstable Rust feature (which is actually the raw underpinning that async/await uses behind the scenes) makes it possible to use combination of an enum, match within the coroutine closure, and yield within the coroutine closure if certain enum variants are matched to block execution from an interrupt handler.