clarification - round robin scheduling - VxWorks

This is a discussion on clarification - round robin scheduling - VxWorks ; Perusing the vxWorks programmers guide and would like to ensure I'm understanding round robin scheduling. For discussion purposes - assume my kernelTimeSlice is set for 10 hertz. i.e KernelTimeSlice ( 10 ) ; Now given two tasks - foo_task1 and ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: clarification - round robin scheduling

  1. clarification - round robin scheduling

    Perusing the vxWorks programmers guide and would like to ensure I'm
    understanding round robin scheduling.

    For discussion purposes - assume my kernelTimeSlice is set for 10
    hertz. i.e
    KernelTimeSlice ( 10 ) ;

    Now given two tasks - foo_task1 and foo_task2 of equal priority. So
    now:
    void foo_task 1 ()
    {
    if ( semTake ( ft_sema1, WAIT_FOREVER ) != OK )
    continue;
    for ( int idx ( 0 ) ; idx < 10; ++idx )
    {
    do_special_thing ( ) ;
    }
    }

    void foo_task2 ()
    {
    while ( 1 )
    {
    if ( semTake ( ft_sema2, WAIT_FOREVER ) != OK )
    continue;
    for ( int jdx ( 0 ) ; jdx < 10; ++jdx )
    {
    do_another_thing ( ) ;
    }
    }
    }

    The scenario: Assume I received a semaphore ft_sema1. As a result,
    I'll begin to execute do_special_thing. Assume that when idx was 3, I
    received the semaphore for ft_sema2. As I understand it. foo_task2
    will not execute ( even though it received a semaphore ) until
    foo_task1 has reached kernelTimeSlice _even_ if foo_task1 finished
    within/long before the specified time slice. Am I correct on this?
    In essence, what I'm trying to get at is this. It appears with round
    robin you need to your time slice just right. Meaning a task could
    finish executing oso long ago but another task is unable to run simply
    because the previous tasks time slice hasn't elapsed. In alot of
    ways, this is for the most part common sense but I'm just wanting to
    clarify.


  2. Re: clarification - round robin scheduling

    Hello,

    Actually the round robin scheduling in VxWorks is still premption based
    and is not monotonic. A task uses its time slice in full as long as it
    does not block or is not preempted by a higher priority task. If it
    blocks (pending on an unavailable semaphore for instance) it
    immediately relinquishes the semaphore and the highest priority ready
    task starts to run. When the semaphore becomes available and the task
    is ready to run again then it executes during the remainder of its time
    slice (provided that it is not preempted) at which point it is
    scheduled out.

    You can see the round robin scheduling policy as evenly/fairly applying
    among all tasks at the same priority level. If higher priority tasks
    exist in the system they will preempt the lower priority ones. If a
    task blocks before the end of its time slice the next highest priority
    ready task (which may or may not be a task at the same priority level
    as the task that blocked) starts immediately.

    Hope this helps,

    --
    PAD


  3. Re: clarification - round robin scheduling


    PAD wrote:

    > You can see the round robin scheduling policy as evenly/fairly applying
    > among all tasks at the same priority level. If higher priority tasks
    > exist in the system they will preempt the lower priority ones. If a
    > task blocks before the end of its time slice the next highest priority
    > ready task (which may or may not be a task at the same priority level
    > as the task that blocked) starts immediately.


    I see. Just so I'm not mistaken. Now going back to my example and
    lets further assume there's NO higher or lower priority tasks. Meaning
    I've only got two tasks ( foo_task1 and foo_task2 ) above - both of
    equal priority.
    Again foo_task1 receives a semaphore and is executing within it's time
    slice. When idx is say 3 in foo_task1, foo_task2 receives it's
    semaphore. I think what you're saying is. foo_task1 will continue
    execution for the duration of _its_ timeslice at which point foo_task2
    will begin execution. Correct?


  4. Re: clarification - round robin scheduling


    ma740988@gmail.com wrote:
    > I see. Just so I'm not mistaken. Now going back to my example and
    > lets further assume there's NO higher or lower priority tasks. Meaning
    > I've only got two tasks ( foo_task1 and foo_task2 ) above - both of
    > equal priority.
    > Again foo_task1 receives a semaphore and is executing within it's time
    > slice. When idx is say 3 in foo_task1, foo_task2 receives it's
    > semaphore. I think what you're saying is. foo_task1 will continue
    > execution for the duration of _its_ timeslice at which point foo_task2
    > will begin execution. Correct?


    Assuming there is nothing that can block foo_task1 then, yes, foo_task1
    will continue executing until its time is up, at which point foo_task2
    resumes its execution.

    --
    PAD


+ Reply to Thread