Skip to content

shwetd19/Multi-Level-Feedback-Queue-MLFQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

⚖️ Multi-Level Feedback Queue Scheduling Algorithms 🤝

Table of Contents
  1. Overview
  2. Key Features
  3. How MLFQ Works
  4. Usage
  5. Examples
  6. License

Overview

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.

Key Features

  • 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.

How MLFQ Works

Product Name Screen Shot

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.

MLFQ.js Overview

    1. To use the MLFQ algorithm in your JavaScript application
        const cases = require("./RandomCases.js");
        const queues = [[], [], []];
        const mlfq = new MLFQ(queues);
    
        mlfq.schedule(cases);
    1. 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)
            }
        }
    1. 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Your Name - @shwetasd19 - [email protected]

Project Link: https://github.com/shwetd19/Multi-Level-Feedback-Queue-MLFQ

About

Multi-Level Feedback Queue (MLFQ) Scheduling Algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published