|
@@ -98,7 +98,7 @@ void texasr(void *in)
|
|
|
|
|
|
int test_tmspr()
|
|
|
{
|
|
|
- pthread_t thread;
|
|
|
+ pthread_t *thread;
|
|
|
int thread_num;
|
|
|
unsigned long i;
|
|
|
|
|
@@ -107,21 +107,28 @@ int test_tmspr()
|
|
|
/* To cause some context switching */
|
|
|
thread_num = 10 * sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
|
|
+ thread = malloc(thread_num * sizeof(pthread_t));
|
|
|
+ if (thread == NULL)
|
|
|
+ return EXIT_FAILURE;
|
|
|
+
|
|
|
/* Test TFIAR and TFHAR */
|
|
|
- for (i = 0 ; i < thread_num ; i += 2){
|
|
|
- if (pthread_create(&thread, NULL, (void*)tfiar_tfhar, (void *)i))
|
|
|
+ for (i = 0; i < thread_num; i += 2) {
|
|
|
+ if (pthread_create(&thread[i], NULL, (void *)tfiar_tfhar,
|
|
|
+ (void *)i))
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
- if (pthread_join(thread, NULL) != 0)
|
|
|
- return EXIT_FAILURE;
|
|
|
-
|
|
|
/* Test TEXASR */
|
|
|
- for (i = 0 ; i < thread_num ; i++){
|
|
|
- if (pthread_create(&thread, NULL, (void*)texasr, (void *)i))
|
|
|
+ for (i = 1; i < thread_num; i += 2) {
|
|
|
+ if (pthread_create(&thread[i], NULL, (void *)texasr, (void *)i))
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
- if (pthread_join(thread, NULL) != 0)
|
|
|
- return EXIT_FAILURE;
|
|
|
+
|
|
|
+ for (i = 0; i < thread_num; i++) {
|
|
|
+ if (pthread_join(thread[i], NULL) != 0)
|
|
|
+ return EXIT_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ free(thread);
|
|
|
|
|
|
if (passed)
|
|
|
return 0;
|