PLAIN VM versus Java VM and .NET

One of the questions we should ask is why we don’t use Java or C# since they both have a similar VM design? .NET Micro would actually run on the F405 MCU’s as well. The answer lies in the requirement “Real-time centric”. In short these VM’s introduce a design that causes them to have a Not Recommended status in higher quality standards like IEC61508 and MISRA.

Exceptions is a mechanism that allows you to do a jump in code execution if you detect an error. I have replaced this with a new mechanism called Event’s that behave exactly the opposite way – an exception makes a try catch jump that causes yet another exception cascading to a fatal error if it is not handled. You have seen it – this long Java or C# exception error that stop an application and make a minor error fatal. It is a nightmare to handle in a real-time system.

Event’s is basically a return code allowing you to continue processing depending on what happens – if it is not coded nothing shall happen. The difference is that a minor error remains minor.

Garbage Handler is a replaced with a Controlled Memory handler. Java/C# uses dynamic memory through a manager that will allocate/remove memory at it’s own doing. This creates errors of it’s own, but most importantly is that we don’t allow dynamic memory usage. We need a memory manager to ensure that all “dynamic” memory usage actually is static.

The third issue is features like size of VM library, inclusion of native C/C++ code and in general how well we target small MCU’s. I am not sure how small I can get the level 2 implementation, but I have a wage hope that I can run it on a STM32F030F4 with only 16Kb Flash and 4Kb SRAM – PBASIC introduced back in 1979 was a VM running from 8Kb ROM so it should be possible, but lets see.

Leave a Reply