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]

Synth virtual time tick patch


Hi Bart

Please can you have a look at this patch and see if its OK for inclusion. 

I've added the option to use the virtual itimer instead of the real
timer. When the virtual timer is used, the idle thread loops rather
than doing select. Normally you don't want this since it consumes
cycles on the host OS, but i found that gdb cannot single step. You
hit n for next and it runs until the next break point. My guess is
that the process receives a signal while halted. When it single steps
the signal handler is run which is messing up the single step. Using
the virtual timer means there is very little chance a signal is
pending when the process is single stepped so single steps works.

By default the new behavior is disabled.

   Andrew

Index: arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/ChangeLog,v
retrieving revision 1.7
diff -u -r1.7 ChangeLog
--- arch/current/ChangeLog	4 Aug 2002 23:18:58 -0000	1.7
+++ arch/current/ChangeLog	2 Sep 2002 08:08:17 -0000
@@ -1,3 +1,11 @@
+2002-09-02  Andrew Lunn  <andrew.lunn@ascom.ch>
+
+	* src/synth_intr.c: Allow the use of the virtual itimer ticks.
+	Idle thread doesn't use select when using the virtual timer.
+	* include/hal_io.h: Added the virtual timer signal.
+	* cdl/hal_synth.cdl: Selection of real or virtual itimer.
+	As whole these changes allow gdb to single step.
+
 2002-08-04  Bart Veer  <bartv@tymora.demon.co.uk>
 
 	* include/hal_io.h: added argv/argv/environ definitions
Index: arch/current/cdl/hal_synth.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/cdl/hal_synth.cdl,v
retrieving revision 1.3
diff -u -r1.3 hal_synth.cdl
--- arch/current/cdl/hal_synth.cdl	23 May 2002 23:05:25 -0000	1.3
+++ arch/current/cdl/hal_synth.cdl	2 Sep 2002 08:08:17 -0000
@@ -101,6 +101,23 @@
            calculated     10000
         }
     }
+
+    cdl_option CYGSEM_HAL_SYNTH_REAL_TIME {
+        display          "Use Linux real-time timer"
+        default_value    1
+        description      "
+            Using the real-time timer to drive the eCos RTC allows the
+            eCos idle loop to call select(2) and thus not put any load
+            on the host machine.
+            Deselecting this option means the virtual timer will be used
+            instead. This may prevent (to some degree) time skew in the
+            eCos kernel, especially if the host machine has a high
+            load. It also makes the debugger work better. With real time
+            a timer signal happens ever single step which causes the single 
+            step to fail. With virtual time this does not happen so 
+            single stepping works.
+   }
+
     cdl_option CYGBLD_LINKER_SCRIPT {
         display "Linker script"
         flavor data
Index: arch/current/include/hal_io.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/include/hal_io.h,v
retrieving revision 1.6
diff -u -r1.6 hal_io.h
--- arch/current/include/hal_io.h	4 Aug 2002 23:19:07 -0000	1.6
+++ arch/current/include/hal_io.h	2 Sep 2002 08:08:18 -0000
@@ -209,6 +209,7 @@
 #define CYG_HAL_SYS_SIGCONT             18
 #define CYG_HAL_SYS_SIGSTOP             19
 #define CYG_HAL_SYS_SIGTSTP             20
+#define CYG_HAL_SYS_SIGVTALRM           26
 #define CYG_HAL_SYS_SIGIO               29
 
 #define CYG_HAL_SYS_SA_NOCLDSTOP        0x00000001
Index: arch/current/src/synth_intr.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/src/synth_intr.c,v
retrieving revision 1.3
diff -u -r1.3 synth_intr.c
--- arch/current/src/synth_intr.c	23 May 2002 23:05:28 -0000	1.3
+++ arch/current/src/synth_intr.c	2 Sep 2002 08:08:18 -0000
@@ -129,6 +129,8 @@
 // and interrupts are disabled.
 static volatile cyg_bool_t  synth_sigio_pending         = false;
 static volatile cyg_bool_t  synth_sigalrm_pending       = false;
+static volatile cyg_bool_t  synth_sigvtalrm_pending     = false;
+
 
 // The current VSR, to be invoked by the signal handler. This allows
 // application code to install an alternative VSR, without that VSR
@@ -249,6 +251,10 @@
         synth_sigalrm_pending = false;
         synth_alrm_sighandler(CYG_HAL_SYS_SIGALRM);
     }
