There is now a proof of concept in https://github.com/lb3361/gigatron-lcc/ ... ff/threads.
The C program ’threads_test.c’ spawns two threads, one that computes prime numbers, another one that draws a maze in the bottom of the screen. Then it goes in a loop that prints the elapsed time until the prime numbers thread terminates. This program creates and manages threads using a small library with prototypes in ’threads.h’ and implementation in ’threads.s’. To make this work, I had to make changes in both the dev7 rom and in the compiler. It was also necessary to use a mutex to print things because the glcc library is not reentrant at this point.
Code: Select all
int main(void)
{
gt_start(&th1, th1s, sizeof(th1s), run_primes, 0);
gt_start(&th2, th2s, sizeof(th1s), run_maze, 0);
run_elapsed(0);
safe_cputs(1, 9, LIGHTMAGENTA, "Finished!");
return 0;
}