robert-w-gries / rxinu

Rust implementation of Xinu educational operating system
Apache License 2.0
33 stars 4 forks source link

Various scheduling enhancements and fixes #41

Closed robert-w-gries closed 6 years ago

robert-w-gries commented 6 years ago

This is a follow-up to #33 that aims to stabilize the scheduling code and make various quality of life improvements to the module.

Reference counting in process list

Fixes #36

The processes in the process list should be reference counted. We need to guarantee that data shared between context switches will not be destroyed..

This issue manifested while running process cycles where current process, process_a, creates process_b and process_b creates process_a. We would randomly hit a page fault while trying to access the process list. The issue was that the reference in the process list was randomly destroyed. We need to explicitly tell the compiler that the process list contains data that will live long at runtime.

We'll use Arc instead of Rc because the references will also need to be safely shared across different CPUs when APIC is supported.

Use generic trait object for dynamic dispatch in process_ret

Our first stab at dynamic dispatch in the process_ret function assumed that the scheduler will always be a CoopScheduler. Since we know our scheduler will always implement kill, we should use the more general DoesScheduling trait object to call the kill method. Now, we can truly use any scheduler object in the kernel to create and kill processes properly.