/* this is a simple hello world program */ #include #include /* now declare (and allocate space for) some kernel objects, like the two threads we will use */ cyg_thread thread_s[3]; /* space for two thread objects */ char stack[3][4096]; /* space for two 4K stacks */ /* now the handles for the threads */ cyg_handle_t simple_threadA, simple_threadB, simple_threadC; /* and now variables for the procedure which is the thread */ cyg_thread_entry_t simple_program; /* and now a mutex to protect calls to the C library */ cyg_mutex_t cliblock; void cyg_user_start(void) { cyg_mutex_init(&cliblock); cyg_thread_create(4, simple_program, (cyg_addrword_t) 0, "Thread A", (void *) stack[0], 4096, &simple_threadA, &thread_s[0]); cyg_thread_create(4, simple_program, (cyg_addrword_t) 1, "Thread B", (void *) stack[1], 4096, &simple_threadB, &thread_s[1]); cyg_thread_create(4, simple_program, (cyg_addrword_t) 2, "Thread C", (void *) stack[2], 4096, &simple_threadC, &thread_s[2]); cyg_thread_resume(simple_threadB); cyg_thread_resume(simple_threadC); cyg_thread_resume(simple_threadA); displayString("\r\nCalling Scheduler.... \r\n"); } extern cyg_uint32 tick_count; void simple_program(cyg_addrword_t data) { int message = (int) data; int delay; //cyg_thread_delay(10); while(1) { cyg_mutex_lock(&cliblock); //cyg_scheduler_lock(); diag_printf("Beginning execution; thread data is %d\r\n", data ); cyg_mutex_unlock(&cliblock); //cyg_scheduler_unlock(); //CYGACC_CALL_IF_DELAY_US(1000); cyg_thread_delay(100); //cyg_thread_yield(); } }