Python 3 Round Robin Priority queues – Avoiding starvation - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Tuesday, August 7, 2018

Python 3 Round Robin Priority queues – Avoiding starvation

In the post (Python 3 avoid starvation in Priority Queues) I explained the starvation problem you face front when using Python priority queues. In this post I'm going to reimplement a queue that avoid the problem using round robin, while in the post Python 3 priority queues with aging I used the aging to avoid the same problem. In Round Robin, what I want to do is: 1. Most of the time, the more important items are fetched. 2. However, we guarantee that some of the time, the less important items are fetched. To reach 1. goal we can use the priority queue. To reach 2. goal we have to define when the queue should return higher priority items and when the queue should return lower priority items. we can do this providing to the queue a roundrobin list for example round_robin = [0, 0, 1, 0, 0, 2, 0, 0, 1] The meaning of the list is: For the first and second fetches, take items with priority = 0 For the third fetch, take the first item with priority = 1 For the fourth and fifth fetches, take items with priority = 0 For the sixth fetch, take an item with priority = 2 For the seventh and eighth fetches, take items with priority = 0 For the nineth fetch, take the first item with priority = 1 If items are not available take the first item in the prio order.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

xAppSoftware News,python,queue,round robin,starvation

No comments:

Post a Comment