简体   繁体   English

使用 freeRTOS 队列 API 或使用自定义数据结构在 freeRTOS 应用程序中创建队列更好吗?

[英]Is it better to create a queue in a freeRTOS application using freeRTOS queue API, or by using a custom data structure?

I have written an application using C under Linux where queues are created using custom structures.我在 Linux 下使用 C 编写了一个应用程序,其中使用自定义结构创建队列。 The code is running just fine.代码运行得很好。 Now I would like to adapt that code to run it using freeRTOS.现在我想修改该代码以使用 freeRTOS 运行它。 It is my first time dealing with a rtos.这是我第一次处理 rtos。 While going through the documentation, I found that freeRTOS supports queues API.在浏览文档时,我发现 freeRTOS 支持队列 API。 So, I was wondering if I have to use those API to create queues, or can I just keep the custom structs??所以,我想知道我是否必须使用那些 API 来创建队列,或者我可以保留自定义结构吗?

It depends.这取决于。 Queues are included in freeRTOS because they are required for task switching and other core OS features to work.队列包含在 freeRTOS 中,因为它们是任务切换和其他核心操作系统功能工作所必需的。 If you are getting low on storage space (flash memory), it may make sense to use the "free" (as in, it's going to already be there) implementation in freeRTOS.如果您的存储空间(闪存)越来越少,那么在 freeRTOS 中使用“免费”(如,它将已经存在)实现可能是有意义的。 In addition, freeRTOS's queue implementation is pretty good overall.另外,freeRTOS 的队列实现总体来说还是不错的。

If you are in somewhat of a timecrunch and you have plenty of flash, I'd just keep with what works.如果你有点时间紧迫并且你有很多 flash,我会继续使用有效的方法。 If you've tested it and it works, keep using it.如果您已经对其进行了测试并且可以正常工作,请继续使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM