This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

tm_basic - test 'flag' synchronizers


Index: kernel/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.83
diff -u -5 -p -r1.83 ChangeLog
--- kernel/current/ChangeLog	28 Oct 2002 16:34:21 -0000	1.83
+++ kernel/current/ChangeLog	3 Dec 2002 14:24:51 -0000
@@ -1,5 +1,9 @@
+2002-12-03  Gary Thomas  <gthomas@ecoscentric.com>
+
+	* tests/tm_basic.cxx: Add tests of 'flag' synchronizers.
+
 2002-10-28  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/tm_basic.cxx: Include infra/diag.h and removed the 
 	incorrect prototype for diag_printf
 
Index: kernel/current/tests/tm_basic.cxx
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/kernel/current/tests/tm_basic.cxx,v
retrieving revision 1.18
diff -u -5 -p -r1.18 tm_basic.cxx
--- kernel/current/tests/tm_basic.cxx	28 Oct 2002 16:34:22 -0000	1.18
+++ kernel/current/tests/tm_basic.cxx	29 Nov 2002 14:52:50 -0000
@@ -7,10 +7,11 @@
 //==========================================================================
 //####ECOSGPLCOPYRIGHTBEGIN####
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
 //
 // eCos is free software; you can redistribute it and/or modify it under
 // the terms of the GNU General Public License as published by the Free
 // Software Foundation; either version 2 or (at your option) any later version.
 //
@@ -52,10 +53,11 @@
 #include <cyg/kernel/sched.hxx>
 #include <cyg/kernel/thread.hxx>
 #include <cyg/kernel/thread.inl>
 #include <cyg/kernel/mutex.hxx>
 #include <cyg/kernel/sema.hxx>
+#include <cyg/kernel/flag.hxx>
 #include <cyg/kernel/sched.inl>
 #include <cyg/kernel/clock.hxx>
 #include <cyg/kernel/clock.inl>
 #include <cyg/kernel/kapi.h>
 
@@ -95,18 +97,21 @@ typedef struct fun_times {
 #define NMBOXES              ((CYGMEM_REGION_ram_SIZE/24)/CYG_MBOX_OVERHEAD)
 #define CYG_SEMAPHORE_OVERHEAD (sizeof(cyg_sem_t)+sizeof(fun_times))
 #define NSEMAPHORES          ((CYGMEM_REGION_ram_SIZE/16)/CYG_SEMAPHORE_OVERHEAD)
 #define CYG_COUNTER_OVERHEAD (sizeof(cyg_counter)+sizeof(fun_times))
 #define NCOUNTERS            ((CYGMEM_REGION_ram_SIZE/24)/CYG_COUNTER_OVERHEAD)
+#define CYG_FLAG_OVERHEAD    (sizeof(cyg_flag_t)+sizeof(fun_times))
+#define NFLAGS               ((CYGMEM_REGION_ram_SIZE/24)/CYG_FLAG_OVERHEAD)
 #define CYG_ALARM_OVERHEAD   (sizeof(cyg_alarm)+sizeof(fun_times))
 #define NALARMS              ((CYGMEM_REGION_ram_SIZE/16)/CYG_ALARM_OVERHEAD)
 #else
 // Defaults
 #define NTEST_THREADS    16
 #define NMUTEXES         32
 #define NMBOXES          32
 #define NSEMAPHORES      32
+#define NFLAGS           32
 #define NCOUNTERS        32
 #define NALARMS          32
 #endif
 
 #define NSAMPLES         32
@@ -118,20 +123,22 @@ typedef struct fun_times {
 #define NTHREAD_SWITCHES_SIM 4
 #define NMUTEXES_SIM         2
 #define NMBOXES_SIM          2
 #define NSEMAPHORES_SIM      2
 #define NSCHEDS_SIM          4
+#define NFLAGS_SIM           2
 #define NCOUNTERS_SIM        2
 #define NALARMS_SIM          2
 
 static int nsamples;
 static int ntest_threads;
 static int nthread_switches;
 static int nmutexes;
 static int nmboxes;
 static int nsemaphores;
 static int nscheds;
+static int nflags;
 static int ncounters;
 static int nalarms;
 
 static char stacks[NTEST_THREADS][STACK_SIZE];
 static cyg_thread test_threads[NTEST_THREADS];
@@ -164,10 +171,13 @@ static fun_times sched_ft[NSCHEDS];
 
 static cyg_counter test_counters[NCOUNTERS];
 static cyg_handle_t counters[NCOUNTERS];
 static fun_times counter_ft[NCOUNTERS];
 
+static cyg_flag_t test_flags[NFLAGS];
+static fun_times flag_ft[NFLAGS];
+
 static cyg_alarm test_alarms[NALARMS];
 static cyg_handle_t alarms[NALARMS];
 static fun_times alarm_ft[NALARMS];
 
 static long rtc_resolution[] = CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION;
@@ -194,10 +204,11 @@ void run_mutex_circuit_test(void);
 void run_mbox_tests(void);
 void run_mbox_circuit_test(void);
 void run_semaphore_tests(void);
 void run_semaphore_circuit_test(void);
 void run_counter_tests(void);
+void run_flag_tests(void);
 void run_alarm_tests(void);
 
 #ifndef max
 #define max(n,m) (m > n ? n : m)
 #endif
@@ -385,10 +396,11 @@ show_test_parameters(void)
     diag_printf("   Mutexes:               %5d\n", nmutexes);
     diag_printf("   Mailboxes:             %5d\n", nmboxes);
     diag_printf("   Semaphores:            %5d\n", nsemaphores);
     diag_printf("   Scheduler operations:  %5d\n", nscheds);
     diag_printf("   Counters:              %5d\n", ncounters);
+    diag_printf("   Flags:                 %5d\n", nflags);
     diag_printf("   Alarms:                %5d\n", nalarms);
     diag_printf("\n"); 
     enable_clock_latency_measurement();
 }
 
@@ -1143,10 +1155,105 @@ run_counter_tests(void)
     }
     show_times(counter_ft, ncounters, "Delete counter");
     end_of_test_group();
 }
 
