5 ms·
I'm looking at these long series of pushes and pops [1]. You have 26 general-purpose registers plus X, Y, Z. I wonder if it would be possible to have e.g. only
by avian 6y ago
I'm looking at these long series of pushes and pops [1]. You have 26 general-purpose registers plus X, Y, Z. I wonder if it would be possible to have e.g. only 4 threads and have dedicated registers for each thread, avoiding the need to store/load all of them on each context switch. This would reduce the overhead and might make this a bit more usable in the real world.
I mean, this is certainly possible when writing assembly. But I wonder if you can convince avr-gcc to do it. To have it limit its use of registers for a part of the compiled C code.
A similar problem appears with interrupt handlers in C [2]. avr-gcc is smart enough to only push/pop registers in a handler that were actually clobbered in the code. But if you call a function pointer from an interrupt handler, it will always push/pop entire CPU state since it will assume that the code the pointer points to will potentially clobber everything. This significantly increases interrupt latency.
[1] https://github.com/TurkeyMcMac/avr_threads/blob/master/avrt.S#L133 https://github.com/TurkeyMcMac/avr_threads/blob/master/avrt....
[2] https://www.avrfreaks.net/forum/calling-function-pointers-isr https://www.avrfreaks.net/forum/calling-function-pointers-is...
- jwmhjwmh 6y agoMaybe one could use the option -ffixed-reg and put different threads in different compilation units with different options. Even so, one would not be able to use the standard library, since it is not compiled with the right options, and even custom functions would have to be compiled separately for each thread. It would be a lot of hassle, but it might work.
- captncraig 6y agoIf you are gonna go through all that work with this chip in particular, you'd probably be better off putting four of them on one board. It's all kinda moot with more powerful chips available for cheaper anyway.
- ComputerGuru 6y agoI think adding a custom calling convention would be the way to go.
- deleted 6y ago[deleted]