Does the scheduler library utilize 2 cores?

Im trrying to play with the scheduler library that is available to the portenta and rp2040 series board. i would like to ask if it will utilize both cores of the microcontroller or it will onnly use 1

I thought this was an Arduino web site, I must be wrong :zipper_mouth_face:

the scheduler library is an arduino library :stuck_out_tongue: . Soooo where else would i go?

Post a GitHub link to "the scheduler library".

this seem to be the official one, BuT it does not look to be the arduino is using because the example that was in the IDE is different to the one in that repo

I can upload the .h and .cpp that my ide is compiling though its fairly short

.h

/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _SCHEDULER_H_
#define _SCHEDULER_H_

#include <Arduino.h>
#include "mbed.h"

#define MAX_THREADS_NUMBER	10

extern "C" {
	typedef void (*SchedulerTask)(void);
	typedef void (*SchedulerParametricTask)(void *);
}

class SchedulerClass {
public:
	SchedulerClass();
	void startLoop(SchedulerTask task, uint32_t stackSize = 1024);
	void start(SchedulerTask task, uint32_t stackSize = 1024);
	void start(SchedulerParametricTask task, void *data, uint32_t stackSize = 1024);

	void yield() { ::yield(); };
private:
	rtos::Thread* threads[MAX_THREADS_NUMBER] = {NULL};
};

extern SchedulerClass Scheduler;

#endif

.cpp

/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "Scheduler.h"

SchedulerClass::SchedulerClass() {

}

static void loophelper(SchedulerTask task) {
	while (1) {
		task();
	}
}

void SchedulerClass::startLoop(SchedulerTask task, uint32_t stackSize) {
	int i = 0;
	while (threads[i] != NULL && i < MAX_THREADS_NUMBER) {
		i++;
	}
	threads[i] = new rtos::Thread(osPriorityNormal, stackSize);
	threads[i]->start(mbed::callback(loophelper, task));
}

void SchedulerClass::start(SchedulerTask task, uint32_t stackSize) {
	int i = 0;
	while (threads[i] != NULL && i < MAX_THREADS_NUMBER) {
		i++;
	}
	threads[i] = new rtos::Thread(osPriorityNormal, stackSize);
	threads[i]->start(task);
}

void SchedulerClass::start(SchedulerParametricTask task, void *taskData, uint32_t stackSize) {
	int i = 0;
	while (threads[i] != NULL && i < MAX_THREADS_NUMBER) {
		i++;
	}
	threads[i] = new rtos::Thread(osPriorityNormal, stackSize);
	threads[i]->start(mbed::callback(task, taskData));
}

SchedulerClass Scheduler;


Given that the processors on all those boards are all single-core, it seems unlikely that the library accommodates scheduling on 2 cores.

If you noticed on the source files, they are completlt different . On the .cpp alone being used on the rp2040 it seems to be accessing a form of rtos

The ESP32 has 2 cores and comes with freeRTOS which allows the programing of both cores.

yes thats why im still unsure if the scheduler uses 2 cores, since i know in rtos you can use 2 cores

Only if the processor has 2 cores. As noted, those mentioned on the Scheduler Library GitHub page are all single-core.

I do not think that is the one the IDE is using, i checked the compile debug for the file path of the source files . Check my post (post number5). the source code is totally different from that repository

Right. But none of the task creation function calls in that code seem to mention anything about assigning a core. So, perhaps you'll have to give up on your goal of doing it the "Arduino Way" and use the raw capabilities of the RTOS. That's what you have to do if you want to use both cores in ESP32 / FreeRTOS.

I actually do not want it to use the second core, that is what i am making sure of. Since i have another thing planned for the second core. Im not familiar of rtos , and i thought rtos::Thread will utilize the second core if its available.

If the secheduler is making freeRTOS calls then it can use both cores on an esp32. Look through the library and do a search on "vTask", if you get a result it could very well be able to use both cores.

On an ESP32 you can assign tasks to a particular core with the freeRTOS OS.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.