在嵌入式实时环境中如何使用D? [英] How would you approach using D in a embedded real-time environment?
问题描述
对于熟悉 D编程语言的所有人员,如何在嵌入式实时环境?我明白,它的原始设计不是实时嵌入式环境的目标,但是这个问题更多地是关于如何实现实时功能。
其中
你看到哪些结构将是一个问题?
有没有人成功地在嵌入式系统中使用它?
任何其他想法或建议都会很棒。
垃圾收集不是灵丹妙药。有一些缺点:
- 收集运行时不可预测,因此程序可以任意暂停。
- 集合运行所需的时间不受限制。虽然在实践中这是非常快的,这是不能保证。
- 收集器线程以外的所有线程必须在集合进行中停止。您仍然可以使用没有垃圾收集器的D(通过手动管理内存,如C / C ++) - 这将阻止您使用某些语言功能,如关联数组和库函数,内部分配内存,而不会取消分配/返回对它的引用。在许多不依赖内存管理的领域(如元编程),D仍然擅长。
To all those familiar with D programming language, how would go about using it in a embedded real-time environment? I understand that it's original design is not targeted for real-time embedded environments, but this question is more about how would you go about making real-time capability happen.
Which constructs of the language would be indispensable?
Which constructs do you see would be a problem?
Has anyone successfully used it in a embedded system?
Any other thoughts or suggestions would be great.
解决方案D isn't really meant for use in real-time applications, mostly because some language features of D rely on its garbage collector, and D's garbage collector is unpredictable and will sporadically pause your program to collect garbage. Quoting:
Garbage collection is not a panacea. There are some downsides:
- It is not predictable when a collection gets run, so the program can arbitrarily pause.
- The time it takes for a collection to run is not bounded. While in practice it is very quick, this cannot be guaranteed.
- All threads other than the collector thread must be halted while the collection is in progress.
You can still use D without a garbage collector (by managing memory manually, like in C/C++) - this will prevent you from using certain language features like associative arrays, and library functions that internally allocate memory without deallocating/returning a reference to it. D still excels in many areas not dependent on memory management (such as metaprogramming).
这篇关于在嵌入式实时环境中如何使用D?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!