Hello,
i have created a fairly simple Microblaze-based system, just one core, opb-UART, BRAM, opb-timer and opb-intc. I wrote a small program using the xilkernel-OS which creates two threads printing a thread-specific number and the current clock_ticks. The code is given below. I expect the program to print each second a message of one thread, but that doesn't work.
When executing the program both threads seem to enter the code fragment locked by the mutex nearly at the same time as can be seen by the printed clock_ticks. The mutex is declared static and initialized in the static thread created by xilkernel_main and before creating the "Hello world"-threads.
void thread_func(int number) { while (1) { pthread_mutex_lock(&print_mutex); sleep(500); xil_printf("Ticks = %d. Thread %d says: Hello world!\r\n", xget_clock_ticks(), number); sleep(500); pthread_mutex_unlock(&print_mutex); } }
Output via UART: Ticks = 362. Thread 1 says: Hello world! Ticks = 365. Thread 2 says: Hello world! Ticks = 464. Thread 1 says: Hello world! Ticks = 468. Thread 2 says: Hello world!
Regards,
Andreas