Damien wrote:
[*]
Ability to allocate memory on an interrupt
Interrupts and callbacks play a large role in microcontrollers, especially to get real-time performance, and uPy should have good support for them. Currently you can run code on an interrupt, but you can't allocate heap memory during such an interrupt. The memory allocator can be made re-entrant so that memory can be allocated during an interrupt (steps have been made in this direction already, but more work and testing is needed). With this improvement you could write some very sophisticated control code that responded within a guaranteed time to an external event.[/list]
Improvements for embedded use (eg as replacement for Lua, or its Javascript equivalent: duktape,
https://github.com/svaarala/duktape):
The biggest issue with allocating is that it might trigger a garbage collect (as I see it), and that would be bad during an interrupt.
When I worked with one of the PIC series it had a whole bunch of "remapping" features, such as remappable pins, uart, etc (where you could actually move which PIN register C5 or UART1_TX pointed to).
Anyway, one of the features it had was the ability to set interrupt levels on different kinds of interrupts. So you could say that a edge interrupt was more critical than a uart interrupt (for example) etc etc.
Hopefully modern ARM chips have this feature, as what you could do is have levels of interrupts. Level 1 is the highest and you can't use anything but global variables, but the lower levels have various "promises" in terms of how soon they will be available. Let's say level 2 will always be available within 10us. At 168MHz you get 1680 operations in 10us. That's a lot of operations! You could move 6.7kB of data in that time, for instance.
So you could have various levels of interrupts, only the highest one having the requirement of "only global variables"
I think for any of this to work though, you need a thread that continuously keeps everything suitably garbage collected (and defragmented?) that when the system asks for small amounts of memory it can be fulfilled quickly.