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

Concurrent task processing in LPC2148

Hi all,

I am using RTX in LPC2148, I am using 3 tasks with different priority. I want to run the tasks periodically like task_1 run for every 10ms,task_2 runs for every 20ms and the third one for every 50ms.
Is this possible to run a task concurrently means i want to how to configure it. I try the below method

__task void task_1(void)
{ os_itv_set(10); while(1) { os_itv_wait();

/* my code goes here*/ }

}

same procedure i followed for remaining tasks, but i am not get what i am expected. Is there is any other ways are available in RTX.

Thanks in advance

Parents
  • Is this some abstract school project.

    Normally, tasks gets a priority based on the need for them to actually perform something. The high-priority tasks may then break in when a low-priority task was executing. And the high-priority task only breaks in when it has something to do, and then it returns to sleep as soon as it is done.

    In the end, it's not too common to need multiple threads that all have different priority and all are run by individual timers.

    Anyway - you don't tell us what you expect to happen, and what really is happening. And you aren't telling us how long the different tasks is busy doing something before they are ready to go back to sleep - which is important because they block lower-prio threads from being activated.

Reply
  • Is this some abstract school project.

    Normally, tasks gets a priority based on the need for them to actually perform something. The high-priority tasks may then break in when a low-priority task was executing. And the high-priority task only breaks in when it has something to do, and then it returns to sleep as soon as it is done.

    In the end, it's not too common to need multiple threads that all have different priority and all are run by individual timers.

    Anyway - you don't tell us what you expect to happen, and what really is happening. And you aren't telling us how long the different tasks is busy doing something before they are ready to go back to sleep - which is important because they block lower-prio threads from being activated.

Children
  • Hi I am using 3 tasks, task_1 value updated in 10 ms, task_2 value updated in 20ms, task_3 value updated in 50 ms,

    Hence i need to schedule it,

    Time_scale for my query is, 10ms task -> | | | | | | | | | | | | | | | | | | | | 20MS TASK -> | | | | | | | | | | 5Oms task -> | | | |
    | -> INDICATES TASK enabling,

    each 20 ms, task1 and task2 must in run condition
    as same as 5o ms task1,task3 in run condition in 100ms three task should go to run.I ask this thing only is this possible in RTX (LPC2148).

  • Hi I am using 3 tasks, task_1 value updated in 10 ms, task_2 value updated in 20ms, task_3 value updated in 50 ms,

    Hence i need to schedule it,

    Time_scale for my query is,
    10ms task -> | | | | | | | | | | | | | | | | | | | | 20MS TASK -> | | | | | | | | | | 5Oms task -> | | | |

    .
    | -> INDICATES TASK enabling,

    each 20 ms, task1 and task2 must in run condition
    as same as 5o ms task1,task3 in run condition in 100ms three task should go to run.I ask this thing only is this possible in RTX (LPC2148).

  • Of course you can schedule timer-controlled activation of your threads.

    Just that when the timer rings for multiple threads, then the highest-priority thread will run and the less prioritized thread will have to wait until the more prioritized thread ends.

    But you still haven't given any information what doesn't work for you. You just repeated the information from the original post in a different way, i.e. 10ms, 20ms and 50ms as the repeatable delays.

    If the three threads falls in sync, and every thread happens to need 5ms of CPU time to finish, and the 10ms/iteration thread happens to have the highest prio and the 50ms/iteration has the lowest prio then you'll end up with.

    A xxxxx.....xxxxx.....xxxxx.....xxxxx.....xxxxx.....xxxxx.....xxxxx.....
    B wwwwwxxxxx..........wwwwwxxxxx..........wwwwwxxxxx..........wwwwwxxxxx
    C wwwwwwwwwwwwwwwxxxxx..............................wwwwwxxxxx..........
    

    x = 1ms of processing time
    w = 1ms of waiting for the CPU but having too low priority
    . = 1ms of sleeping, waiting for next timer activation

    So the B thread with 20ms/iteration and less priority will regularly have to be delayed.
    And the C thread with 50ms/iteration and even less priority will have different amounts of delay at different times.

    The above would obviously change if the threads doesn't have their individual timers started at the same time, or if the threads have other CPU time needs. And in some situations, a thread might be allowed to start, and then preempted by a higher-prio thread and then once again reactivated to finish up the job.

    And the above diagram would also change depending on if the timer is restarted after each thread is run, or if the timer runs at a fixed frequency without caring about how much delayed the thread was.

  • Hi Per Westermark,

    Thanks for your response.Actually i am asking about schedule the task periodically, In our RTX it behaves as one task run at a time. I want to Run two or more task at the same time i mean parallel functions.

    task_1 in Running task_2Running task_2waiting, i saw in simulation-Debugging mode if any one task run other task goes to wait or ready state. [I am clearly tell i want two task in running condition meant parallel another one task in wait state, is this possible means how?]

  • I want to Run two or more task at the same time i mean parallel functions

    as far as I know the LPC2114 is not a multiprocessor chip

  • The OS performs task switching - i.e. it switches which task that runs at any one time. That's all your processor can manage. And that was all PC machines could manage too, until we got processors with multiple cores or with hyperthreading.

    And that was why I created a diagram that indicated that when both a high-prio and low-prio task wants to run at the same time, then the low-prio task will have to wait.

    The concurrency you get is through short time-slices where the processor jumps between the available threads or switches to the background "idle" thread if none of your threads wants to be serviced.

    This isn't a limitation of the operating system, but a limitation of the processor hardware. True concurrency requires that the processor has multiple program counters and can use them to pick up and execute multiple instructions concurrently. This level of functionality exists in PC machines and in newer mobile phones. But most microcontrollers are much smaller than that.