RTL8710AF and arduino IDE 1.8.7 ,thread not getting executed

Hello
I have RTL8710F development board and Arduino IDE 1.8.7 I am creating two threads , one of thread is below

wifi_handle = os_thread_create(wifi_service_thread, NULL,OS_PRIORITY_REALTIME, 2048 * 32);

what I am observing this thread (wifi_service_thread ) is not executing where as main thread which executing loop() gets all the microcontroller time,

what I should do to fix this problem

By default, the main thread is given the highest priority, as it is assumed that most processing will be done in loop(). If you want to use the RTOS to manage threads, you can try lowering the main thread priority in \AppData\Local\Arduino15\packages\realtek\hardware\Ameba1\2.0.10\cores\arduino\main.cpp in order to suit your application.

Hello,

I am using os priority (OS_PRIORITY_REALTIME) in second thread also ,same as main thread(loop()) ,should’nt wifi_service_thread get cpu (microcontroller) time because of round robin scheduling , when I put wifi service thread in loop() , it gets all the cpu time and other thread does not get any cpu time

-Thanks
-Alok

@Alok_Kumar_Mishra

I can’t seem to replicate your problem, running the code below, the task outputs appear to be normal, both tasks set at the same priority as main gets called.

#include "cmsis_os.h"

osThreadId tidA = 0;
osThreadId tidB = 0;

void threadA(void const* pvParameters) {
  Serial.println("Thread A: Started");
  for (;;) {
    Serial.println("A");
    //executeTaskWithDelayInside();
    delay(3000);
  }
}

void threadB(void const* pvParameters) {
  Serial.println("Thread B: Started");
  for (;;) {
    Serial.println("B");
    delay(3000);
  }
}

void setup() {
  Serial.begin(115200);
  tidA = (osThreadId)os_thread_create(threadA, NULL,OS_PRIORITY_REALTIME, 512);
  tidB = (osThreadId)os_thread_create(threadB, NULL,OS_PRIORITY_REALTIME, 512);
}

void loop() {
  Serial.print("M");
}

Output:

12:03:24.706 -> B
12:03:24.706 -> A
12:03:24.706 -> MMM [...abbreviated...] MB
12:03:27.711 -> MA
12:03:27.711 -> MMM [...abbreviated...] MB
12:03:30.713 -> MA
12:03:30.713 -> MMM [...abbreviated...] MB
12:03:33.669 -> MA
12:03:33.669 -> MMM [...abbreviated...] MB
12:03:36.673 -> MA
12:03:36.673 -> MMM [...abbreviated...] MB
12:03:39.679 -> MA

If the priority of thread A and B are set to OS_PRIORITY_REALTIME - 1, neither will get called, which is expected since the main thread is only yielding and not blocking.