Listing 7: (a) RTLinux cancel test; (b) RTLinux cancel output.

(a)
main()
   for (i = 0; i < NUM_THREADS; i++)
      pthread_create(&threads[i], NULL, test_thread, NULL);
Thread
   for (i = 0; i < NUM_THREADS; i++) {
      clock_gettime(CLOCK_REALTIME, &start);
      pthread_cancel(threads[i]);
      pthread_join(threads[i], NULL);
      clock_gettime(CLOCK_REALTIME, &end);
   }

(b)
Thread Cancellation:
10051.5 us