npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

processschedulingalgo

v1.0.1

Published

This package provides implementations of various process scheduling algorithms. It includes both preemptive and non-preemptive versions of the following algorithms:

Downloads

3

Readme

Process Scheduling Algorithms

This package provides implementations of various process scheduling algorithms. It includes both preemptive and non-preemptive versions of the following algorithms:

  • First Come First Serve (FCFS)
  • Priority-Based Scheduling
  • Shortest Job First (SJF)

Installation

You can install this package via npm. Make sure you have Node.js and npm installed on your machine.

npm install processSchedulingAlgo

Replace your-package-name with the actual name of your package.

Usage
-----

### Importing the Algorithms

You can import the algorithms into your project using ES module syntax. Here's how you can do it:
import { FCFSPreemptive, FCFSNonPreemptive, PriorityPreemptive, PriorityNonPreemptive, SJFPreemptive, SJFNonPreemptive } from 'your-package-name';

Example Usage

Here's a brief example of how to use each scheduling algorithm.

1. First Come First Serve (FCFS)

Preemptive Version

import { FCFSPreemptive } from 'your-package-name';

let readyQueue1 = [
    { id: 1, AT: 0, BT: 10 },
    { id: 2, AT: 0, BT: 5 },
    { id: 3, AT: 0, BT: 8 }
];

let fcfsPreemptive = new FCFSPreemptive(readyQueue1);
console.log('Average Turnaround Time:', fcfsPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', fcfsPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', fcfsPreemptive.getAverageResponseTime());

Non-Preemptive Version

import { FCFSNonPreemptive } from 'your-package-name';

let readyQueue2 = [
    { id: 1, AT: 0, BT: 10 },
    { id: 2, AT: 0, BT: 5 },
    { id: 3, AT: 0, BT: 8 }
];

let fcfsNonPreemptive = new FCFSNonPreemptive(readyQueue2);
console.log('Average Turnaround Time:', fcfsNonPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', fcfsNonPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', fcfsNonPreemptive.getAverageResponseTime());

2. Priority-Based Scheduling

Preemptive Version

import { PriorityPreemptive } from 'your-package-name';

let readyQueue3 = [
    { id: 1, AT: 0, BT: 10, priority: 2 },
    { id: 2, AT: 0, BT: 5, priority: 1 },
    { id: 3, AT: 0, BT: 8, priority: 3 }
];

let priorityPreemptive = new PriorityPreemptive(readyQueue3);
console.log('Average Turnaround Time:', priorityPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', priorityPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', priorityPreemptive.getAverageResponseTime());

Non-Preemptive Version

import { PriorityNonPreemptive } from 'your-package-name';

let readyQueue4 = [
    { id: 1, AT: 0, BT: 10, priority: 2 },
    { id: 2, AT: 0, BT: 5, priority: 1 },
    { id: 3, AT: 0, BT: 8, priority: 3 }
];

let priorityNonPreemptive = new PriorityNonPreemptive(readyQueue4);
console.log('Average Turnaround Time:', priorityNonPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', priorityNonPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', priorityNonPreemptive.getAverageResponseTime());

3. Shortest Job First (SJF)

Preemptive Version

import { SJFPreemptive } from 'your-package-name';

let readyQueue5 = [
    { id: 1, AT: 0, BT: 10 },
    { id: 2, AT: 0, BT: 5 },
    { id: 3, AT: 0, BT: 8 }
];

let sjfPreemptive = new SJFPreemptive(readyQueue5, 4); // Time quantum set to 4 for example
console.log('Average Turnaround Time:', sjfPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', sjfPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', sjfPreemptive.getAverageResponseTime());

Non-Preemptive Version

import { SJFNonPreemptive } from 'your-package-name';

let readyQueue6 = [
    { id: 1, AT: 0, BT: 10 },
    { id: 2, AT: 0, BT: 5 },
    { id: 3, AT: 0, BT: 8 }
];

let sjfNonPreemptive = new SJFNonPreemptive(readyQueue6);
console.log('Average Turnaround Time:', sjfNonPreemptive.getAverageTurnaroundTime());
console.log('Average Waiting Time:', sjfNonPreemptive.getAverageWaitingTime());
console.log('Average Response Time:', sjfNonPreemptive.getAverageResponseTime());

Contributing

Feel free to contribute to this project by submitting issues or pull requests. Please ensure that your code adheres to the existing style and is well-tested.

License

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