hello friends i have written the code for ARM RTOS, i have used same priority for all of my 4 task, its working fine
my problem is when i change the priority in the code then all task's are not executing simultaneously.... please any one help
i am using LPC2148 ARM processor, it has RTX Kernel OS in it. and i had posted the code in the above, please tel me which priority can i select to make that code to work for all task
OK, so you've found how to use the tags for Bold - wasn't so hard, was it?
So how about now posting your source code using the correct tags for source code?
If your "buzzer()" function returns, your program is falling of a cliff! Did you read RTX's user manual?
__task void job1(vod) { buzzer() ; for (;;) // Do you have an infinite loop in your tasks? { } }
The same applies to other tasks as well.
i dont have any infinite loop in my task now
Then you MUST start by reading RTX's user manual - you cannot go on like this! Start here:
http://www.keil.com/support/man/docs/rlarm/rlarm_ar_artxarm.htm
So you posted a version of the code with all comments and declarations stripped.
But more importantly - you posted code that didn't show a single task loop.
Didn't you read my original comment? Let me repeat it: "Does the high-prio tasks share time?"
A high-prio task that wants to consume 100% CPU time will consume 100% CPU time unless you have a task with even higher priority that wants to be serviced, or you have interrupts that needs servicing.
i had used in the beginning , even though i am facing same problem
if i keep infinite loop also , program is not executing according to the priority wise
it means that you are saying me to use lower priority for the job1 and litle higher priority for the job2 and so on?
Maybe. But he's also saying that you should start by reading the user manual first. You cannot expect your program to function according to your expectations if it contains fundamental errors! At this moment there is little point in asking more questions; fix the glaring errors, come back when it is up and running.
Programs - whether RTOS or not - neither know nor care anything of your expectations.
Programs function according to the specifications given in the relevant Documentation.
It is up to you to study the Documentation, and base your expectations on what you find there.
I'm saying that when you have tasks with same priority, you can have the RTOS let each task run for a lite while in a round robin order.
When you have tasks with different priorities, you must make sure that tasks with high priority have some method to decide when they have work to do (and consumes 100% CPU time) and when they can donate CPU time to lower-prioritized threads.
One way for a high-priority task to donate CPU time is to make use of delay/sleep calls, telling the OS that the thread don't need any CPU time for x time slices.
Another way is a high-priority task that waits for an event. While the event isn't available, the OS will dedicate the CPU capacity to other tasks. As soon as an interrupt or other thread sets the event, or sends mail or whatever, then the high-prio task will wake up and do the requested action before going to sleep again, waiting for yet another event.
But in the end, you only have one processor. It can't be at multiple locations at the same time. With "normal" operating systems, the OS will slowly increase the priority of starved tasks until they get a tiny bit of CPU time before they drop back to their low priority again.
An RTOS is designed for real-time performance. It expects the developer to make the decisions how to prioritize and make sure that different tasks gets performed within their specific timing requirements. You are that developer. Have you set up rules for what your realtime requirements are? Have you verified that all your tasks fulfills their own requirements without breaking requirements for other - same or higher prioritized - tasks? You have a limited CPU budget - how are you spending it?
Thank you Per Westermark
i hope i dont know the concept of the OS first of a;ll so can any one guide/provide me some sites for knowing the OS concept Properly?
"can any one guide/provide me some sites for knowing the OS concept Properly?"
The following might be a pretty good start:
http://www.keil.com/download/docs/403.asp
please tell me when the event will set in the down code
os_evt_set (0x00ff,tsk4);
os_evt_wait_or (0x0001, 0xffff); // Wait until ISR triggers an event
when the ISR will trigger that event i means when that event will set?
Your code must call os_evt_set() or isr_evt_set() when your code have decided that it needs something done by the thread that is listening for that specific event.
If your program never needs the receiving thread to be woken up and process any event then maybe your code don't even need that thread.
So if you have a thread buzzer_thread, then that thread can sleep until some other part of the program needs the buzzer to sound. Then the part that wants the buzzer to sound can set the event, getting the buzzer thread to wake up and activate the buzzer.
Note that threads are used when you need multiple things performed concurrently. If all you need is to set a GPIO pin to start a buzzer and then clear the pin x seconds or milliseconds later, then you would normally not need a buzzer thread - it would be simple to have a main loop set the buzzer and have your time handling (counting OS time slices or maybe timer interrupts or whatever) silence the buzzer after a suitable amount of time.
In the end, you must decide what is suitable threads. And you must decide if the individual threads needs to perform work continuously (motivating either round-robin execution using same priority, or letting them have a loop with a sleep in), or if some of the threads should only be woken up when specific things happens (such as when the clock becomes 07:00 in the mortning, or when someone presses a button or serial data is received from an UART), or if some of the threads should activate periodically such as once every second.
We don't know anything about your project, so we can't tell what is suitable tasks, or what is suitable reasons for them to wake up.