#168880 - BlazerRazor - Mon Jun 01, 2009 4:22 pm
Hello fellow coders,
Do any of you know if it is possible to use POSIX threads on the Nintendo DS with devkitARM?
I've been looking around in the devkitARM directory and I can find a header, pthread.h, and it seems to be implemented.
The problem I am experiencing is that when I try compiling my code I get a "error: 'pthread_t' undeclared (first use in this function)" when declaring the usual pthread_t. I have included the pthread.h but I does not work.
Any suggestions or solutions would be greatly appreciated!
#168881 - wintermute - Mon Jun 01, 2009 4:57 pm
#168887 - samel - Mon Jun 01, 2009 5:55 pm
Here you can find thread for the DS.
http://donotjava.netsons.org/?page_id=67
Feel free to ask, test and use 8)
#168894 - BlazerRazor - Mon Jun 01, 2009 8:45 pm
Thanks for the replies, really appreciate it!
Wow, very cool and nice! Thanks!
You have any example? Just a simple thread test using the library.
#168897 - wintermute - Mon Jun 01, 2009 10:08 pm
Please do not use this, the toolchain does not support threading. Bad things will happen.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#168898 - samel - Mon Jun 01, 2009 10:18 pm
@wintermute
Can you explain why? I've used it with r21 and it work well. May be with newer version you have to modify something, but I don't think "Bad things will happen".
@BlazerRazor
There is an example in the zip file, take a look at main9.c
#168900 - wintermute - Mon Jun 01, 2009 10:42 pm
Without threading support in the toolchain any attempt to use threads on the DS will fail at some point. Many libc functions are not re-entrant which will cause all sorts of interesting issues.
Primarily, stdio will cause stupendous crashes with threads.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#168901 - samel - Mon Jun 01, 2009 10:58 pm
wintermute wrote: |
Without threading support in the toolchain any attempt to use threads on the DS will fail at some point.
|
So you never use interrupt on the DS? That's basicaly the same idea as thread .... you can use thread on the DS as long as you write the appropiate code.
Well, not posix thread, but something like that.
wintermute wrote: |
Many libc functions are not re-entrant which will cause all sorts of interesting issues.
Primarily, stdio will cause stupendous crashes with threads. |
As I said before:
samel wrote: |
May be with newer version you have to modify something, but I don't think "Bad things will happen".
|
#168902 - wintermute - Mon Jun 01, 2009 11:09 pm
Interrupts and threads are two entirely different things.
Threads on the DS are inappropriate due to lack of toolchain support and the impact on execution speed due to the need to place the stack in slow RAM.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#168903 - samel - Mon Jun 01, 2009 11:21 pm
wintermute wrote: |
Interrupts and threads are two entirely different things.
Threads on the DS are inappropriate due to lack of toolchain support and the impact on execution speed due to the need to place the stack in slow RAM. |
You're right, but that's a dirty replacement 8)
#168905 - BlazerRazor - Mon Jun 01, 2009 11:37 pm
Thanks for the talk guys :D
I have decided not to use any threads, but the reason I ask for threads was because I am currently working on a client-server remote mouse and keyboard control application and I need to send both UDP and TCP packages at the same time. I guess I'll drop that idea and find another appropriate way of doing this.
#168906 - samel - Mon Jun 01, 2009 11:50 pm
BlazerRazor wrote: |
Thanks for the talk guys :D
I have decided not to use any threads, but the reason I ask for threads was because I am currently working on a client-server remote mouse and keyboard control application and I need to send both UDP and TCP packages at the same time. I guess I'll drop that idea and find another appropriate way of doing this. |
Ok, you made the right choose. 8)))))))
That's not a good idea to use ThreaDS for network comunication.
#168907 - Pete_Lockwood - Tue Jun 02, 2009 1:08 am
BlazerRazor wrote: |
I need to send both UDP and TCP packages at the same time. I guess I'll drop that idea and find another appropriate way of doing this. |
Nothing stops you doing this without threads. Use non-blocking sockets and calls to select().
_________________
It's not an illusion, it just looks like one.
#168908 - Dwedit - Tue Jun 02, 2009 1:26 am
How about some kind of simple round robin thread system that uses an IRQ or Yield call to switch to another thread?
Just need to support threads yielding to wait for IRQ or something like that.
All you really need for a context switch is to move the PC and stack around, and set a number or something to indicate which thread you are currently running. For example, if you know you can get by with a 1K stack, use that.
Just don't call any LIBC functions from both threads, not even malloc.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#168910 - elwing - Tue Jun 02, 2009 6:50 am
what about http://www.sics.se/~adam/pt/ ?
it's not thread as you generally use the term, but it should simplify a game engine coding, no?