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
Don't you believe in indenting your code, and posting it using the proper tags, as clearly specified just above the message input box?
void job3 (void) __task { while (1) { SPI(); counter3++; if (counter3 == 0) { os_evt_set (0x00ff,tsk4); os_tsk_pass (); } } }
The above code is almost totally meaningless.
Why?
1) There isn't a single comment telling what it is expected to do, or more specifically why it things it does what it does.
2) You make 2^8 or 2^16 or 2^32 iterations of your loop - each iteration with a single call to SPI (which does some SPI communication without we knowing anything about if it just polls something or if it does a full transfer or whatever) and a single increment of your counter3 (which really is not a descriptive name of a symbol - counter3 third counter of what?)
3) First after having done 2^8 or 2^16 or 2^32 (or maybe even 2^64) iterations of your loop, you get an overflow and enter the body of the if statement. It sends a whole bunch of event flags to your tsk4 (yet another totally meaningless name - the goal of the task can't be to be #4, it really must have a purpose of some kind). Why send many event flags? A task may listen for multiple event flags, but you normally send single event flags depending on what event you want to announce. So you can send MY_EVENT_BEEP_BUZZER, MY_EVENT_HAVE_UART_DATA, MY_EVENT_xx and the task can poll or wait for any of the events to happen and then perform the corresponding action before starting to listen for more events.
4) First when the counter overflow do you call os_tsk_pass() - why? Did you think it would be a good idea to suddenly manually share a bit of the processor CPU time? If the processor is just round-robin-scheduling, then this call doesn't really fill any purpose other than to shorten this specific time slice. if it isn't round-robin-scheduling and this is a high-prio thread - how much CPU time do you think the other threads did get before you entered the if body? How much time do 2^8 or 2^16 or 2^32 or 2^64 calls to SPI() take?
5) Note also that os_tsk_pass() only shares CPU time with other tasks of same priority. If you have tasks with higher priority ready to run, then this task wouldn't have run so it wouldn't have been able to call os_tsk_pass(). And if you had other tasks with lower priority, they would still be at lower priority and not be allowed to run by your call to os_tsk_pass() - it can only send execution to the next task with same priority as your task3. If there are no other ready task with same priority, then task3 will instantly continue and start to do a new round of 2^8 or 2^16 or 2^32 or 2^64 calls to SPI().
So I really think you have to sit down and figure out what you want to do. And then read the documentation for the quite few functions available in RTX. It doesn't take long to read the descriptions and figure out what they do. And it doesn't take long to look at the sample code available in the manual and figure out how they are intended to be used. First then will it be meaningful for you to try to write any multithreaded application.