10

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?

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?

1
  • in embedded you "end with learning" printf(). In general programming, you start at printf() and work your way up the abstraction. Commented Nov 25, 2015 at 17:54

5 Answers 5

15

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() 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.

Also:

  • 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
1
  • I've done quite a number of embedded projects, and only used malloc() in one, which was running on embedded DOS. Checking malloc() for null seems more a DOS-era thing than an embedded-systems thing, since embedded systems are often better off with a single- or double-ended LIFO heap allocator (in many cases, a LIFO allocator can let one get by with 2-4 bytes of total overhead system-wide, with zero overhead per block).
    – supercat
    Commented Feb 2, 2011 at 5:54
9

Desktop programmers view resources as practically unlimited. Memory, computing power, drive space. Those never run out. Embedded programmers focus intently on all of those.

Oh, and embedded programmers also often have to worry about memory alignment issues. Desktop coders don't. The Arm chips care. x86 chips don't.

2
  • Can you elaborate on the : "The Arm chips care. x86 chips don't."
    – JeffV
    Commented Feb 13, 2009 at 14:13
  • 4
    Sure. Most non-x86 CPUs like the ARM that is so popular in embedded systems will only read an integer if it is on a DWORD (32-bit) boundary. They will fault if asked to read a non-aligned int. The x86 will happily read such an int, it will just be a little slow.
    – Steve Rowe
    Commented Feb 14, 2009 at 5:28
8

I desktop environment there's the idea that "hey I can always release an update or patch to fix this later." In embedded design, you get more "this has to work cause we don't want to recall the device or release an even longer patching program."

2
  • Although the ability to issue firmware updates is moving the embedded world into a mindset closer to the desktop one more and more over time... Commented Feb 12, 2009 at 4:44
  • Agreed, we can see this with new EEPROMs and the ability to release flash updates. As seen on motherboards for years and we'll probably be seeing on graphics cards soon. You can now program your own shaders which get applied to the gfx card now.
    – Suroot
    Commented Feb 12, 2009 at 4:50
8

size matters

3
  • 2
    all the woman say the same ...
    – rcs20
    Commented Feb 28, 2012 at 20:48
  • size, time, memory allocation and initilization. infinite loop and timing issue need to be take care.
    – kapilddit
    Commented Jul 19, 2012 at 10:38
  • C'mon people, when you downvote, tell me why (especially years after the fact)
    – KevinDTimm
    Commented Dec 18, 2012 at 2:43
1

2 things - as Suroot already mentioned, once you release a desktop app, it doesn't have to be "forever", especially nowadays.

But in embedded, once you "ship it", it's on its way to Mars so you're not going to be able to pull it back.

Also one of the major differences are that embedded programmers are generally a LOT more conscious about efficient code and memory management - desktops run horrible code really fast, embedded doesn't.

2
  • I think they actually did a firmware update on the Mars rovers.
    – JeffV
    Commented Feb 13, 2009 at 14:17
  • 1
    I bet that's what you would call an "intense" moment while it restarts... ;)
    – Brandon
    Commented Feb 13, 2009 at 17:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.