paked / ross

0 stars 0 forks source link

multitasking #2

Open paked opened 3 years ago

paked commented 3 years ago

implement multitasking!

this requires:

  1. [x] a scheduler (system timer running at a regular time unit to pre-empt tasks)
  2. [x] code to context switch processes (once i figure this out i'll write some more info here)
paked commented 3 years ago

so we now have a timer interrupt which pulses every so often. which can form the basis of our round robin scheduler.

in leg-os we had a one-off function called parasite_process which took control of the main thread and began scheduling stuff. this is, imo, too much of a hack. to kick-off the scheduling bonanza i want something a bit more flexible. this was there because our scheduling logic was deeply tied to the STM32L4's interrupt logic.

i don't want to have two seperate ways of entering a process in this codebase. so, i propose we kick off the main thread with a yield svc command. this yield command will pull in the next running process, and switch to its context.

since svc will trigger an exception, we can use the same logic we use in the IRQ handler.

paked commented 3 years ago

so i've implemented most of this in a4013cfd6e942a988669e5461fa613091e9fc06b.

the only thing left to do is to add mark out some critical sections in our code base.

these could be:

  1. any of the current exceptions (or maybe we only do leaf functions? idk, not sure what the best way to handle is)
  2. any of the process_creation/death/lifecycle stuff

looks like we'll need to use the daifclr and daifset registers.