]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/commitdiff
Update MessageQMulti test to support up to 55 threads
authorvwan@ti.com <vwan@ti.com>
Tue, 20 May 2014 22:06:14 +0000 (15:06 -0700)
committerRobert Tivy <rtivy@ti.com>
Tue, 20 May 2014 22:33:54 +0000 (15:33 -0700)
Signed-off-by: VW <vwan@ti.com>
linux/src/tests/MessageQMulti.c
packages/ti/ipc/tests/messageq_multi.c
qnx/src/tests/MessageQMulti/MessageQMulti.c
qnx/src/tests/MessageQMulti/MessageQMulti.use

index 0beb37cb89ec4f4d5f9fb8d659c9174443627ad9..3790cebca58ca494cde55fcc38c00c51b47c45d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2014, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,7 @@
 
 #define  NUM_LOOPS_DFLT   1000
 #define  NUM_THREADS_DFLT 10
-#define  MAX_NUM_THREADS  50
+#define  MAX_NUM_THREADS  55
 #define  ONE_PROCESS_ONLY (-1)
 
 /** ============================================================================
@@ -214,11 +214,19 @@ int main (int argc, char ** argv)
            break;
         default:
            printf("Usage: %s [<numThreads>] [<numLoops>] [<Process #]>\n",
-                   argv[0]);
-           printf("\tDefaults: numThreads: 10, numLoops: 100\n");
-           printf("\tMax Threads: 100\n");
+               argv[0]);
+           printf("\tDefaults: numThreads: %d, numLoops: %d\n",
+               NUM_THREADS_DFLT, NUM_LOOPS_DFLT);
+           printf("\tMax Threads: %d\n", MAX_NUM_THREADS);
            exit(0);
     }
+
+    if (numThreads > MAX_NUM_THREADS) {
+        printf("Error: Maximum number of threads supported is %d\n",
+            MAX_NUM_THREADS);
+        exit(EXIT_FAILURE);
+    }
+
     printf("Using numThreads: %d, numLoops: %d\n", numThreads, numLoops);
     if (procNum != ONE_PROCESS_ONLY) {
         printf("ProcNum: %d\n", procNum);
@@ -248,7 +256,7 @@ int main (int argc, char ** argv)
         ret = pthread_join(threads[i].thread_id, NULL);
         if (ret != 0) {
             printf("MessageQMulti: failed to join thread: %d, %s\n",
-                    i, strerror(ret));
+                    threads[i].thread_num, strerror(ret));
         }
         printf("MessageQMulti: Joined with thread %d\n",threads[i].thread_num);
     }
index ea2f2727fb557a18a781909ab71c2dac90fb2bea..17ab5fe374c7cb8e89a8de3c4245af8b0a2a9f1e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2014, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@
 
 #define SLAVE_MESSAGEQNAME "SLAVE"
 #define HOST_MESSAGEQNAME "HOST"
-#define NUMTHREADS 10
+#define NUMTHREADS 55
 #define NUMLOOPS 1000
 
 static int numTests = 0;
index 397376b9fb0dcb1215ebdab62800d9f90149151b..19ece589bc870bc6d1bdcb09d42e1ef97579acc8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2014, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,7 +62,7 @@
 
 #define  NUM_LOOPS_DFLT   1000
 #define  NUM_THREADS_DFLT 10
-#define  MAX_NUM_THREADS  50
+#define  MAX_NUM_THREADS  55
 #define  ONE_PROCESS_ONLY (-1)
 
 /** ============================================================================
@@ -215,11 +215,19 @@ int main (int argc, char ** argv)
            break;
         default:
            printf("Usage: %s [<numThreads>] [<numLoops>] [<Process #]>\n",
-                   argv[0]);
-           printf("\tDefaults: numThreads: 10, numLoops: 100\n");
-           printf("\tMax Threads: 100\n");
+               argv[0]);
+           printf("\tDefaults: numThreads: %d, numLoops: %d\n",
+               NUM_THREADS_DFLT, NUM_LOOPS_DFLT);
+           printf("\tMax Threads: %d\n", MAX_NUM_THREADS);
            exit(0);
     }
+
+    if (numThreads > MAX_NUM_THREADS) {
+        printf("Error: Maximum number of threads supported is %d\n",
+            MAX_NUM_THREADS);
+        exit(EXIT_FAILURE);
+    }
+
     printf("Using numThreads: %d, numLoops: %d\n", numThreads, numLoops);
     if (procNum != ONE_PROCESS_ONLY) {
         printf("ProcNum: %d\n", procNum);
@@ -248,11 +256,13 @@ int main (int argc, char ** argv)
     for (i = 0; i < numThreads; i++) {
         ret = pthread_join(threads[i].thread_id, &res);
         if (ret != 0) {
-            printf("MessageQMulti: failed to join thread: %d, %s\n",
-                    i, strerror(ret));
+            printf("MessageQMulti: failed to join thread #%d, %s\n",
+                    threads[i].thread_num, strerror(ret));
+        }
+        else {
+            printf("MessageQMulti: Joined with thread %d; "
+                "returned value was %p\n", threads[i].thread_num, res);
         }
-        printf("MessageQMulti: Joined with thread %d; returned value was %p\n",
-                threads[i].thread_num, res);
         free(res);      /* Free memory allocated by thread */
     }
 
index 6321b842165bfae7777bbea11f5b958836b25dd7..0caaeb2625e623297afb3f5a24a354eab273caa6 100644 (file)
@@ -3,5 +3,8 @@ MessageQMulti Test
 Syntax:
   MessageQMulti [<numThreads>] [<numLoops>] [<Process #>]
 
+        Defaults: numThreads: 10, numLoops: 1000
+        Max Threads: 55
+
 Examples:
   MessageQMulti 10 100        Create 10 threads and each thread sends 100 msgs concurrently to slave processor