Executing Programs - MultitaskingThe RIO can run up to 4 independent programs or threads simultaneously. They are numbered 0 thru3, where 0 is the main thread.The main thread differs from the others in the following ways:1. Only the main thread, thread 0, may use the input command, IN.2. When interrupts are implemented for command errors, the subroutines are executed in thread 0.However for the #ININTn subroutines, the RIO has the ability to execute multiple input interrupts(#ININTn) on designated threads, not limited to the main thread. For more information, refer to the IIcommand in the Command Reference.To begin execution of the various programs, use the following instruction:XQ #A,nWhere A represents the label and n indicates the thread number. To halt the execution of anythread, use the instructionHX nwhere n is the thread number.Note that both the XQ and HX commands can be performed from within an executing program.For example:Instruction Interpretation#TASK1 Task1 labelAT0 Initialize reference timeCB1 Clear Output 1#LOOP1 Loop1 labelAT 10 Wait 10 msec from reference timeSB1 Set Output 1AT -40 Wait 40 msec from reference time, then initialize referenceCB1 Clear Output 1JP #LOOP1 Repeat Loop1#TASK2 Task2 labelXQ #TASK1,1 Execute Task1#LOOP2 Loop2 labelWT20000 Wait for 20 secondsHX1 Stop thread 1MG”DONE” Print MessageEN End of ProgramThe program above is executed with the instruction XQ #TASK2,0 which designates TASK2 as the mainthread (i.e. Thread 0). #TASK1 is executed within TASK2.Debugging ProgramsThe RIO provides commands and operands that are useful in debugging application programs. Thesecommands include interrogation commands to monitor program execution, determine the state ofChapter 5 Programming ▫ 58 RIO-47xxx Rev. 1.0r