Go Down

Topic: XMEM2 - Now with real preemptive multitasking (Read 1 time) previous topic - next topic


Apr 16, 2013, 04:29 pm Last Edit: Jun 03, 2013, 05:24 pm by ajk_ Reason: 1
For those of us who need more room...

XMEM2 @ https://github.com/xxxajk/xmem2

xmem2 is an xmem compatible library with autosize features.

Supports both RuggedCircuits RAM expansions automatically. Supports Andy Brown's RAM expansion too.

Can support up to 255 banks of external memory, with minor sketch changes.

NEW: Supports moving the stack to external memory. You can even specify how much.

NEW:  XMEM2 now supports real preemptive multitasking!

On the QuadRam, 16 tasks are possible.
Each task has it's own stack, and malloc arena.
Tasks are switched in round-robin order.
The shared stack/malloc arena area is 32KB and you can split it how ever you wish.
Best of all *NO RTOS OVERHEAD*

Multitasking Demo @ https://github.com/xxxajk/testMultitask

NEW: CPU cycle friendly Sleep()
     Lock_Acquire(), Lock_Release(), Yield()
     Ability to determine parent task.
     Ability to detect when a task is running or done.
     Ability to determine if parent task owns child task.

More features coming as needed.



   Thanks for posting the Xmem2. I'm trying to make use of a Rugged Circuits QuadRam board to add memory to my mega 2560 project.

   I've downloaded Xmem2 from github, and placed it in my (apple mac)  Arduino/libraries folder.
   Then I got testMultiTask and opened Arduino (1.5.2), but when I compile the sketch, I get a series of errors;

testMultitask.ino: In function 'void task_B()':
testMultitask:70: error: 'Sleep' is not a member of 'xmem'
testMultitask.ino: In function 'void setup()':
testMultitask:112: error: 'SetupTask' is not a member of 'xmem'

So, looking at the header file, I defined   USE_MULTIPLE_APP_API
( I don't actually need Multi tasking in my project,just extra ram space). But then I get the following error about redefinition of malloc & free;
(BTW; I get this with Andy Browns Xmem too...)

/Applications/Arduino-152.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/libc.a(malloc.o): In function `malloc':
/Users/cs/Developer/Hardware/AVR-USB/AVRMacPack/buildtmp.nobackup/avr-libc-1.6.4/avr/lib/avr6/../../../libc/stdlib/malloc.c:78: multiple definition of `malloc'
core.a(malloc.c.o):/Applications/Arduino-152.app/Contents/Resources/Java/hardware/arduino/avr/cores/arduino/malloc.c:82: first defined here
/Applications/Arduino-152.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
/Applications/Arduino-152.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/libc.a(malloc.o): In function `free':
/Users/cs/Developer/Hardware/AVR-USB/AVRMacPack/buildtmp.nobackup/avr-libc-1.6.4/avr/lib/avr6/../../../libc/stdlib/malloc.c:195: multiple definition of `free'
core.a(malloc.c.o):/Applications/Arduino-152.app/Contents/Resources/Java/hardware/arduino/avr/cores/arduino/malloc.c:194: first defined here
testMultitask.cpp.o: In function `setup':
/Applications/testMultitask.ino:112: undefined reference to `xmem::SetupTask(void (*)())'
/Applications/testMultitask.ino:113: undefined reference to `xmem::StartTask(unsigned char)'
/Applications/testMultitask.ino:114: undefined reference to `xmem::SetupTask(void (*)())'
/Applications/testMultitask.ino:115: undefined reference to `xmem::StartTask(unsigned char)'
/Applications/testMultitask.ino:116: undefined reference to `xmem::SetupTask(void (*)())'
/Applications/testMultitask.ino:117: undefined reference to `xmem::StartTask(unsigned char)'
testMultitask.cpp.o: In function `task_B()':
/Applications/testMultitask.ino:70: undefined reference to `xmem::Sleep(unsigned long long)'

Have I missed something crucial in the docs somewhere?  Any suggestions?

Mark B

Go Up