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

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
NeoXeno
Posts: 10
Joined: Thu Oct 20, 2005 5:35 am

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

Post by NeoXeno »

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!
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

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
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

Code: Select all

/* 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
NeoXeno
Posts: 10
Joined: Thu Oct 20, 2005 5:35 am

Post by NeoXeno »

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.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

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 :)
NeoXeno
Posts: 10
Joined: Thu Oct 20, 2005 5:35 am

Post by NeoXeno »

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.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

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 :(
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

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
Chrighton
Posts: 58
Joined: Wed Jun 15, 2005 8:24 pm

Post by Chrighton »

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 ?!
Post Reply