• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision14339 (tree)
Time2021-05-04 23:51:23
Authorgdisirio

Log Message

Test code, some tentative optimizations.

Change Summary

Incremental Difference

--- trunk/os/rt/src/chvt.c (revision 14338)
+++ trunk/os/rt/src/chvt.c (revision 14339)
@@ -112,6 +112,8 @@
112112 sysinterval_t deltanow) {
113113 delta_list_t *dlp = vtlp->dlist.next;
114114
115+ vtlp->lasttime = chTimeAddX(vtlp->lasttime, deltanow);
116+
115117 /* The loop is bounded because the delta list header has the delta field
116118 set to (sysinterval_t)-1 which is larger than all deltas.*/
117119 while (dlp->delta < deltanow) {
@@ -120,10 +122,11 @@
120122 dlp = dlp->next;
121123 }
122124
123- vtlp->lasttime = vtlp->lasttime + deltanow;
124-
125125 /* Adjusting next timer in the list, if any.*/
126126 if (is_timer(&vtlp->dlist, dlp)) {
127+
128+ chDbgAssert(deltanow <= dlp->delta, "invalid delta");
129+
127130 dlp->delta -= deltanow;
128131 }
129132 }
@@ -183,9 +186,9 @@
183186 requires a special handling, the compression procedure.*/
184187 if (delta < deltanow) {
185188 vt_list_compress(vtlp, deltanow);
186- delta -= deltanow;
189+ delta = delay;
187190 }
188- else if (delta < vtlp->dlist.next->delta) {
191+ if (delta < vtlp->dlist.next->delta) {
189192 sysinterval_t deadline_delta;
190193
191194 /* A small delay that will become the first element in the delta list
@@ -479,7 +482,8 @@
479482 virtual_timer_t *vtp = (virtual_timer_t *)dlp;
480483
481484 /* The "last time" becomes this timer's expiration time.*/
482- vtlp->lasttime += dlp->delta;
485+// vtlp->lasttime += dlp->delta;
486+ vtlp->lasttime = chTimeAddX(vtlp->lasttime, dlp->delta);
483487 nowdelta -= dlp->delta;
484488
485489 /* Removing the timer from the list, marking it as not armed.*/
@@ -507,18 +511,30 @@
507511 order to reduce error.*/
508512 now = chVTGetSystemTimeX();
509513
514+// chDbgAssert((int)chTimeDiffX(vtp->last, now) >= 0, "back in time");
515+
510516 /* If a reload is defined the timer needs to be restarted.*/
511517 if (vtp->reload > (sysinterval_t)0) {
512518 sysinterval_t skipped_delta;
513519
514- /* Calculating how much the real current time skipped past the
515- hypothetical current deadline.*/
520+#if 1
521+ /* Calculating how much the actual current time skipped past the
522+ predicted current deadline.*/
516523 skipped_delta = chTimeDiffX(vtp->last, now);
517524
518- chDbgAssert(skipped_delta < vtp->reload, "skipped deadline");
525+// if (vtp->reload == 121) {
526+// chTraceWriteI(vtp, (void *)now);
527+// chTraceWriteI(vtp, (void *)vtp->last);
528+// chTraceWriteI(vtp, (void *)skipped_delta);
529+// }
519530
531+ chDbgAssert(skipped_delta <= vtp->reload, "skipped deadline");
532+
520533 /* Enqueuing the timer again using the calculated delta.*/
521534 vt_enqueue(vtlp, vtp, now, vtp->reload - skipped_delta);
535+#else
536+ chVTDoSetI(vtp, vtp->reload, vtp->func, vtp->par);
537+#endif
522538 }
523539
524540 /* Next element in the list.*/
@@ -535,8 +551,8 @@
535551 /* The "unprocessed nowdelta" time slice is added to "last time"
536552 and subtracted to next timer's delta.*/
537553 // vtlp->lasttime += nowdelta;
538- vtlp->lasttime = chTimeAddX(vtlp->lasttime, nowdelta);
539- vtlp->dlist.next->delta -= nowdelta;
554+// vtlp->lasttime = chTimeAddX(vtlp->lasttime, nowdelta);
555+// vtlp->dlist.next->delta -= nowdelta;
540556
541557 /* Recalculating the next alarm time.*/
542558 delta = dlp->delta - chTimeDiffX(vtlp->lasttime, now);
--- trunk/testrt/VT_STORM/source/vt_storm.c (revision 14338)
+++ trunk/testrt/VT_STORM/source/vt_storm.c (revision 14339)
@@ -155,7 +155,7 @@
155155 chprintf(cfg->out, "*** Delta: %d\r\n", CH_CFG_ST_TIMEDELTA);
156156 chprintf(cfg->out, "\r\n");
157157
158- for (i = 1; i <= VT_STORM_CFG_ITERATIONS; i++){
158+ for (i = 1; i <= VT_STORM_CFG_ITERATIONS; i++) {
159159
160160 chprintf(cfg->out, "Iteration %d\r\n", i);
161161
Show on old repository browser