| View previous topic :: View next topic |
| Author |
Message |
AudioMonster
Joined: 07 Sep 2005 Posts: 37
|
Posted: Sun Sep 18, 2005 12:48 pm Post subject: Returning to the caller of sceKernelLoadExec ? |
|
|
| Is there a way to do so ? |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Sep 18, 2005 5:20 pm Post subject: |
|
|
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 |
|
 |
AudioMonster
Joined: 07 Sep 2005 Posts: 37
|
Posted: Sun Sep 18, 2005 5:28 pm Post subject: |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Sep 18, 2005 5:33 pm Post subject: |
|
|
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 |
|
 |
AudioMonster
Joined: 07 Sep 2005 Posts: 37
|
Posted: Sun Sep 18, 2005 5:40 pm Post subject: |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Sep 18, 2005 5:48 pm Post subject: |
|
|
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 |
|
 |
|