From 8ba41cd798c36b54c25892ebfa2c1b2c8a8b2dc0 Mon Sep 17 00:00:00 2001 From: april Date: Wed, 22 Aug 2018 18:06:11 -0400 Subject: [PATCH 1/2] started --- src/Process.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Process.js b/src/Process.js index 159a307..6e7b82b 100644 --- a/src/Process.js +++ b/src/Process.js @@ -16,11 +16,12 @@ class Process { } setParentQueue(queue) { + this.queue =queue; } isFinished() { - + return(this.cpuTimedNeeded === 0 && this.blockingTimeNeeded === 0) ? true : false; } // If no blocking time is needed by this process, decrement the amount of @@ -29,7 +30,10 @@ class Process { // by emitting the appropriate interrupt // Make sure the `stateChanged` flag is toggled appropriately executeProcess(time) { - + this.sateChanged = false; + if (this.blockingTimeNeeded === 0){ + this.cpuTimedNeeded + } } // If this process requires blocking time, decrement the amount of blocking From 6987b0f9bb676d8f414dc58f179d27f8472034e6 Mon Sep 17 00:00:00 2001 From: april Date: Wed, 22 Aug 2018 18:54:01 -0400 Subject: [PATCH 2/2] working --- src/Process.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Process.js b/src/Process.js index 6e7b82b..0c68665 100644 --- a/src/Process.js +++ b/src/Process.js @@ -31,8 +31,11 @@ class Process { // Make sure the `stateChanged` flag is toggled appropriately executeProcess(time) { this.sateChanged = false; - if (this.blockingTimeNeeded === 0){ - this.cpuTimedNeeded + if (this.blockingTimeNee == 0){ + this.cpuTimedNeeded = (time > this.cpuTimeNeeded) ? 0 : this.cpTimeNeeded -time + return; + }else{ + this.queue.emitInterrupt } }