Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
6/17 Queue.test.js failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradiowave committed Aug 15, 2018
1 parent f4a5242 commit f46463c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
38 changes: 29 additions & 9 deletions src/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,69 @@ class Queue {

// Enqueues the given process. Return the enqueue'd process
enqueue(process) {

this.processes.push(process);
process.setParentQueue(this);
return process;
}

// Dequeues the next process in the queue. Return the dequeue'd process
dequeue() {

return this.processes.shift();
}

// Return the least-recently added process without removing it from the list of processes
peek() {

return this.processes[0];
}

isEmpty() {

return (this.processes == 0);
}

getPriorityLevel() {

return this.priorityLevel;
}

getQueueType() {

return this.queueType;
}

// Manages a process's execution for the given amount of time
// Processes that have had their states changed should not be affected
// Once a process has received the alloted time, it needs to be dequeue'd and
// then handled accordingly, depending on whether it has finished executing or not
manageTimeSlice(currentProcess, time) {

if (currentProcess.stateChanged === true) this.quantumClock = 0;
else if (time < this.quantum) {
this.quantumClock = time;
if (currentProcess.isFinished()){
this.dequeue();
}
} else {
this.quantumClock = 0;
if (currentProcess.isFinished()){
this.dequeue();
} else {
this.dequeue();
this.scheduler.handleInterrupt(this, currentProcess, SchedulerInterrupt.LOWER_PRIORITY)
}
}
}

// Execute the next non-blocking process (assuming this is a CPU queue)
// This method should call `manageTimeSlice` as well as execute the next running process
doCPUWork(time) {

let currentProcess = this.peek;
currentProcess.executeProcess(time);
this.manageTimeSlice(currentProcess, time);
}

// Execute the next blocking process (assuming this is the blocking queue)
// This method should call `manageTimeSlice` as well as execute the next blocking process
doBlockingWork(time) {

let currentProcess = this.peek;
currentProcess.executeBlockingProcess(time);
this.manageTimeSlice(currentProcess, time);
}

// The queue's interrupt handler for notifying when a process needs to be moved to a different queue
Expand Down
4 changes: 2 additions & 2 deletions yarn-error.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Arguments:
C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Yarn\bin\yarn.js run test Process.test.js
C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Yarn\bin\yarn.js run test Queue.test.js

PATH:
C:\Users\diveb\bin;D:\Program Files\Git\mingw64\bin;D:\Program Files\Git\usr\local\bin;D:\Program Files\Git\usr\bin;D:\Program Files\Git\usr\bin;D:\Program Files\Git\mingw64\bin;D:\Program Files\Git\usr\bin;C:\Users\diveb\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files\Oculus\Support\oculus-runtime;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;D:\Program Files\Git\cmd;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Yarn\bin;C:\Program Files\nodejs;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\Program Files\Microsoft VS Code\bin;C:\Users\diveb\AppData\Local\Programs\Python\Python36\Scripts;C:\Users\diveb\AppData\Local\Programs\Python\Python36;C:\Users\diveb\AppData\Local\Programs\Python\Python37\Scripts;C:\Users\diveb\AppData\Local\Programs\Python\Python37;C:\Users\diveb\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Microsoft VS Code\bin;C:\Users\diveb\AppData\Local\Yarn\bin;C:\Users\diveb\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\3.6\bin;C:\Program Files\Heroku\bin;C:\Users\diveb\AppData\Roaming\Python\Python37\Scripts;D:\Program Files\Git\usr\bin\vendor_perl;D:\Program Files\Git\usr\bin\core_perl
Expand Down Expand Up @@ -3675,7 +3675,7 @@ Trace:
Error: Command failed.
Exit code: 1
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /d /s /c jest --verbose Process.test.js
Arguments: /d /s /c jest --verbose Queue.test.js
Directory: C:\Users\diveb\LambdaSchool\Week19\Multi-Level-Feedback-Queue
Output:

Expand Down

0 comments on commit f46463c

Please sign in to comment.