- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我写了一个简单的例子,包括 2 个任务:任务 1 和任务 2。任务 1 的优先级高于任务 2。在任务 1 函数中,我增加了任务 2 的优先级,使其优先级等于 (任务 1 的优先级 + 1)。此外,在任务 2 函数中,我将其优先级降低了 2,使其优先级低于任务 1。结果,执行顺序为任务 1 -> 任务 2 -> 任务 1 -> 任务 2 ...但是,当我运行代码时,任务 2 首先运行。有人可以帮我解决这个问题吗?我的代码和结果如下:
/* Standard includes. */
#include <stdio.h>
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "basic_io.h"
/*-----------------------------------------------------------*/
#define mainDELAY_LOOP_COUNT ( 0xffffff )
/*
* The tasks as described in the comments at the top of this file.
*/
static void prvTask1( void *pvParameters );
static void prvTask2( void *pvParameters );
/*
* The task parameters
*/
const char *pvTask1Param = "Continuous task 1 is running\n";
const char *pvTask2Param = "Continuous task 2 is running\n";
xTaskHandle xTask1Handle, xTask2Handle;
/*-----------------------------------------------------------*/
void main( void )
{
/* Start the two tasks as described in the comments at the top of this
file. */
xTaskCreate( prvTask1, /* The function that implements the task. */
"Task 1", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
100, /* The size of the stack to allocate to the task. */
(void*)pvTask1Param, /* The parameter passed to the task - just to check the functionality. */
2, /* The priority assigned to the task. */
&xTask1Handle ); /* The task handle is not required, so NULL is passed. */
xTaskCreate( prvTask2, "Task 2", 100, (void*)pvTask2Param, 1, &xTask2Handle );
/* Start the tasks and timer running. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following
line will never be reached. If the following line does execute, then
there was insufficient FreeRTOS heap memory available for the idle and/or
timer tasks to be created. See the memory management section on the
FreeRTOS web site for more details. */
for( ;; );
}
/*-----------------------------------------------------------*/
static void prvTask1( void *pvParameters )
{
char *string = (char*)pvParameters;
for( ;; )
{
vPrintString(string);
portBASE_TYPE task1Priority = uxTaskPriorityGet(NULL);
vTaskPrioritySet(xTask2Handle, task1Priority+1);
}
}
/*-----------------------------------------------------------*/
static void prvTask2( void *pvParameters )
{
char *string = (char*)pvParameters;
for( ;; )
{
vPrintString(string);
portBASE_TYPE task2Priority = uxTaskPriorityGet(NULL);
vTaskPrioritySet(NULL, task2Priority-2);
}
}
/*-----------------------------------------------------------*/
最佳答案
我刚刚尝试在 FreeRTOS Windows port 中运行它使用 FreeRTOS V8.2.3,输出显示任务 1 首先运行,我认为这符合预期:
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
Continuous task 1 is running
Continuous task 2 is running
关于C: freeRTOS 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33801180/
我正在使用 http://www.freertos.org/对于应用程序,但我找不到自启动以来如何获取系统时间。我可以创建一个任务并不断更新计数器,但我认为这不是一件好事,因为调度程序可能会安排我的任
我正在开始使用 freeRTOS。我浏览了 freeRTOS.org 中提供的文档,并对一些演示项目进行了一些练习。我的问题是如何在不使用 win32 端口的情况下安装 freeRTOS(因为它只是一
我正在开始使用 freeRTOS。我浏览了 freeRTOS.org 中提供的文档,并对一些演示项目进行了一些练习。我的问题是如何在不使用 win32 端口的情况下安装 freeRTOS(因为它只是一
当使用依赖于 WFI 指令的无滴答空闲功能时,我在 FreeRTOS 的 Cortex-M 端口中看到以下几行 __asm volatile( "dsb" ); __asm volatile( "wf
我在 Linux 下使用 C 编写了一个应用程序,其中使用自定义结构创建队列。代码运行得很好。现在我想修改该代码以使用 freeRTOS 运行它。这是我第一次接触 RTO。在浏览文档时,我发现 fre
哪些参数定义了 FreeRTOS 中的时间片持续时间,以及如何计算在切换一个任务并切换到另一个任务之前它将运行多长时间。 我找到了 configTICK_RATE_HZ,它设置了每秒的滴答数,但它与任
我开始使用 FreeRTOS,我想要一个中断来抢占任何即将运行的任务并运行我需要关键运行的任务。 有没有办法在 FreeRTOS 中执行此操作? (这是通过任务优先级实现的吗?) 最佳答案 不!以上两
我有 STM32F746ZG Nucleo-144pin 板并使用 STMCubeMx 生成代码。我选择了CubeMx提供的10.0.0版本的FreeRTOS,工具链是SW4STM32。 我做了两个任
我正在学习 freeRTOS。我需要在 PIC32 平台(cerebot Mx7ck)的 freeRTOS 中编写软件中断 ISR 处理程序。我浏览了文档,但没有帮助。请有人帮忙。 最佳答案 您是在寻
FreeRTOS 使用什么样的调度程序? 我在某处读到它是一个运行完成调度程序,但另一方面,我也看到它与并行任务一起使用,所以它不会是一个循环调度程序? 最佳答案 最高优先级的任务被授予CPU时间。如
FreeRTOS 使用什么样的调度程序? 我在某处读到它是一个运行完成调度程序,但另一方面,我也看到它与并行任务一起使用,所以它不会是一个循环调度程序? 最佳答案 最高优先级的任务被授予CPU时间。如
我正在构建一个 FreeRTOS 应用程序。我创建了一个模块,它从另一个模块注册 freeRTOS 队列句柄,当该模块中发生中断时,它会向所有注册的队列发送一条消息。但似乎我能够从队列发送消息,但无法
在 cortex M0 MCU 上的一些 FreeRTOS 演示中 configMINIMAL_STACK_SIZE设置为 60,而其他一些设置为 70。使用 STM32Cube 软件将其设置为 12
我想创建两个在 FreeRTOS 中同时运行的任务。第一个任务将处理 LED,第二个任务将监视温度。我有两个问题: 这段代码会创建两个同时运行的任务吗? 如何在任务之间发送数据,例如:如果温度超过 x
我正在读取 dsPIC30F6014A 上 ADC channel 上的一些数据。为此,我为每个 ADC 实现了一个单独的任务(例如 7 个 channel -7 个任务)。 我只在开始时创建了所有任
我写了一个简单的例子,包括 2 个任务:任务 1 和任务 2。任务 1 的优先级高于任务 2。在任务 1 函数中,我增加了任务 2 的优先级,使其优先级等于 (任务 1 的优先级 + 1)。此外,在任
我有一个任务在 freeRTOS 上运行,我正在检查该应用程序中有多少应用程序堆栈未使用。我看到的是,可用堆栈内存在一段时间后会减少,并在很长一段时间内保持在该值。该任务有一个 while(1) 循环
让一个线程修改原子单元(例如字符)而另一个线程仅读取它是否安全?当然,在允许这样做的环境中,例如 freertos。 我得到了一些执行此操作的代码,它使用 bool (定义为 char)作为信号量,我
我正在使用 ARM Cortex-M4 微 Controller 来开发带有 FreeRTOS 的应用程序。 为了精确计时,我想使用基于中断的计时器。中断具有适当的优先级,因此它应该能够调用 Free
我是 FreeRTOS (ARM CM3) 的初学者,我的问题是: 当你创建一个内部有一些局部变量的任务时,将这些变量存储在 RAM 中,堆栈中(由 main() 使用)就像局部变量的一般情况一样,或
我是一名优秀的程序员,十分优秀!