-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testiranje os_sleep al je preciznost 3 sekunde (bice bolje nadam se)
- Loading branch information
Showing
13 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"src" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
https://afrodita.rcub.bg.ac.rs/~dmilicev/publishing/OS1/Dragan%20Milicev%20-%20Operativni%20sistemi%201%20-%20predavanja%202020%20-%20Deo%20III/#92 slajdovi 52-55 | ||
|
||
http://os.etf.rs/OS2/predavanja/ slajdovi 2 - 26 | ||
http://os.etf.rs/OS2/predavanja/ slajdovi 2 - 26 | ||
|
||
https://github.com/lazar2222/Operating-Systems-2-Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
from algorithmPlanner import * | ||
from process import Process | ||
from operatingSystem import OS | ||
from cpu import CPU | ||
|
||
def test_queue_order(): | ||
cpu = CPU() | ||
os = OS(cpu, FirstComeFirstServe()) | ||
cpu.setOS(os) | ||
|
||
p1 = Process(5, 30, 2) | ||
p3 = Process(6, 20, 2) | ||
p2 = Process(3, 25, 1) | ||
|
||
os.createProcess(p1) | ||
os.createProcess(p2) | ||
os.createProcess(p3) | ||
|
||
|
||
assert os.getProcess() == p1 | ||
assert os.getProcess() == p2 | ||
assert os.getProcess() == p3 | ||
|
||
def test_priority_queue_order(): | ||
cpu = CPU() | ||
os = OS(cpu, ShortestProcessFirst()) | ||
cpu.setOS(os) | ||
|
||
p1 = Process(5, 30, 2) | ||
p2 = Process(6, 20, 2) | ||
p3 = Process(3, 25, 1) | ||
|
||
os.createProcess(p1) | ||
os.createProcess(p2) | ||
os.createProcess(p3) | ||
|
||
|
||
assert os.getProcess() == p2 | ||
assert os.getProcess() == p3 | ||
assert os.getProcess() == p1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
from algorithmPlanner import * | ||
from process import Process | ||
from operatingSystem import OS | ||
from cpu import CPU | ||
import time | ||
|
||
def test_os_sleep(): | ||
cpu = CPU() | ||
os = OS(cpu, FirstComeFirstServe()) | ||
cpu.setOS(os) | ||
|
||
time1 = 1.0 | ||
time2 = 2.0 | ||
time3 = 3.0 | ||
|
||
p1 = Process(5, 30, time1) | ||
p3 = Process(6, 20, time2) | ||
p2 = Process(3, 25, time3) | ||
|
||
os.createProcess(p1) | ||
os.createProcess(p2) | ||
os.createProcess(p3) | ||
|
||
dt = 3.0 | ||
|
||
t1_0 = time.time() | ||
os.sleep(p1) | ||
t1_1 = time.time() | ||
assert abs(t1_1 - (t1_0 + time1)) <= dt | ||
|
||
t2_0 = time.time() | ||
os.sleep(p2) | ||
t2_1 = time.time() | ||
assert abs(t2_1 - (t2_0 - time2)) <= dt | ||
|
||
t3_0 = time.time() | ||
os.sleep(p3) | ||
t3_1 = time.time() | ||
assert abs(t3_1 - (t3_0 - time3)) <= dt |