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 

Returning to the caller of sceKernelLoadExec ?

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



Joined: 07 Sep 2005
Posts: 37

PostPosted: Sun Sep 18, 2005 12:48 pm    Post subject: Returning to the caller of sceKernelLoadExec ? Reply with quote

Is there a way to do so ?
Back to top
View user's profile Send private message Visit poster's website
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Sun Sep 18, 2005 5:20 pm    Post subject: Reply with quote

sceKernelLoadExec reboots the PSP and loads up the executable you tell it to.

All other programs are thus no longer in memory...

You need to use sceKernelLoadModule and sceKernelStartModule. They work -very- well for this purpose, much faster too, however you have to worry about memory leaks and cleanup much more... and unfortunately you cant load elfs using this method... however you can compile your programs into prxs, and it'll work.
Back to top
View user's profile Send private message AIM Address MSN Messenger
AudioMonster



Joined: 07 Sep 2005
Posts: 37

PostPosted: Sun Sep 18, 2005 5:28 pm    Post subject: Reply with quote

Thanks a lot , this is exactly what i wanted to know.

I am doing a program that is relaunching itself with that function and i was afraid that it could just fill the memory more and more each time i recall it.

Do the prxs are dynamically loaded libraries like .dll or .so ?
Back to top
View user's profile Send private message Visit poster's website
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Sun Sep 18, 2005 5:33 pm    Post subject: Reply with quote

Yes, prxs are essentially dlls. Using sceKernelLoadExec you can load and reload and reload an application as many times as you want.

Also, if you overwrite the file through USB/WiFi while running it, it will work perfectly, as the file is opened, copied to RAM, and then closed.
Back to top
View user's profile Send private message AIM Address MSN Messenger
AudioMonster



Joined: 07 Sep 2005
Posts: 37

PostPosted: Sun Sep 18, 2005 5:40 pm    Post subject: Reply with quote

Correct me if i'm wrong, but i think that in the case of windows at least, the memory is freed when you Unload a .dll ( even if you did not free all the memory dynamically allocated in this dll ).

Is it the same when using sceKernelUnloadModule ?
Back to top
View user's profile Send private message Visit poster's website
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Sun Sep 18, 2005 5:48 pm    Post subject: Reply with quote

No, unfortunately it doesnt.

The way memory is allocated on the PSP is in memory partitions. Each of these partitions is created and doesnt seem to be tied to a thread or process or module.

When you create a memory partition (aka you call 'new' or 'malloc' which creates some large partition which your call is ACTUALLY allocated from) and dont free it, it just sits around taking up memory. When your application ends, this memory is freed as long as the 'destructor' gets called on your main function. Personally though, I dont like this approach and would rather have more control over it, but the sceKernelCreateFpl (creates a fixed length memory pool) functions havnt been put into the PSPSDK yet... Hopefully soon.

Unloading a module only removes the small memory partition that was created to store the actual module itself in memory. It doesnt even free the memory used to hold the threads (500KB per thread or so)!!! Even letting your threads just quit doesnt end them, you MUST call sceKernelExitThread or whatever its called. Its pretty craptastic. :) This is one of the reasons most games on PSP dont use multiple modules.
Back to top
View user's profile Send private message AIM Address MSN Messenger
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