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. |
|||
![]() |
|
Greg_M 16 Jun 2025, 08:51
The tickless and variable scheduling is interesting and helpful.
Admittedly, my OP is geared more towards general OS and has less emphasis on the RT aspect. Still, variant-timing RT and tickless, can leverage much of, if not exactly, what is in my OP, depending upon the design. If a company is producing an embedded systems product and the goal is to implement V1.0 of a multithreading kernel for much better software development and processing, and RT purposes, then the kernel basics that I have provided are valuable. A true pre-emptive (RT)OS kernel has huge advantages over pseudo-multi-threading and prioritizing in a single-threaded software loop. Last edited by Greg_M on 17 Jun 2025, 12:28; edited 7 times in total |
|||
![]() |
|
bzt 17 Jun 2025, 09:47
Greg_M wrote: However, RT designs and even variable task timing thereof (scheduling), often use interrupt-driven task switching. Greg_M wrote: The yielding that you described, is also needed for suspend() And that's exactly why it's irrelevant for this discussion. Greg_M wrote: The task switching implementation is the key focus of the OP Greg_M wrote: This core applies to general OS, tickless, and RT. If you want this topic about "RTOS Kernel Basics", as the title suggests, then you should focus on predictability, timing and scheduling, etc., the actual multitasking details are irrelevant, as long as you can do it in O(1) time. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.