taskPrioritySet - VxWorks

This is a discussion on taskPrioritySet - VxWorks ; Hi, I would like to know the "price" for setting priority by using "taskPrioritySet" every 2mS. I know it's not recommended. But can someone list the disadvantages ? (I don't necessarily mean performance) Thanks in advance, Tal...

+ Reply to Thread
Results 1 to 7 of 7

Thread: taskPrioritySet

  1. taskPrioritySet

    Hi,

    I would like to know the "price" for setting priority by using
    "taskPrioritySet" every 2mS. I know it's not recommended. But can
    someone list the disadvantages ? (I don't necessarily mean performance)

    Thanks in advance,

    Tal


  2. Re: taskPrioritySet


    tal כתב:
    > Hi,
    >
    > I would like to know the "price" for setting priority by using
    > "taskPrioritySet" every 2mS. I know it's not recommended. But can
    > someone list the disadvantages ? (I don't necessarily mean performance)
    >
    > Thanks in advance,
    >
    > Tal


    Imho, it depends on system tick length. If the system tick is 10 ms,
    then to set the task priority each 2 ms is an overkill, since only last

    value will be considered by task scheduler.

    HTH,
    Akiva.


  3. Re: taskPrioritySet

    Hi..

    I was reading through embedded.com.....when I came across a article
    about Scheduling Sporadic Events (By Lonnie Vanzandt ).....I think
    taskPrioritySet can be used to dynamically assign proirities for real
    time sporadic tasks....

    Pls let me know...

    Abhijit


  4. Re: taskPrioritySet

    kirillsdv@yahoo.com wrote:

    >tal כתב:
    >>
    >> I would like to know the "price" for setting priority by using
    >> "taskPrioritySet" every 2mS. I know it's not recommended. But can
    >> someone list the disadvantages ? (I don't necessarily mean performance)


    I've given this question a lot of thought and I haven't come up with any
    "price" and disadvatages. I haven't come up with a reason to need doing
    it either, but that's a different matter! As for it being not recommended,
    I found this in the version 5.5 VxWorks Programmer's Guide:

    You can also change a tasks priority level while it is executing by
    calling taskPrioritySet( ). The ability to change task priorities
    dynamically allows applications to track precedence changes in the
    real world.

    This seems to imply changing tasks' priorities is an acceptable technique
    but doesn't specify unacceptable rates of doing so.

    >Imho, it depends on system tick length. If the system tick is 10 ms,
    >then to set the task priority each 2 ms is an overkill, since only last
    >value will be considered by task scheduler.


    The system tick rate matters to the scheduler only under the relatively
    unusual condition of using round-robin scheduling. Otherwise, it is
    events such as giving semaphores, writing on message queues, and the like
    that invoke the scheduler, but not the system tick.

    --
    ================================================== ======================
    Michael Kesti | "And like, one and one don't make
    | two, one and one make one."
    mrkesti at comcast dot net | - The Who, Bargain

  5. Re: taskPrioritySet

    That's a very subtle, but important point; that task switching does not
    occur on tickRate boundaries.

    Since the VxWorks scheduler is pre-emptive, as soon as you set the
    "work" task priority higher than the currently running task, it will
    run.

    Likewise, the work task should reduce its priority when it is done its
    thing. Otherwise, you need an even higher priority task (or ISR) to
    reduce the work task priority again. Lots of assumptions about what
    you're trying to do, but it can be tricky trying to get VxWorks
    scheduler to copy the behavior of other (say, Linux) scheduling
    algorithms.


  6. Re: taskPrioritySet

    Thanks for the responses.

    The cause of the question was actually to *disqualify* the idea of
    dynamically change priorities so often.
    I'd rather split a task into two, then use one task and change its
    priorities dynamically.
    The problem is, that this decision does not depend just on me.
    I'm just seeking for good arguments.

    The following takes place in the system:

    1. The system contains an important event, say A, which must be
    processed every 5 mS.

    2. The system contains 2 tasks, say: task-1, and task-2.

    3. Event A should be processed in the context of task-1. But task-1
    has other events to process which their priority is more or less as the
    priorities in task-2.

    The solution that appears to be implemented is, that task-1 gets high
    priority for event A, but as soon as it finishes, it would lower its
    priority below the one of task-2.
    It relies on the fact that Task-2 does not have much work to do, and
    when it's done, it would higher task-1 priority again - to be the
    highest.

    I hope it is clearer now.
    Thanks again.

    Tal


  7. Re: taskPrioritySet

    I think having to change a task priority is a sign of bad design.

    I think what you call "task-1" that must be high priority to process
    "event-A" should be split into 2 tasks "task-1a" and "task-1b". Then
    you have task-1a running at a high priority that blocks on event-A,
    meanwhile you've got task-1b that is running at a lower priority, but
    if you need task-1b to do things only after event-A then there should
    be a semaphore released by task-1a that unblocks task-1b.

    This is similar to the ISR paradigm where you have a high-priority task
    that does the actual work of the ISR, and the actual ISR just releases
    a sem to unblock the task.


+ Reply to Thread