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 

Can I open more than 9 files using fopen or sceIoOpen?

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



Joined: 20 Oct 2005
Posts: 10

PostPosted: Mon Mar 12, 2007 1:49 am    Post subject: Can I open more than 9 files using fopen or sceIoOpen? Reply with quote

Hi everyone,

This may sound strange to some of you, but I'm writing a game engine where I need to have about 20 to 30 files opened simultaneously for the entire duration of the program. This is for streaming purposes. However, when I try to open more than 9 files using either fopen or sceIoOpen, my PSP freezes. Is there a way I can up the maximum number of files I can open at once? Thanks!
Back to top
View user's profile Send private message
Saotome



Joined: 03 Apr 2004
Posts: 182

PostPosted: Mon Mar 12, 2007 3:09 am    Post subject: Reply with quote

Maybe a stack issue?
I had a similar problem with networking. Then after a while I noticed the stack of the networking thread was set to just 1kB :P (after setting it to 128kB I didn't have problems anymore).
If you don't use threads (I don't know what the default stack size of the main thread is), you could try to make a thread for loading and set it to some bigger size.
_________________
infj
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon Mar 12, 2007 4:01 am    Post subject: Reply with quote

Code:
/* Define the main thread's stack size (optional) */
/**
 * ELF:
 * Elf default stack size is (256KB)
 *
 * PRX:
 * PRX default stack size is (256KB)
 *   
 * Example Below: smaller stack for kernel
 *                thread for 1.0 psp (32KB)
 */
PSP_MAIN_THREAD_STACK_SIZE_KB(32);

_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
NeoXeno



Joined: 20 Oct 2005
Posts: 10

PostPosted: Mon Mar 12, 2007 5:03 am    Post subject: Reply with quote

Thanks guys.

I tried increasing the size of the stack for the kernel thread but it would still crash. To be sure, I even created a separate, simple program that only opens a specified number of files for reading but it would still crash after opening more than 9.

Maybe one of you can create something similar to see if it you get the same results? It could be that I'm doing something wrong.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Mon Mar 12, 2007 6:32 am    Post subject: Reply with quote

Well I wrote a quick app and it looks like there is a 16 file open limit (which once you take off some existing files) ends up at around 9 or so. When I run out of files it returns SCE_KERNEL_ERROR_MFILE but it shouldn't crash.

So you are screwed :)
Back to top
View user's profile Send private message
NeoXeno



Joined: 20 Oct 2005
Posts: 10

PostPosted: Mon Mar 12, 2007 9:42 am    Post subject: Reply with quote

Lol! Yeah TyRaNiD, I'm starting to think there is no work around to this and that I am screwed. I did not anticipate this when I started coding so I may have to rethink and redo some of the things I had going (which were working quite well up until now). I'll see if I can try a few things before I call it quits.

By the way, why was a limit even placed? Does having too many files open at once drain system resources or something?

Thanks everyone.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Mon Mar 12, 2007 3:56 pm    Post subject: Reply with quote

Yah it will probably be a resources thing, strangely though if I do my test on my hostfs stuff I can open around 56 files. Seems the MS driver is artifically limiting the number of files :(
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Mon Mar 12, 2007 5:12 pm    Post subject: Reply with quote

Not the first time the SCE engineers artificially crumbled the sce* API :)
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Chrighton



Joined: 15 Jun 2005
Posts: 58

PostPosted: Thu Apr 12, 2007 12:53 am    Post subject: Reply with quote

I think this limitation just kicked my ass. I have no problems running the app I ported through PSPLink/hostfs side of things (hooray for tyranid!) but from the memstick side of things, some showstoppers result: errno codes from 24 (too many open?) to 2 (not found? when trying to read, but the file(s) exist and are stat'able at this point - it's not a case issue either).

*9* files max ?!
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