#include #include #include "scheduler.h" #define false 0 #define true 1 #define ITERSTEP 50000 // for screen debug, comment next line //#define scr_printf printf int _doKillThreads; void test_Run( void *pThreadArgs ); void other_test_Run( void *pThreadArgs ); int main(int argc, char *argv[]) { unsigned long iter = 90000000; unsigned int iter2 = ITERSTEP + 7000; _doKillThreads = false; init_scr(); Scheduler_Init(); // Start the two example threads Scheduler_BeginThread( test_Run, NULL ); Scheduler_BeginThread( other_test_Run, NULL ); Scheduler_Run(); scr_printf("> never gests here\n"); return 0; } void test_Run( void *pThreadArgs ) { unsigned int iter2 = ITERSTEP; while(_doKillThreads == false) { iter2--; if(iter2 == 0) { //printf(" > test_Run\n"); scr_printf("."); iter2 = ITERSTEP; } Scheduler_YieldThread(); } //scr_printf("#"); scr_printf(" end test_Run."); Scheduler_EndThread(); } void other_test_Run( void *pThreadArgs ) { //unsigned int iter2 = ITERSTEP/2 + 4000; unsigned int iter2 = 2000; int j = 0; int countDown = iter2 * 500; while(_doKillThreads == false) { iter2--; if(iter2 == 0) { //for(j=0; j<10; j++) { //printf(" * other_test_Run\n"); scr_printf("*"); } //iter2 = ITERSTEP/2 + 4000; iter2 = 2000; } Scheduler_YieldThread(); // killer condition if(--countDown < 0) _doKillThreads = true; } //scr_printf("&"); scr_printf(" end other_test_Run."); Scheduler_EndThread(); }