This is the mail archive of the ecos-discuss@sourceware.org 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]

Re: Cortex-M3 failing certain kernel tests


Grant,

This is what I did for pmutex3.c which has the same problem. I did not
found the same problem in kmutex3.c... may be it was kind of fixed in
the cvs pulled version I'm using.

Nevertheless, this should be kind of generic, the conversion functions
come from posix private code in ecos, but they can be put as test
helper code using other than timespec for normal kernel tests.

I've used a macro that can be replaced with an expression of the
numerator and denominator time tick parameters, to use the
"simplified" code when the tick is set to 10ms, but I guess that
having conversion functions is better.

$ cvs diff -U5 packages/compat/posix/current/tests/pmutex3.c
Index: packages/compat/posix/current/tests/pmutex3.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/compat/posix/current/tests/pmutex3.c,v
retrieving revision 1.2
diff -U 5 -r1.2 pmutex3.c
--- packages/compat/posix/current/tests/pmutex3.c       29 Jan 2009
17:47:52 -0000     1.2
+++ packages/compat/posix/current/tests/pmutex3.c       30 Sep 2013
12:03:27 -0000
@@ -58,10 +58,14 @@
 #ifdef CYGPKG_ISOINFRA
 # include <sys/types.h>
 # include <pthread.h>
 # include <semaphore.h>
 # include <time.h>
+typedef cyg_uint64      cyg_tick_count;
+externC void cyg_ticks_to_timespec( cyg_tick_count ticks, struct
timespec *tp );
+externC cyg_tick_count cyg_timespec_to_ticks( const struct timespec *tp,
+                                              cyg_bool roundup);
 # include <unistd.h>
 #endif

 #if !defined(CYGPKG_POSIX_PTHREAD)
 #define NA_MSG "POSIX threads not enabled"
@@ -332,11 +336,15 @@
     // better, so that is what we will do.  Must be a busy-wait.
     then = cyg_current_time();
     do {
         now = cyg_current_time();
         // Wait longer than the delay in t3 waiting on go_flag
+#if     defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)
+    } while ( now < (then + cyg_timespec_to_ticks(&sleeptime, false)) );
+#else /*defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)*/
     } while ( now < (then + 3) );
+#endif/*defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)*/

 #ifdef _POSIX_THREAD_PRIO_INHERIT
     CYG_TEST_INFO( "Checking for mutex priority inheritance" );
     CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" );
     CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" );
@@ -418,12 +426,16 @@
     // Emulate resume behaviour
     sem_wait( &hold[id] );
     if( all_exit ) return 0;

     // one tick sleep time
+#if     defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)
     sleeptime.tv_nsec = 10000000;
     sleeptime.tv_sec = 0;
+#else /*defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)*/
+    cyg_ticks_to_timespec(1, &sleeptime);
+#endif/*defined(CYGOPT_POSIX_MUTEX3_10MS_DELAY)*/

     CYG_TEST_INIT();
     CYG_TEST_INFO( "Control Thread running" );

     // Go through the 27 possibilitied of resuming the extra threads

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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