mbed RTOS basic question

12 Sep 2012

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

12 Sep 2012

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

13 Sep 2012

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

13 Sep 2012

Never mind, got it. cheers!

25 Oct 2012

Ali,

Can you publish a example how to set the priority of a thread.

Thanks, Gerrit