int main() { sched_init(); mythread_start(thread_function1, NULL); mythread_start(thread_function2, NULL); mythread_start(thread_function3, NULL); timer_setup(sig_timer_handler, 25000); while(1) ; return 0; }
/* * Prototype OS that creates threads and semaphores. */ void os_primitive() { unsigned int i; tcb *thread_pointer; // Create the semaphores full = mysem_create(0); empty = mysem_create(BUFFER_SIZE); mutex = mysem_create(1); // Create the threads for (i = 0; i < NUM_THREADS; i++) { thread_pointer = mythread_create(i, 4096, mythread); // 4B * 4096 entries = 16KB mythread_start(thread_pointer); mythread_join(thread_pointer); } if ( start_alarm_succeed() ) printf ("Start the alarm successfully\n"); else printf ("Unable to start the alarm\n"); /* an endless while loop */ while (1) { printf ("This is the OS primitive for my exciting CSE351 course projects!\n"); /* delay printf for a while */ for (i = 0; i < 5*MAX; i++); } }