OSTaskCreate Return Values

Discussion to talk about software related topics only.
tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

OSTaskCreate Return Values

Post by tpannone » Mon Mar 04, 2019 8:16 am

I'm in the process of updating some MOD5282 code from Dev C++ 1.13 to NBE R2.7.7. The OSTaskCreate() function in one of four NB applications has started generating an error at runtime, returning the value of 70.

From the definition of OSTaskCreate in the uCOSLibrary, the return value is either 0 (Successful) or 40 (Priority already exists). In all of my NB applications, I set the my main loop priority to 23. I've looked at nburn\include\constants.h, and 23 does not interfere with any given system task priorities.

What could a OSTaskCreate return value of 70 mean?

User avatar
TomNB
Posts: 230
Joined: Tue May 10, 2016 8:22 am

Re: OSTaskCreate Return Values

Post by TomNB » Mon Mar 04, 2019 10:57 am

Hello,

All the return codes are in \nburn\include\ucos.h. 70 means you are out of task control blocks, so you may be creating more tasks than the system default limit of 20 (changable in predef.h)

Running your main priority at 23 is very dangerous, but I guess if you have it working somehow your architecture must be ok with it. The reason it is dangerous is that it puts main at a higher priority than all other system tasks such as TCP, IP, HTTP, etc, so your main task will preempt everything in the system. If you have something that is really important to do, the recommended way is to leave main at 50, and spawn a task that does just that one specific thing at such a high priority. But again, you are updating code from DevCpp (which must be 15 years old?), so if it is working for you, you might not want to change it.

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Mon Mar 04, 2019 11:05 am

Thanks Tom. I'll go back and look at the task control blocks.

This particular application would not need the priority so high, but our control algorithms still need to be higher than those system tasks you mentioned.

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Mon Mar 04, 2019 11:34 am

Interesting. I only call OSTaskCreate three times in my application. One for the Transmit UDP task, one for the Receive UDP task, and one for the main program loop. The other three create functions (OSTaskCreatewName, OSSimpleTaskCreate, and OSSimpleTaskCreatewName) are not called.

Are you sure predef.h is where the system default task limit is set to 20? There's not much in mine, and no #define statements setting anything to 20.

User avatar
TomNB
Posts: 230
Joined: Tue May 10, 2016 8:22 am

Re: OSTaskCreate Return Values

Post by TomNB » Mon Mar 04, 2019 4:30 pm

If you are running into that problem with creating only 3 tasks, then the number of tasks in prefef is not the problem. My guess is that maybe you made some low level modifications to get your critical code to run faster. Maybe you are doing something with onchip sram? fast vars in sram, etc. Anyway, creating a few tasks on a standard configuration would definitely not create the issue you are seeing.

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Tue Mar 05, 2019 6:36 am

Thanks again Tom. I'll look at the sram. I am seeing an issue reading back some data from flash at startup. I didn't think the two issues were related, but maybe they are.

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Fri Mar 08, 2019 5:50 am

Hi Tom,

I made a stupid mistake saying that this application has only 3 tasks created. It's more like 15. Most of those Transmit UDP and Receive UDP task creates were in a for loop.

Anyway, you said that the default limit for tasks is set to 20 in predef.h. I must be missing something because I do not see it in my copy of predef.h. I'm attaching my copy hoping you can point out where it is.
Attachments
predef.h
(6.95 KiB) Downloaded 7 times

ephogy
Posts: 28
Joined: Fri Aug 29, 2008 12:53 pm

Re: OSTaskCreate Return Values

Post by ephogy » Fri Mar 08, 2019 7:20 am

I think it might be in constants.h:

#define OS_MAX_TASKS 20 /* Max number of system tasks */

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Fri Mar 08, 2019 7:29 am

Yep... there it is. Thanks.

tpannone
Posts: 43
Joined: Fri Feb 15, 2013 1:04 pm

Re: OSTaskCreate Return Values

Post by tpannone » Fri Mar 08, 2019 8:01 am

Interesting. Now that I know where OS_MAX_TASKS is defined, I checked it in my old Dev C++ 1.13. There it is set to 25.

I'll bump it up to 25 in NBE 2.7.7 and see if it works.

Post Reply