flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Greg_M 11 Jun 2025, 00:48
Greg_M wrote:
The key is to store the registers and other context when a task is switched out and restore the context when the task is switched back to. The SP register and other particular registers that are used for the task switch process itself are handled as special cases for context save/restore (e.g. the SP would be in the Task struct). |
|||
![]() |
|
bzt 14 Jun 2025, 04:55
TL;DR: RTOS is not about multitasking, it's about scheduling.
Greg_M wrote: The keys to a true multithreaded RTOS kernel: Greg_M wrote: #1 Hardware interrupt driven, based on time slice timer e.g. 10 millisecond. - When you do an interrupt at precise intervals, then your kernel will have "ticks". Easier to implement but you'll loose performance (you'll have to handle the interrupt even when it does not trigger a task switch). - If you dynamically program your timer to do an interrupt when the task's time slice runs out, that's called a "tickless" kernel. Harder to do it right, but this is what all modern OS kernels do. Greg_M wrote: The secret sauce here is that the PC on the stack is where Task A was running when interrupted. What RTOS really means is, that you can calculate the time slices in advance for each task, so that you can predict how tasks will be scheduled, therefore you'll be able to run a task at an exact time. - If you can always guarantee that a task will be scheduled at the requested time, then you have a hard real-time kernel. - If it's possible that a task might miss its deadline, then that's called a soft real-time kernel. As you can see, the thing that makes an RTOS is mostly about scheduling and timing tasks, and not about how the task switching is actually implemented. See Criteria for real-time computing. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.