Kernel mode vs. user mode

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
uberjack
Posts: 34
Joined: Tue Jul 17, 2007 9:09 am
Location: California, USA
Contact:

Kernel mode vs. user mode

Post by uberjack »

Hello everyone,

I've recently tried to add wifi support to one of my apps, which (in case of fw 1.50) involves starting up my app in kernel mode (the application was originally a user-mode application), then spawning off a user-mode thread to do the usual stuff (setting up callbacks, initting sound, etc...).
It seems like everything works fine, except my sound thread no longer works as usual. Sound is distorted and seems to skip, which I cannot explain.

The main user-mode thread is started as follows:

sceKernelCreateThread("User Mode Thread", user_main,
0x11, // default priority
256 * 1024, // stack size (256KB is regular default)
PSP_THREAD_ATTR_USER, NULL);

Here's how my app starts the sound thread:

sceKernelCreateThread(label, (void*)&AudioChannelThread, 0x12, 0x10000,
0, NULL);

My (older) user-mode init:
/* User mode */
PSP_MODULE_INFO(PSP_APP_NAME, 0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);

New kernel-mode init:
/* Kernel mode */
PSP_MODULE_INFO(PSP_APP_NAME, 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);

Am I doing something wrong? My understanding is that the sound thread should still run exactly as before, seeing as how the stack size, priority and attributes are still the same.

Appreciate any help
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Create your audio thread in user mode using PSP_THREAD_ATTR_USER.

Also, change the priority of your main user thread so it is lower than the sound thread (ie. higher value).
Post Reply