This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTX Tiny: Round-robin questions

The RTX51 Tiny "tips" article states the following:

Round-robin multitasking is preemptive. It interrupts your task and switches to a new task after the specified number of OS ticks. Refer to CONF_TNY.A51.

But elsewhere in the documentation (http://www.keil.com/support/man/docs/tr51/tr51_sysreq.htm, among others), it is stated that Tiny can only do cooperative (not preemptive) multitasking. Why the discrepancy?

Also: task priorities can not be assigned in RTX-Tiny (as per the above referenced article). So why does the option to disable round-robin task switching (in conf_tiny_banking.a51) exist if round-robin is the only allowed method anyway? In other words, will the system act any differently whether or not RR is disabled?

  • among others), it is stated that Tiny can only do cooperative (not preemptive) multitasking. Why the discrepancy?

    There isn't one. The documentation talks about three different types of multitasking:

    1. Cooperative multitasking, in which each task has to volunatarily transfer control back to the operating system.

    2. Round-robin multitasking, in which each task has its control over the CPU taken away by the operating system when its time slice is up.

    3. Preemptive multitasking, where different tasks can pre-empt each other depending on their priority.

    Tiny can do 1 and 2, but not 3.

    So why does the option to disable round-robin task switching (in conf_tiny_banking.a51) exist if round-robin is the only allowed method anyway?

    Disabling round-robin task switching will leave cooperative multitasking as the available multitasking method.

  • Okay, I guess it's a matter of semantics then.

    An OS is usually described in 1 of 2 methods of task-scheduling (cooperative or preemptive) and 1 of 2 methods of selecting the next task (round-robin or priority). Option 1 is round-robin cooperative. Option 2 is indeed round-robin but it is also preemptive (because the OS will preempt the running task). Option 3 is priority preemptive.

    So this chart is not accurate when it states that RTX Tiny is not preemptive:
    http://www.keil.com/c51/rtx51tiny/specs.asp

  • Yes, the traditional definition of preemptive doesn't have anything with priority to do. It just means that a task switch is asynchronous, whereas a non-preemptive OS can only switch a task when the task calls a subset of the OS API, for example a wait function.

    Keil seems to have narrowed down the definition of preemptive to mean an OS that may switch threads before the thread has consumed it's full time slice (or voluntary offered a task switch).

  • So this chart is not accurate when it states that RTX Tiny is not preemptive:

    The chart is accurate. Preemption means that one task can interrupt another task. The operating system can always interrupt a task, even when it does cooperative multitasking, else it isn't really an operating system, but just a superloop.

  • No, preemptive (if ýou look in a book about OS) means any OS that does not require the task to call magic switch functions. If the OS time-slices tasks, then it is preemptive. Priority or variable-length time strata does not really matter. That is a second dimension when talking about scheduling.

  • Preemption means that one task can interrupt another task.

    As Per says, this is not really the meaning of this word in a task-switching context. And that reiterates my point:
    (from various Keil support articles)
    Round-robin multitasking is allowed in RTX Tiny.
    Round-robin multitasking is preemptive.
    Preemptive task-switching is not allowed in RTX Tiny.

    The wording is confusing and self-conflicting.

    The operating system can always interrupt a task, even when it does cooperative multitasking

    This is not true. When in this mode, the only way a task can be switched is if it voluntarily gives up its command to the OS (os_wait, os_switch_task, etc).

    Thank you gentlemen, I think I have my answer.