Table of Contents
The MLFQ algorithm is an extended and more advanced version of multi-level queue (MLQ) scheduling. It divides processes into multiple priority levels and uses feedback mechanisms to dynamically adjust their priorities. This ensures that both interactive and CPU-intensive tasks are handled effectively.
-
Priority Levels: Processes are categorized into different priority levels, allowing for efficient handling of diverse workloads.
-
Multiple Queues: The algorithm maintains multiple queues, each corresponding to a different priority level. The highest priority queue is serviced first.
-
Time Quantum: Processes in the highest priority queue are given a fixed time quantum to execute on the CPU. Exceeding the time quantum results in pre-emption and demotion.
-
Promotion and Demotion: Processes that complete their time quantum are demoted to lower priority queues, preventing CPU-bound tasks from monopolizing resources.
-
Aging: Aging prevents starvation by gradually increasing the priority of processes waiting in lower priority queues.
-
Feedback Mechanism: Feedback, collected during execution, influences priority adjustments based on a process's behavior.
-
Queue Selection: Processes are moved to lower priority queues when they complete their time quantum or perform blocking I/O operations.
-
Pre-emption: Higher priority processes pre-empt running processes, ensuring responsiveness and prioritizing critical tasks.
The Multi-Level Feedback Queue (MLFQ) dynamically prioritizes processes based on their behavior, utilizing multiple queues, time quantums, and feedback mechanisms to balance responsiveness and resource utilization for efficient CPU scheduling.
-
- To use the MLFQ algorithm in your JavaScript application
const cases = require("./RandomCases.js"); const queues = [[], [], []]; const mlfq = new MLFQ(queues); mlfq.schedule(cases);
-
- Case Assignment to Queues
for (const currentCase of cases) { if (currentCase.score >= 7 && currentCase.score <= 10) { this.queues[0].push(currentCase); // Queue 1 for urgent cases (7-10) } else if (currentCase.score >= 4 && currentCase.score <= 6) { this.queues[1].push(currentCase); // Queue 2 for medium priority cases (4-6) } else if (currentCase.score >= 1 && currentCase.score <= 3) { this.queues[2].push(currentCase); // Queue 3 for low-priority cases (1-3) } }
-
- Sorting Cases Within Each Queue
for (let i = 0; i < this.queues.length; i++) { const priorityLabel = this.getPriorityLabel(i); const sortedCases = this.queues[i].sort((a, b) => b.score - a.score); }
Explore the provided examples to see how MLFQ scheduling can be applied to different sets of processes. These examples showcase various scenarios to help you understand the algorithm's behavior in different situations.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Your Name - @shwetasd19 - [email protected]
Project Link: https://github.com/shwetd19/Multi-Level-Feedback-Queue-MLFQ