QDXOS - Quick and Dirty XMOS Operating System

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
monk_is_batman
Active Member
Posts: 38
Joined: Wed Jun 09, 2010 3:20 am
Location: Maine, USA

QDXOS - Quick and Dirty XMOS Operating System

Post by monk_is_batman »

First I would like to say hello, this is my first post in these forums. I started using XMOS a couple months ago for a project and am a huge fan of almost everything about these processors.

I am currently working on a fairly in depth project on a XC-1A involving analyzing USB Data. This project will have many components such as ethernet, USB, possibly UART, FLASH, SD-Cards, etc. Because of size of the project I plan on having something to manage all of the module, a sort of module to manage resources and what not.

So far in terms of a skeleton of this OS I already have a thread_create(), thread_exit(), and the ability to create and destroy channels at will. I plan on running 1 thread on each core so they can easily talk to each other and create threads wherever needed. I am now trying to figure out the best way to handle the dynamic code loading. I understand that the compiler generates position dependent code.

Is this possible to overcome by using macros for all function calls? I was thinking something in the code that lets the OS know there is a function call and to replace it with a branch to where it loads the code for that function.

I'm open to thoughts on any part of this but I'm trying to keep this streamline as I only have this summer to finish the project. I'm specifically looking for thoughts on dynamic code loading. I know that some people have discussed this on here before, but I haven't found any specific code that does it yet.


User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Nice id like to see how this OS of yours works out.

You could try code loading with modifying any address specific intrusions with the offset at what your are writing the code in to memory. Note that you must also watch out for ram allocation. Two modules might use the same address for a variable and that could cause some really strange behavior of the code. So id guess you also need some sort of memory management done too.
User avatar
monk_is_batman
Active Member
Posts: 38
Joined: Wed Jun 09, 2010 3:20 am
Location: Maine, USA

Post by monk_is_batman »

I had considered implementing some sort of memory manager, but if I can easily avoid it I will for now just to make things easier. I would like to mention that everything after this is speculation as I don't pretend to know anything about the inner workings of the XMOS compilers or how they do things.

That being said, I didn't think variables being in the same location would be a very big issue. As far as I know the local variables to each function will be stored on the stack which I plan allocating for each thread. Since there are channels that can be used I don't anticipate global variables being needed very much so those shouldn't be colliding. Was this the memory you were referring or did you mean more of a malloc/free issue between threads?

I'm gonna try to post fairly regularly throughout the project to get people's thoughts on things. I figure its good to keep my mind open to other ideas on this, otherwise I might write a large amount of code that didn't even need to exist.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Hi Monk_is_batman

I am very interested in this idea see my thread enquiring about dynamic loading ideas, all be it not from and operating systems POV I'm more anti operating systems on Xmos.. Thus I would be very interested in following how you get on with this project as it is a problem in much need of solution IMHO!

Obviously if I can help in anyway please just let me know.

regards
Al
User avatar
monk_is_batman
Active Member
Posts: 38
Joined: Wed Jun 09, 2010 3:20 am
Location: Maine, USA

Post by monk_is_batman »

Thanks for the quick responses on this so far. I really hope to keep this thread alive as I am very determined to be successful and have this be part of the project.

Currently I am working on a system to automatically disassemble files containing each file and determine its dependencies. I'm thinking I'll have some sort tree that will contain information about what functions must be loaded into memory at start of the module and where they need to be placed relative to each other. In this I'm hoping functions like printintln can be reused and loaded for all modules from the same location.

So my question is, can simply 1 printintln be used for all of my modules or does the binary change depending on your project when it is compiled?
User avatar
monk_is_batman
Active Member
Posts: 38
Joined: Wed Jun 09, 2010 3:20 am
Location: Maine, USA

Post by monk_is_batman »

Today I took a code module, in this case something that would launch 2 threads to loop back uart signals and one to respond to commands. I packaged this and put it into flash and loaded when requested by another program. Most of this went surprisingly smoothly, and I had an application that had no uart code load it from flash and start up the loop back. So far there are a couple restrictions that make things go smoother, like not using global variables, and not compiling XC code at a higher optimization level the O1.

Couple questions for everyone, has anyone ever encountered select statements that do not seem to read from channels when on too high an optimization level?

Has anyone ported over and released any code for talking to sd-cards? I think this could be very useful, but the limited space on my XC-1A flash limits this.
User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Nice work there!

I have an SD card working in my wav player project since thats where it reads the audio from. Should be easy to rip the SD card code out.