forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSP_THREAD_ATTR_VFPU and multiple threads

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
gauri



Joined: 20 Jan 2008
Posts: 35
Location: Belarus

PostPosted: Mon Mar 10, 2008 8:11 am    Post subject: PSP_THREAD_ATTR_VFPU and multiple threads Reply with quote

I've bumped into unexpected problems with multiple threads having PSP_THREAD_ATTR_VFPU attribute set.

Let me describe the setting... I have main thread and, say, 8 workers. All of them have the attribute set (potentially). In the main thread i do rendering stuff, worker threads are created for sound processing (one per channel).

So, if I have the attribute set for all threads, the code breaks, having sudden hangings of main thread, or screen messed up (looks like buffer pointers go wrong somewhere inside). I can still terminate my program with "Home" killer, though. If I remove the attribute flag from worker threads, everything goes smoothly and without any problems.

Is there possibly a limit for having threads with PSP_THREAD_ATTR_VFPU attribute set? Some kind of buffer overrun happens? I so not see any other reason this could be happening since all the threads do nothing except yielding the control to each other.
_________________
Freelance game industry veteran. 8]
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Mar 10, 2008 2:29 pm    Post subject: Reply with quote

Such a thread needs a MUCH larger context, which I would guess is pulled from the stack. The stack has a default size that may be overflowing after X number of threads set to use the VFPU. You might try increasing the size of the stack to see if that fixes the problem. The macro that goes in the main file is

Code:
PSP_MAIN_THREAD_STACK_SIZE_KB(256);


where 256 would be changed to whatever stack (in KB) you want. Try different sizes and see what happens.
Back to top
View user's profile Send private message AIM Address
gauri



Joined: 20 Jan 2008
Posts: 35
Location: Belarus

PostPosted: Mon Mar 10, 2008 5:16 pm    Post subject: Reply with quote

Unfortunately, it still fails. The screen is still flickering. :-(
_________________
Freelance game industry veteran. 8]
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Mar 11, 2008 3:50 am    Post subject: Reply with quote

What size are you setting the heap to? I've seen programs that set the heap manually, and setting it wrong prevented threads from being created. SNES9xTYL is that way.
Back to top
View user's profile Send private message AIM Address
gauri



Joined: 20 Jan 2008
Posts: 35
Location: Belarus

PostPosted: Tue Mar 11, 2008 4:13 am    Post subject: Reply with quote

I use default settings for the heap, e.g. I set nothing. :-)
Thread creation does not fail, the threads seem to work.
_________________
Freelance game industry veteran. 8]
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Mar 11, 2008 9:42 am    Post subject: Reply with quote

Well, unless someone has run into this before, all we can do is just keep making suggestions. :) If it isn't a secret or something you want to keep closed, you could post the code you're doing this with. Maybe it's something else that's making it crash that is only peripherally related to the VFPU.

My next guess is maybe you could try increasing the size of the stack of the created threads. Maybe the threads are created with a stack too small to handle VFPU. The stack size for the created thread is the fourth arg passed in the function to create the threads.
Back to top
View user's profile Send private message AIM Address
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Tue Mar 11, 2008 10:05 am    Post subject: Reply with quote

I've had similar effects once before.

I put it down to the fact that the kernel saves and restores the VFPU registers when switching threads.

It's also probably why the VFPU param is optional when you create a thread.

Best bet is to limit VFPU capable threads to as few as possible.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group