posix simulator hal_lld changes Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

posix simulator hal_lld changes  Topic is solved

Postby faisal » Wed Jan 17, 2018 9:44 pm

If interrupts are too frequent, then the system tick will never happen due to the call to chSchDoReschedule(). Below is a patch to _sim_check_for_interrupts() which will ensure that the systick is always evaluated, and chSchDoReschedule() is called at the end. Originally I had included a call to nanosleep() for a short duration so that the process doesn't run at 100% CPU utilization. However, that is probably best done in CH_CFG_IDLE_LOOP_HOOK() .


Code: Select all

---
+++
@@ -1,31 +1,32 @@
 void _sim_check_for_interrupts(void) {
   struct timeval tv;
-
+  bool int_occurred = false;
 #if HAL_USE_SERIAL
   if (sd_lld_interrupt_pending()) {
-    _dbg_check_lock();
-    if (chSchIsPreemptionRequired())
-      chSchDoReschedule();
-    _dbg_check_unlock();
-    return;
+    int_occured = true;
   }
 #endif
 
   gettimeofday(&tv, NULL);
   if (timercmp(&tv, &nextcnt, >=)) {
+    int_occurred = true;
     timeradd(&nextcnt, &tick, &nextcnt);
 
     CH_IRQ_PROLOGUE();
 
     chSysLockFromISR();
     chSysTimerHandlerI();
     chSysUnlockFromISR();
 
     CH_IRQ_EPILOGUE();
 
-    _dbg_check_lock();
-    if (chSchIsPreemptionRequired())
-      chSchDoReschedule();
-    _dbg_check_unlock();
   }

+  if (int_occurred)
+  {
+    _dbg_check_lock();
+    if (chSchIsPreemptionRequired())
+      chSchDoReschedule();
+    _dbg_check_unlock();
+  }
 }

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: posix simulator hal_lld changes

Postby faisal » Fri Mar 16, 2018 6:25 am

Any appetite to include this change in 18.2.x?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: posix simulator hal_lld changes

Postby Giovanni » Sat Mar 17, 2018 11:33 am

Hi,

I committed it in both trunk and 18.2.x.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 6 guests