工作站和嵌入式程序员之间的心态差异 [英] Mindset difference between workstation and embedded programmers

查看:120
本文介绍了工作站和嵌入式程序员之间的心态差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你认为在一个桌面环境(windows,linux,无论什么...)和在嵌入式系统上工作的人的程序员之间的心态有什么区别?

What do you think are the difference in mindset between a programmer doing work for a desktop environment (windows, linux, whatever...) and someone doing work on an embedded system?

我可以想到的一个简单的例子是,在嵌入式环境中,我总是检查一个malloc不是NULL。大多数代码我已经看到,目标桌面当然不是检查malloc返回值的努力。

A simple example I can think of is that in an embedded environment, I always check that a malloc is not NULL. Most code I have seen that target desktops is certainly not diligent in checking malloc return value.

任何其他心态差异的例子?

Any other examples of mindset differences?

推荐答案

有趣的是你在这个例子中提到了malloc()。

Funny that you mention malloc() specifically in your example.

在每一个硬实时,深入嵌入的系统,我已经工作,内存分配被特别管理(通常不是堆,但固定的内存池或类似的东西)...而且,只要有可能,所有的内存分配是在初始化前完成的。这比大多数人都会相信容易得多。

In every hard-real-time, deeply embedded system that I've worked on, memory allocation is managed specially (usually not the heap, but fixed memory pools or something similar)... and also, whenever possible, all memory allocation is done up-front during initialization. This is surprisingly easier than most people would believe.

malloc()容易受到碎片的影响,是非确定性的,并且不会在内存类型之间丢弃。使用内存池,您可以使用位于/从超快速SRAM,快速DRAM,电池备份RAM(我已经看到)等位置的池...

malloc() is vulnerable to fragmentation, is non-deterministic, and doesn't discrminate between memory types. With memory pools, you can have pools that are located/pulling from super fast SRAM, fast DRAM, battery-backed RAM (I've seen it), etc...

另外还有一百个问题(在你的原始问题的答案中),但内存分配是一个很大的问题。

There are a hundred other issues (in answer to your original question), but memory allocation is a big one.

另外:


  • 尊重/了解硬件平台

  • 不会自动使硬件完美,甚至功能

  • 意识到某些语言的含义

  • 意识到CPU加载和内存利用率

  • 意识到中断,预先对共享数据的影响(绝对必要 - 数据越少越好)

  • 大多数嵌入式系统是数据/事件驱动的,而不是轮询;当然有例外

  • 大多数嵌入式开发人员都非常喜欢状态机和状态行为/建模的概念。

  • Respect for / knowledge of the hardware platform
  • Not automatically asssuming the hardware is perfect or even functional
  • Awareness of certain language apects & features (e.g., exceptions in C++) that can cause things to go sideways quickly
  • Awareness of CPU loading and memory utilization
  • Awareness of interrupts, pre-emption, and the implications on shared data (where absolutely necessary -- the less shared data, the better)
  • Most embedded systems are data/event driven, as opposed to polled; there are exceptions of course
  • Most embedded developers are pretty comfortable with the concept of state machines and stateful behavior/modeling

这篇关于工作站和嵌入式程序员之间的心态差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