Skip to content

Commit

Permalink
Algorithm Enhancement, bug fixes and package as Electron app
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedkrmn committed Apr 17, 2019
1 parent 165895a commit 07c9f19
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build/FCFS.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/NP_Priority.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/NP_SJF.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/Priority.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/RR.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/SJF.js

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions express-server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ const express = require("express");
const routes = require("./routes");
const path = require("path");

const app = express();
function runServer() {
const app = express();

app.use(express.static(path.join(__dirname, "../assets")));
app.use(express.static(path.join(__dirname, "../build")));
app.use(express.static(path.join(__dirname, "../assets")));
app.use(express.static(path.join(__dirname, "../build")));

app.set("views", path.join(__dirname, "../src/views"));
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "../src/views"));
app.set("view engine", "ejs");

app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "../mainWindow.html"));
});
app.use("/", routes);
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "../mainWindow.html"));
});
app.use("/", routes);

const PORT = 3000;
const PORT = 3000;

app.listen(PORT);
app.listen(PORT);
}

module.exports = runServer;
5 changes: 3 additions & 2 deletions src/app/Priority.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class Chart {

//* Extract the highest priority process from the list on a unit-time basis and add it to the final scheduler list that is to be drawn on the chart
let shortestProcess;
//* If the burst time of the process = 1, extract it right away
if (this.processes[0][2] == 1) shortestProcess = this.processes.shift();
//* If the burst time of the process = 1, OR it's the only process left, extract it right away
if (this.processes[0][2] == 1 || this.processes.length == 1)
shortestProcess = this.processes.shift();
//* else consume 1 second of the process, add it in the scheduler and leave the rest of the process in the list
else {
let [processName, arrivalTime, burstTime, priority] = [
Expand Down
4 changes: 2 additions & 2 deletions src/app/RR.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Chart {
while (this.processes.length) {
let shortestProcess, processName, arrivalTime, burstTime;

//* If the burst time of the process <= quantum, extract it right away
if (this.processes[0][2] <= this.quantum) {
//* If the burst time of the process <= quantum, OR it's the only process left, extract it right away
if (this.processes[0][2] <= this.quantum || this.processes.length == 1) {
shortestProcess = this.processes.splice(0, 1)[0]; //! splice() returns the element wrapped in a list
} else {
//* else consume "quantuam" seconds of the process
Expand Down
5 changes: 3 additions & 2 deletions src/app/SJF.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class Chart {

//* Extract the shortest process from the list on a unit-time basis and add it to the final scheduler list that is to be drawn on the chart
let shortestProcess;
//* If the burst time of the process = 1, extract it right away
if (this.processes[0][2] == 1) shortestProcess = this.processes.shift();
//* If the burst time of the process = 1, OR it's the only process left, extract it right away
if (this.processes[0][2] == 1 || this.processes.length == 1)
shortestProcess = this.processes.shift();
//* else consume 1 second of the process, add it in the scheduler and leave the rest of the process in the list
else {
let [processName, arrivalTime, burstTime] = [...this.processes[0]];
Expand Down
15 changes: 11 additions & 4 deletions src/helpers/userInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ form.addEventListener("submit", addProcess);

function deleteProcess(e) {
if (e.target.classList.contains("fa-times")) {
const processName = parseInt(
e.target.parentElement.previousElementSibling.previousElementSibling
.textContent
);
let processName;
if (priorityField)
processName = parseInt(
e.target.parentElement.previousElementSibling.previousElementSibling
.previousElementSibling.textContent
);
else
processName = parseInt(
e.target.parentElement.previousElementSibling.previousElementSibling
.textContent
);
for (let i = processName; i < processes.length; i++) processes[i][0]--;
processes.splice(processName - 1, 1);
current_process--;
Expand Down

0 comments on commit 07c9f19

Please sign in to comment.