I'm running a thread to get the status of a controller. Inside the thread, if I hit UP it will decrease the thread's priority, and DOWN will increase it.
After I call the thread, my main goes into a busy waiting look and prints some stuff to the screen to identify that it is currently running. My controller thread also prints to identify itself.
My problem is, when I run the thread, my main() loop never identifies itself, so it is never running, when i set the priorities to be the same, it still never runs. I would assume that I would get a mix of main() and my thread messages on the screen. When I set the priority lower, my main() message takes over and I never see the thread message again().
It seems like the threads with higher priority starve on the queue. Does anybody know how I'd get these two to run concurrently?
Can someone tell me what RotateThreadReadyQueue() does? I tried to use that will all kinda parameters, it doesn't do anything.
See
Code: Select all
void PollController() //The threaded Function
{
int i = 50;
while (1)
{
controllerReturn = padRead(0, 0, &buttons);
if (controllerReturn != 0)
{
paddata = 0xffff ^ ((buttons.btns[0] << 8) | buttons.btns[1]);
new_pad = paddata & ~old_pad;
old_pad = paddata;
}
if(new_pad & PAD_DOWN)
{
i-=1; if (i<0) i = 0;
}
if(new_pad & PAD_UP)
{
i+=1; if (i>255) i = 255;
}
scr_printf("Read Controller %d Priority %d\n", controllerReturn, i);
ChangeThreadPriority(GetThreadId(), i);
}
}
Code: Select all
while (1)
{
scr_printf("MAIN: This is the main function\n");
}
Ryan