1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 8<title>Interrupts and callbacks</title> 9</head> 10 11<body> 12 13<h1>Interrupts and Callback Functions</h1> 14 15<h2>Introduction</h2> 16<P> 17Revolution SDK provides asynchronous functions for which callback functions can be specified. Fundamentally, callback functions specified at asynchronous function invocation are called from interrupt handlers. Because interrupt handlers execute at a higher priority than threads, all thread execution will be suspended at this time. 18</P> 19 20<h2>Notes</h2> 21<P> 22Because callback functions are part of the interrupt processing system, they are run with interrupts prohibited by default. Consequently, callback function processing should not last so long that other important interrupts (such as audio interrupts) are blocked. 23</P> 24 25<P> 26Do not call functions that can put the current thread to sleep from within callback functions. Callback functions are not run as threads; thus, if a function is invoked that puts the current thread to sleep, it will not be the callback function that will sleep but the current thread. If there is no current thread at this time, the Revolution OS will be suspended. 27</P> 28 29<P> 30Interrupt handlers use the current thread's stack. If an interrupt occurs during the execution of a thread with a stack of insufficient size, memory corruption may occur due to the interrupt handler. 31</P> 32 33<h2>Functions that Can Put the Current Thread to Sleep</h2> 34<P> 35Notable functions that can put the current thread to sleep are listed below. Do not call these functions from within a callback function. 36<ul> 37<li>Synchronous functions that are counterparts to asynchronous I/O functions such as <CODE>DVDRead()</CODE> 38<li><CODE>GXSet*</CODE> and <CODE>GXLoad*</CODE> functions, which send output to <CODE>GXFifo</CODE> 39<li><CODE><a href="../../gx/Management/GXWaitDrawDone.html">GXWaitDrawDone()</a></CODE> and <CODE><a href="../../gx/Management/GXDrawDone.html">GXDrawDone()</a></CODE> 40<li><CODE><a href="../Thread/OSJoinThread.html">OSJoinThread()</a></CODE>, <CODE><a href="../Thread/OSSleepThread.html">OSSleepThread()</a></CODE>, and <CODE><a href="../Thread/OSSuspendThread.html">OSSuspendThread()</a></CODE>, which is for the current thread 41<li><CODE><a href="../Thread_Synchronization/OSLockMutex.html">OSLockMutex()</a></CODE> and <CODE><a href="../Thread_Synchronization/OSWaitCond.html">OSWaitCond()</a></CODE> 42<li>Message queue functions in <CODE>OS_MESSAGE_BLOCK</CODE> mode (<CODE><a href="../Thread_Synchronization/OSJamMessage.html">OSJamMessage()</a></CODE>), <CODE><a href="../Thread_Synchronization/OSSendMessage.html">OSSendMessage()</a></CODE>, and <CODE><a href="../Thread_Synchronization/OSReceiveMessage.html">OSReceiveMessage()</a></CODE>) 43<li><CODE><a href="../Thread_Synchronization/OSWaitSemaphore.html">OSWaitSemaphore()</a></CODE> 44<li><CODE><a href="../../vi/VIWaitForRetrace.html">VIWaitForRetrace()</a></CODE> 45<li><CODE><a href="../../wpad/WPADGetInfo.html">WPADGetInfo()</a></CODE> 46<li><CODE><a href="../../ax/Initialization/AXQuit.html">AXQuit()</a></CODE> 47</ul> 48<P> 49 50 51<h2>See Also</h2> 52<P> 53<a target="contents" href="../toc.html#Interrupt">Interrupts</a>, <a target="contents" href="../toc.html#Thread">Thread</a>, <a target="contents" href="../toc.html#Stack">Stack</a> 54</P> 55 56<H2>Revision History</H2> 57<P> 582007/09/25 Added a note on stack usage by interrupt handlers.<br>2007/09/25 Expanded links.<br>2007/08/28 Initial version.<br> 59</P> 60 61<hr><p>CONFIDENTIAL</p></body> 62</html> 63