Micrium uC-OS / II on Dynamic C / Rabbit - May Cause Hunger

I am trying to perform two tasks to run in Dynamic C under Micrium uC-OS / II. One task is the http handler, the other is the serial port. The serial port task seems to prevent the launch of the http task. Any idea why this is? I thought uC-OS / II is proactive.

void httptask(void* ptr) { http_init(); while(1) { http_handler(); } } void gpstask(void* ptr) { int c; while (1) { c = serFgetc(); } } 

Both threads have the same priority by default.

+4
source share
2 answers

uC / OS-II is preferable, but only in one direction - it will preempt a stream with a lower priority to allow a stream with a higher priority, but will not do the opposite. That is, threads with a higher priority must explicitly give up CPU control in order to allow threads with a lower priority. I am sure that your serial stream has higher priority than the HTTP stream, and that serFgetc() does not give up control at all (via OSMboxPend or OSTimeDly or some other procedure).

Try to either make the serial stream a downstream stream in the system, or put something in its code so that it can refuse to control the processor. (For example, waiting on a semaphore when there are no characters available, which semaphore you can send from an interrupt available for data.) Either should work.

+7
source

uC / OS-II only supports unique priorities. You also need something like OSTimeDLY (x) or some other element in your task loops to give up scheduler control.

+2
source

Source: https://habr.com/ru/post/1315286/


All Articles