diff options
| author | Martin Braun <martin.braun@ettus.com> | 2017-05-15 10:03:37 -0700 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2017-05-15 10:03:37 -0700 | 
| commit | 5d4c0ccb41f925bbc0749090c58c0d66ecf0f37a (patch) | |
| tree | ae814eb8cb17a47148b79231399844a70fba35e1 /host/lib/usrp/device3 | |
| parent | 412acb853729023e7f24c9ef11699010ed8dadab (diff) | |
| parent | 6f87cca4e8d98b5544a89d25d9eddce5ba85d393 (diff) | |
| download | uhd-5d4c0ccb41f925bbc0749090c58c0d66ecf0f37a.tar.gz uhd-5d4c0ccb41f925bbc0749090c58c0d66ecf0f37a.tar.bz2 uhd-5d4c0ccb41f925bbc0749090c58c0d66ecf0f37a.zip | |
Merge branch 'maint'
Diffstat (limited to 'host/lib/usrp/device3')
| -rw-r--r-- | host/lib/usrp/device3/device3_io_impl.cpp | 30 | 
1 files changed, 28 insertions, 2 deletions
| diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp index 27c31f17b..1668846c2 100644 --- a/host/lib/usrp/device3/device3_io_impl.cpp +++ b/host/lib/usrp/device3/device3_io_impl.cpp @@ -357,6 +357,8 @@ static bool tx_flow_ctrl(      size_t fc_window,      managed_buffer::sptr  ) { +    bool refresh_cache = false; +      // Busy loop waiting for flow control update.  This is necessary because      // at this point there is data trying to be sent and it must be sent as      // quickly as possible when the flow control update arrives to avoid @@ -364,6 +366,12 @@ static bool tx_flow_ctrl(      // data needs to be sent and flow control is holding it back.      while (true)      { +        if (refresh_cache) +        { +            // update the cached value from the atomic +            fc_cache->last_seq_ack_cache = fc_cache->last_seq_ack; +        } +          // delta is the amount of FC credit we've used up          const size_t delta = (fc_cache->last_seq_out & HW_SEQ_NUM_MASK) -              (fc_cache->last_seq_ack_cache & HW_SEQ_NUM_MASK); @@ -374,8 +382,26 @@ static bool tx_flow_ctrl(              fc_cache->last_seq_out++; //update seq              return true;          } -        // update the cached value from the atomic -        fc_cache->last_seq_ack_cache = fc_cache->last_seq_ack; +        else +        { +            if (refresh_cache) +            { +                // We have already refreshed the cache and still +                // lack flow control permission to send new data. + +                // A true busy loop choked out the message handler +                // thread on machines with processor limitations +                // (too few cores).  Yield to allow flow control +                // receiver thread to operate. +                boost::this_thread::yield(); +            } +            else +            { +                // Allow the cache to refresh and try again to +                // see if the device has granted flow control permission. +                refresh_cache = true; +            } +        }      }      return false;  } | 
