brief/deep sleep for DP cores
authorimarom <[email protected]>
Wed, 2 Mar 2016 12:37:58 +0000 (14:37 +0200)
committerimarom <[email protected]>
Wed, 2 Mar 2016 12:37:58 +0000 (14:37 +0200)
src/stateless/dp/trex_stateless_dp_core.cpp

index 19eface..f8d6d82 100644 (file)
@@ -394,12 +394,27 @@ bool TrexStatelessDpCore::set_stateless_next_node(CGenNodeStateless * cur_node,
 void 
 TrexStatelessDpCore::idle_state_loop() {
 
+    const int SHORT_DELAY_MS    = 2;
+    const int LONG_DELAY_MS     = 50;
+    const int DEEP_SLEEP_LIMIT  = 2000;
+
+    int counter = 0;
+
     while (m_state == STATE_IDLE) {
         bool had_msg = periodic_check_for_cp_messages();
-        /* if no message - backoff for some time */
-        if (!had_msg) {
-            delay(200);
+        if (had_msg) {
+            counter = 0;
+            continue;
+        }
+
+        /* enter deep sleep only if enough time had passed */
+        if (counter < DEEP_SLEEP_LIMIT) {
+            delay(SHORT_DELAY_MS);
+            counter++;
+        } else {
+            delay(LONG_DELAY_MS);
         }
+        
     }
 }