title: Starvation prevention in priority queue
body: <p>As everyone knows, a priority queue can create starvation for lower priority items in its simplest form. For example, assume that we have following items in a priority queue in increasing priority order:</p>
  
  <pre><code>Item     Priority
  --------------------
  Item A      0      //Lowest priority
  Item B      1
  Item C      2
  Item D      3
  Item E      4      //Highest priority
  </code></pre>
  
  <p>Now if we receive a consistent flow of items with higher priority in our priority queue(B-E), we may never handle lower priority packets(A). I wonder what algorithms are there to handle this problem?</p>
  
  <p>A simple approach that comes to my mind is limiting processing of different item types based on priority. For example, we limit packet processing of each type to <code>2 ^ priority</code>. So for table above, after handing 16 items of <code>Item E</code> type, we will handle up to 8 items of type <code>Item D</code>, up to 4 of <code>Item C</code>, up to 2 of <code>Item B</code> and up to 1 of <code>Item A</code> before starting to handle <code>Item E</code> again. This will prevent starvation for different item types. </p>
  
  <p>This is a simple method, but I wonder if there are other famous algorithms to tackle this problem. Any idea for better algorithms or solutions?</p>