Question

Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads,...

Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads, independent of priority. How effectively would a priority-based scheduling algorithm handle this situation if one run queue had all high-priority threads and a second queue had all low-priority threads?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution is very simple.

1. Give higher priority to queue containing high priority thread and hence process the thread in this queue first.

2. Then once an element from high priority queue is dequeued, if  balance between number of threads in these two queues are disturbed, then dequeue one thread from queue containing low priority thread and enqueue this into queue having high priority thread to balance the number of threads in these 2 queues. Since priority queue automatically adjust the thread within the queue based on its priority, hence removal of thread from one priority queue to another is not a problem.

3. If a new thread arrive with certain value of priority, then new thread could be added into queue containing less number of thread to maintain balance.

Thus in this way, load-balancing criteria of maintaining almost equal number of thread will be maintained and also giving more priority to high priority thread will also be maintained.

An additional thing to add in above statement is that, priority based scheduler, always check the priority of front element in both the queue. Hence scheduler will dequeue the thread from the queue containing highest priority thread. And then it is task of load-balancing algorithm to maintain balance of number of thread using method we discussed in 3 points above.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT