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

Which task will run while calling os_switch_task ?

RTX51 Tiny User's Guide said: "The os_switch_task function allows a task to halt execution and allow another task to run."

If I have 5 tasks on READY state, which task will be switched to run while calling os_switch_task() ?

Parents Reply Children
  • Joost, I have found some information about priority of task, as follows:
    In http://www.keil.com/support/man/docs/tr51/tr51_sysreq.htm, it said:
    Preemptive task switching and task priorities are not supported. If your application requires preemptive task switching you must use the RTX51 Full Real-Time Executive.

    In http://www.keil.com/support/man/docs/bl51/bl51_l131.htm, it said:
    You have assigned a priority for an RTX51 Tiny task. RTX51 Tiny does not support priorities.

    In http://www.keil.com/forum/docs/thread5879.asp, Jon Ward wrote:

    RE: Question on RTX51Tiny os_wait
    Jon Ward
    ...there should be a "next_task" function that I can call simply to give other tasks a chance to execute...
    
    This is your lucky day. :-)
    
    There is such a function. It's called os_switch_task. Here's the manual page for it: http://www.keil.com/support/man/docs/tr51/tr51_os_switch_task.htm
    
    Jon
    

    In www.keil.com/.../c51_le_realtimefunctasks.htm, it said:
    The Cx51 Compiler supports the RTX51 Full and RTX51 Tiny real-time multitasking operating systems with the _task_ and _priority_ keywords.

    In http://www.keil.com/support/docs/1073.htm, it said:
    Change the priority to a number from 0 to 3.

    According to the information above, I guess(determine) conclusion:
    1. Only RTX51 Full supports task priority, you can use keyword _priority_ to decide, range from 0(lowest level) to 3(highest level).
    2. RTX51 Tiny doesn't support task priority. After I testing, you still can use keyword _priority_, but only value of 0. For example:

    void FUNC (void) _task_ 2 _priority_ 0 {
    }
    

    3. when calling os_switch_task(), if next task after current running task is in READY state, it will run immediately. For example:

    void FUNC (void) _task_ 2 {
      os_switch_task();  /* it will switch to task 3 to run */
    }
    

    If task 3 isn't at READY state, it will check task 4, and go on.

    4.task_id is from 0 to 15 circurly in RTX51 Tiny.