Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Example - yield so another thread can execute

The c_samplethread_thread1() function is called when thread 1 is started. This function loops, incrementing a timer until the maximum value is reached.

Each time through the while loop, the counter is incremented and the display is updated, then ISHELL_Resume() is called to register a callback for the thread making the call (thread 1 in this example), which will allow the thread to be resumed later. c_samplethread_thread1() then calls ITHREAD_Suspend() to suspend itself, allowing other threads to be executed.

Threads 2 and 3 have similar calls to ISHELL_Resume() and ITHREAD_Suspend() so that all three threads are executed.

   // Register a callback that will be used to resume this thread
   ISHELL_Resume( pMe->piShell, ITHREAD_GetResumeCBK(pMe->piThread1));

   //suspend thread 1 itself
   ITHREAD_Suspend(pMe->piThread1);