CS 0449 – pthreads Lab
Make a program with two threads. Note: Remember to compile your program with the
-pthread option.
In the first thread, make an infinite loop that does:
printf(“Hello from thread 1 - A\n”);
printf(“Hello from thread 1 - B\n”);
In the second thread, have an infinite loop that does:
printf(“Hello from thread 2 - A\n”);
printf(“Hello from thread 2 - B\n”);
Run the program, and eventually stop it with CTRL+C. The time between thread switches is called a quantum.
1.) Does the quantum seem long or short?
2.) What happens if you insert a pthread_yield() into each loop between the two printf calls?