Priority level question

Discussion to talk about software related topics only.
Post Reply
jdal
Posts: 21
Joined: Sat Jan 07, 2012 7:10 am

Priority level question

Post by jdal »

I was reading the "uCOSLibrary.pdf" file. On page 13 where it talks about OSChangePrio it says:

Description:
This function changes the priority of the calling task. Note: The uC/OS can only have one task at each priority level. Task priorities can range from 1 to 63, where 63 is the lowest priority level and 1 is highest priority level. Priorities 1-4 and the NetBurner system priority levels are reserved as described below. The recommended user priority levels for your application are in the range of 46 to 62. This avoids any conflicts with network communications.

Yet when i opened constants.h i find this list in there.
/* Recommend UserMain priority */
#define MAIN_PRIO (50)

/* Runtime library driver and support task priorities */
#define HTTP_PRIO (45)
#define PPP_PRIO (44)
#define SECURITY_TASK_PRIO (43)
#define WIFI_STATION_TASK_PRIO (42)
#define WIFI_TASK_PRIO (41)
#define ENC_TASK_PRIORITY (41)
#define TCP_PRIO (40)
#define IP_PRIO (39)
#define ETHER_SEND_PRIO (38)

/* Features */
/* SSH server must be lower than main for progress displays */
#define SSH_TASK_PRIORITY (56)
My question is can 2 tasks have the same priority, and if so how does that play out. The reason why i ask is that the .pdf file says "recommended user priority levels for your application are in the range of 46 to 62" yet "#define SSH_TASK_PRIORITY " is set to 56.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Priority level question

Post by Ridgeglider »

Each task must have a unique priority. However, some of the tasks in the system list you posted may not be used by all apps: SSH, or Wifi for example. This frees up those slots for other tasks at those default priorities in an app, however that app may need re-configuring if it ever needed Wifi or SSH later.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Priority level question

Post by tod »

A while back I posted my C++ TaskBase code on gisthub. that shows how to create a task and handles the error condition when the requested priority is already in use. The point of the class is that starting tasks requires a certain amount of boiler plate code and can be tricky to do right. The base class allows you to adhere to DRY. There is also an associated blog post The Easy Way To Start a Task that I wrote to aid in using the class and finally another related thread here on the forum that led to my posting my library code.
Post Reply