mbed RTOS basic question
Topic last updated
25 Oct 2012, by
Ali Kilisli.
4 replies
Greetings,
I've had some experience in c and c++ coding, but am new to mbed and rtos. I've been playing with the mbed-rtos library and example program and I was wondering if anyone could tell me how to view a threads priority information, basically I'm wondering how to use get_priority(), when you call this function what is it returning? I do have a serial communication port set up so I can print things to screen. As well, how can the priority of threads be changed?
Thanks
Replies
Hi Ali,
The get_priority method return an osPriority value. osPriority is an enum defined as:
typedef enum {
osPriorityIdle = -3, ///< priority: idle (lowest)
osPriorityLow = -2, ///< priority: low
osPriorityBelowNormal = -1, ///< priority: below normal
osPriorityNormal = 0, ///< priority: normal (default)
osPriorityAboveNormal = +1, ///< priority: above normal
osPriorityHigh = +2, ///< priority: high
osPriorityRealtime = +3, ///< priority: realtime (highest)
osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
} osPriority;
You can change the priority of a thread by using (for instance):
thread.set_priority(osPriorityHigh)
Cheers,
Sam
Thanks Sam!
But for some reason when I tried to print it to screen it didn't work as follows:
int g = thread.get_priority();
pc.putc((char)g);
it compiles, but nothing is printed to screen
Never mind, got it. cheers!
GerritPathuis
#
25 Oct 2012
Ali,
Can you publish a example how to set the priority of a thread.
Thanks,
Gerrit
Please log in to post a reply.
Greetings,
I've had some experience in c and c++ coding, but am new to mbed and rtos. I've been playing with the mbed-rtos library and example program and I was wondering if anyone could tell me how to view a threads priority information, basically I'm wondering how to use get_priority(), when you call this function what is it returning? I do have a serial communication port set up so I can print things to screen. As well, how can the priority of threads be changed?
Thanks