+void
+run_flag_tests(void)
+{
+    int i;
+    cyg_flag_value_t val;
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_init(&test_flags[i]);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Init flag");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_destroy(&test_flags[i]);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Destroy flag");
+
+    // Recreate the flags - reused in the remaining tests
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_init(&test_flags[i]);
+    }
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_maskbits(&test_flags[i], 0);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Mask bits in flag");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Set bits in flag [no waiters]");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_AND);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Wait for flag [AND]");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_OR);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Wait for flag [OR]");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_AND|CYG_FLAG_WAITMODE_CLR);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Wait for flag [AND/CLR]");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_OR|CYG_FLAG_WAITMODE_CLR);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Wait for flag [OR/CLR]");
+
+    wait_for_tick(); // Wait until the next clock tick to minimize aberations
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_setbits(&test_flags[i], 0x11);
+        HAL_CLOCK_READ(&flag_ft[i].start);
+        val = cyg_flag_peek(&test_flags[i]);
+        HAL_CLOCK_READ(&flag_ft[i].end);
+    }
+    show_times(flag_ft, nflags, "Peek on flag");
+
+    // Destroy flags - no longer needed
+    for (i = 0;  i < nflags;  i++) {
+        cyg_flag_destroy(&test_flags[i]);
+    }
+    end_of_test_group();
+}
+
 // Alarm callback function
 void
 alarm_cb(cyg_handle_t alarm, cyg_addrword_t val)
 {
     // empty call back
@@ -1606,10 +1713,11 @@ run_all_tests(CYG_ADDRESS id)
     run_sched_tests();
     run_mutex_tests();
     run_mbox_tests();
     run_semaphore_tests();
     run_counter_tests();
+    run_flag_tests();
     run_alarm_tests();
 
 #ifdef CYG_SCHEDULER_LOCK_TIMINGS
     Cyg_Scheduler::get_lock_times(&lock_ave, &lock_max);
     diag_printf("\nMax lock:");
@@ -1686,20 +1794,22 @@ void tm_basic_main( void )
         nthread_switches = NTHREAD_SWITCHES_SIM;
         nmutexes = NMUTEXES_SIM;
         nmboxes = NMBOXES_SIM;
         nsemaphores = NSEMAPHORES_SIM;
         nscheds = NSCHEDS_SIM;
+        nflags = NFLAGS_SIM;
         ncounters = NCOUNTERS_SIM;
         nalarms = NALARMS_SIM;  
     } else {
         nsamples = NSAMPLES;
         ntest_threads = NTEST_THREADS;
         nthread_switches = NTHREAD_SWITCHES;
         nmutexes = NMUTEXES; 
         nmboxes = NMBOXES;
         nsemaphores = NSEMAPHORES;
         nscheds = NSCHEDS;
+        nflags = NFLAGS;
         ncounters = NCOUNTERS;
         nalarms = NALARMS;
     }
 
     // Sanity
@@ -1714,10 +1824,11 @@ void tm_basic_main( void )
     ntest_threads = max(64, ntest_threads);
     nmutexes = max(32, nmutexes);
     nsemaphores = max(32, nsemaphores);
     nmboxes = max(32, nmboxes);
     ncounters = max(32, ncounters);
+    nflags = max(32, nflags);
     nalarms = max(32, nalarms);
 #endif
 
     new_thread(run_all_tests, 0);
     


-- 
------------------------------------------------------------
Gary Thomas                  |
eCosCentric, Ltd.            |  
+1 (970) 229-1963            |  eCos & RedBoot experts
gthomas@ecoscentric.com      |
http://www.ecoscentric.com/  |
------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]