K210 FreeRTOS多任务多核系统调度
多任务 freeRTOS 多核
2023-09-11 14:21:44 时间
一、目的
众所周知,K210这款AI新品是一款64bit 双核芯片,其支持裸机编程,并且官方也提供freertos sdk,方便开发者在其上进行多任务应用开发。那么如何进行任务创建和多核开发呢。
二、参考
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
static void task_0(void *args) {
while (1) {
printf("task 0 on core %d is polling\n", (int)uxPortGetProcessorId());
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}
static void task_1(void *args) {
while (1) {
printf("task 1 on core %d is polling\n", (int)uxPortGetProcessorId());
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}
int main() {
printf("Hello K210!!!\n");
//在core 0上创建一个优先级为5的任务task_0
xTaskCreateAtProcessor(0, task_0, "task0", 1024, NULL, 5, NULL);
//在core 1上创建一个优先级为5的任务task_0
xTaskCreateAtProcessor(1, task_1, "task1", 1024, NULL, 5, NULL);
while (1) {
printf("main on core %d is polling\n", (int)uxPortGetProcessorId());
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
在上一篇博文中,我们已经介绍过,main函数是freertos在core 0上创建的一个线程,构建烧写后从日志上可以看到跟预期一下。
--- Miniterm on /dev/ttyUSB0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Hello K210!!!
task 0 on core 0 is polling
task 1 nocer0 i polling
g
task 0 on core 0 is polling
task 1 on core 1 is polling
task 0 on core 0 is polling
main on core 0 ta ko1lon
ore 1 is polling
task 0 on core 0 is polling
task 1 on core 1 is polling
task 0 on core 0 is polling
main on core 0 is polling
task 1 on core 1 is polling
task 0 on core 0 is polling
task 1 on core 1 is polling
task 0 on core 0 is polling
main on core 0 is polling
task 1 on core 1 is polling
至此,一个最简单的多任务多核应用介绍结束。
相关文章
- itop4412学习-上层应用多任务开发
- android 之断点续传详解三部曲之[三] → 多任务同时下载
- Android app不被列入Recents多任务列表
- 【第24篇】YOLOR:多任务的统一网络
- 线程的概念 线程和进程的比较 多线程的用处 线程的基本操作 线程的创建 验证多线程实现多任务 及线程间共享全局变量 验证线程函数传参 collect2: error: ld returned 1 e
- FreeRTOS 任务基础知识 多任务系统 任务与协程 任务状态 任务优先级 任务实现 任务控制块 任务堆栈
- win + linux + android 多任务分屏
- CompletableFuture多任务异步,获取返回值,汇总结果
- 【多任务的实现】