OS_WaitAnyIrq

Syntax

#include <nitro/os.h>

void OS_WaitAnyIrq( void );

Arguments

None.

Return Values

None.

Description

This function waits for any IRQ interrupt.

It waits for IRQ interrupts to be generated, regardless of type. It does not look for interrupt check flags and therefore returns when an interrupt is actually generated.



Example of Multiple Threads Waiting for an Interrupt

To illustrate the use of the OS_WaitIrq function, consider the case of multiple threads waiting for the same interrupt event. By replacing the OS_WaitIrq function in that example with OS_WaitAnyIrq, thread 1 and thread 2 will be run once per each interrupt (in the example, they will be run per each V-Blank).(If the code is left as OS_WaitIrq, only thread 1 was run.)

Below is the program that's been changed to OS_WaitAnyIrq.

void TwlMain(void)
{
:
OS_CreateThread( &thread1, proc1, ..., 10 );
OS_CreateThread( &thread2, proc2, ..., 11 );
:
}

//---- Thread1
void proc1(void* arg)
{
while(1)
{
OS_WaitAnyIrq();
OS_Printf("proc1\n");
}
}

//---- Thread2
void proc2(void* arg)
{
while(1)
{
OS_WaitAnyIrq();
OS_Printf("proc2\n");
}
}

//---- V-Blank interrupt handler
void VBlankHandler( void )
{
OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

Thread 1 and thread 2 wait for some kind of interrupt. At this time the two threads are registered in the IRQ thread queue. Once the V-Blank occurs and control exits the handler, the threads registered in the IRQ thread queue will enter the runnable state. This mechanism is unrelated to the interrupt check flag. When some sort of interrupt occurs, the threads that were stopped with OS_WaitAnyIrq will be run. This program will continually display proc1 and proc2 alternately.

See Also

OS_WaitIrq

Revision History

2008/07/01 Gave an example of multiple threads waiting for an interrupt.
2005/03/08 Standardized how the term "Interrupt" is written in Japanese.
2004/05/01 Initial value.


CONFIDENTIAL