// Program thread_test.c // Author W. B. Ligon // // This program is a very basic test of the functionality for the thread // package designed for ECE329 #include "threads.h" int task1(); int task2(); int task3(); int task4(); main(int argc, char **argv) { // initialize the thread package if (thread_init() < 0) printf("error initializing threads\n"); // create four threads if (thread_create(task1, 1) < 0) printf("error starting thread 1\n"); if (thread_create(task2, 2) < 0) printf("error starting thread 2\n"); if (thread_create(task3, 3) < 0) printf("error starting thread 3\n"); if (thread_create(task4, 4) < 0) printf("error starting thread 4\n"); // infinite loop - need to ctrl-C this to stop it while (1) { printf("MAIN THREAD\n"); } // this will never be called but is here for completeness thread_exit(); } int task1() { // infinite loop - need to ctrl-C this to stop it while (1) { printf("THREAD 1\n"); } // this will never be called but is here for completeness thread_exit(); } int task2() { // infinite loop - need to ctrl-C this to stop it while (1) { printf("THREAD 2\n"); } // this will never be called but is here for completeness thread_exit(); } int task3() { // infinite loop - need to ctrl-C this to stop it while (1) { printf("THREAD 3\n"); } // this will never be called but is here for completeness thread_exit(); } int task4() { // infinite loop - need to ctrl-C this to stop it while (1) { printf("THREAD 4\n"); } // this will never be called but is here for completeness thread_exit(); }