First hack. Note that whilst this does the "right" thing, there is no attempt made to avoid deadlock. The Java tests (in particular the QoS Tests) all pass. Basically, I take the longest queue length, double it. The probability of that queue being unblocked is 50% (i.e. len >= 2*Len). That 2*Len is then used against all the queues, with their own length. Thus the shorter they are, the lower their probability of being unblocked. We stop work when we guarantee that either we've woken everyone up, or we've woken up enough to guarantee that we're now reblocked.

In general, this is pretty rough and ready and more like a proof of concept. Needs refinement.
And now it can't deadlock. Beautiful.
All the low hanging fruit from the QA notes
Well, there's been a reorganisation of the algorithm. It's an approximation of what we really want, but with the advantage that we don't need to build a new data structure, but the disadvantage that there may be too many calls to random:uniform. However, it does it in one pass (well, max 2 passes) of the list of queues, instead of N. For massive numbers of queues, this'll actually be better as the cost of manipulating a huge data structure will be higher than the additional calls to random:uniform. The QoS fairness tests pass randomly.
Don't bother working through a bunch of queues which have zero length. Of course when being called through unblock_all, we really do need to tell everyone.
inability to do maths
Split queues to limited and unlimited queues, thus we don't need to filter out unlimited queues when trying to unblock. There's still the dict:fold over all the limited queues, otoh, this can't be avoided given the probabilistic nature of the solution - we just don't know in advance how many queues we're going to attempt to unblock. Also, found a large number of bugs here with the previous version - such as the inability to cope with several queues of the same length and others too.
merging default into bug 20072 as default has moved a long way in the meantime
Junk bug 20072.