public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* sort out synth HAL diagnostics locking
@ 2009-08-23 11:30 Bart Veer
  0 siblings, 0 replies; only message in thread
From: Bart Veer @ 2009-08-23 11:30 UTC (permalink / raw)
  To: ecos-patches

The synth HAL diagnostics were not as thread-safe as they are supposed
to be. They also involved an unnecessary system call.

Bart

2009-07-16  Bart Veer  <bartv@ecoscentric.com>

	* src/synth_diag.c: add locking to the HAL diag code. Remove an
	unnecessary fdatasync().

Index: arch/current/src/synth_diag.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/src/synth_diag.c,v
retrieving revision 1.6
diff -u -p -r1.6 synth_diag.c
--- arch/current/src/synth_diag.c	29 Jan 2009 17:49:43 -0000	1.6
+++ arch/current/src/synth_diag.c	23 Aug 2009 11:27:30 -0000
@@ -61,6 +61,7 @@
 #include <cyg/infra/cyg_type.h>
 #include <cyg/hal/hal_diag.h>
 #include <cyg/hal/hal_io.h>
+#include <cyg/hal/hal_intr.h>
 #include <cyg/infra/cyg_ass.h>
 
 //-----------------------------------------------------------------------------
@@ -102,10 +103,12 @@ void hal_diag_init( void )
 
 void hal_diag_write_char(char c)
 {
-    static int  diag_index = 0;
+    static int      diag_index = 0;
     static unsigned char diag_buffer[128];
-
+    int             ints_state;
+    
     CYG_ASSERT(diag_index < 128, "Diagnostic buffer overflow");
+    HAL_DISABLE_INTERRUPTS(ints_state);
     
     diag_buffer[diag_index++] = (unsigned char) c;
     if (('\n' == c) || (128 == diag_index)) {
@@ -129,9 +132,9 @@ void hal_diag_write_char(char c)
             }
             CYG_ASSERT(0 == diag_index, "All data should have been written out");
             diag_index = 0;
-            cyg_hal_sys_fdatasync(1);
         }
     }
+    HAL_RESTORE_INTERRUPTS(ints_state);
 }
 
 // Diagnostic input. It is not clear that this is actually useful,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-23 11:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-23 11:30 sort out synth HAL diagnostics locking Bart Veer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).