+    if (synth_sigvtalrm_pending) {
+        synth_sigvtalrm_pending = false;
+        synth_alrm_sighandler(CYG_HAL_SYS_SIGVTALRM);
+    }
     if (synth_sigio_pending) {
         synth_sigio_pending = false;
         synth_io_sighandler(CYG_HAL_SYS_SIGIO);
@@ -482,20 +488,33 @@
     timer.hal_it_interval.hal_tv_usec   = period;
     timer.hal_it_value.hal_tv_sec       = 0;
     timer.hal_it_value.hal_tv_usec      = period;
-    
+
+#ifdef CYGSEM_HAL_SYNTH_REAL_TIME
     if (0 != cyg_hal_sys_setitimer(CYG_HAL_SYS_ITIMER_REAL, &timer, (struct cyg_hal_sys_itimerval*) 0)) {
         CYG_FAIL("Failed to initialize the clock itimer");
     }
+#else
+    if (0 != cyg_hal_sys_setitimer(CYG_HAL_SYS_ITIMER_VIRTUAL, &timer, (struct cyg_hal_sys_itimerval*) 0)) {
+        CYG_FAIL("Failed to initialize the clock itimer");
+    }
+#endif
+
 }
 
 static void
 synth_alrm_sighandler(int sig)
 {
-    CYG_PRECONDITION((CYG_HAL_SYS_SIGALRM == sig), "Only SIGALRM should be handled here");
-    
+    CYG_PRECONDITION(((CYG_HAL_SYS_SIGALRM == sig) ||
+                      (CYG_HAL_SYS_SIGVTALRM == sig)) ,
+                     "Only SIGALRM or SIGVTALRM should be handled here");
+
     if (!hal_interrupts_enabled) {
+      if (sig == CYG_HAL_SYS_SIGALRM) {
         synth_sigalrm_pending = true;
-        return;
+      } else {
+        synth_sigvtalrm_pending = true;
+      }
+      return;
     }
 
     // Interrupts were enabled, but must be blocked before any further processing.
@@ -606,12 +625,14 @@
 hal_idle_thread_action(cyg_uint32 loop_count)
 {
 #ifndef CYGIMP_IDLE_THREAD_YIELD
-    cyg_hal_sys__newselect(0,
+#ifdef CYGSEM_HAL_SYNTH_REAL_TIME
+   cyg_hal_sys__newselect(0,
                            (struct cyg_hal_sys_fd_set*) 0,
                            (struct cyg_hal_sys_fd_set*) 0,
                            (struct cyg_hal_sys_fd_set*) 0,
                            (struct cyg_hal_sys_timeval*) 0);
 #endif
+#endif
     CYG_UNUSED_PARAM(cyg_uint32, loop_count);
 }
 // ----------------------------------------------------------------------------
@@ -635,6 +656,7 @@
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGPIPE);
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGCHLD);
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGALRM);
+    CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGVTALRM);
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGIO);
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGHUP);
     CYG_HAL_SYS_SIGDELSET(&blocked, CYG_HAL_SYS_SIGINT);
@@ -671,6 +693,10 @@
     if (0 != cyg_hal_sys_sigaction(CYG_HAL_SYS_SIGALRM, &action, (struct cyg_hal_sys_sigaction*) 0)) {
         CYG_FAIL("Failed to install signal handler for SIGALRM");
     }
+    if (0 != cyg_hal_sys_sigaction(CYG_HAL_SYS_SIGVTALRM, &action, (struct cyg_hal_sys_sigaction*) 0)) {
+        CYG_FAIL("Failed to install signal handler for SIGVTALRM");
+    }
+
     action.hal_handler  = &synth_io_sighandler;
     if (0 != cyg_hal_sys_sigaction(CYG_HAL_SYS_SIGIO, &action, (struct cyg_hal_sys_sigaction*) 0)) {
         CYG_FAIL("Failed to install signal handler for SIGIO");


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