I am developing an application where I have multiple threads. I want to distribute these threads on 2 CPU cores of ESP32.
To achieve this I am trying to use multicore functionality. I have downloaded micropython v1.12 and compiled with esp-idf V3.3.
As I can see in the code I can use core 1 as mentioned in - micropython-1.12\ports\esp32\main.c, function app_main, line 188
Code: Select all
xTaskCreatePinnedToCore(mp_task, "mp_task", MP_TASK_STACK_LEN, NULL, MP_TASK_PRIORITY, &mp_main_task_handle, MP_TASK_COREID);
// where MP_TASK_COREID = 1
Here is my python code:
Code: Select all
from utime import sleep_ms, sleep, time
import _thread
def test0(p1,p2):
print("This is test 0 ")
count = 0
while True:
print("test0", count)
count+=1
sleep(1)
def test1(p1,p2):
print("This is test 1 ")
cnt = 0
while True:
sleep(2)
print("test1", cnt)
cnt+=1
_thread.stack_size(40*1024)
_thread.start_new_thread(test0, (1, 0))
print()
_thread.start_new_thread(test1, (1, 1))
print("Threads started...")
Thanks,
-Rajendra