Skip to content

Commit 9e557ac

Browse files
committed
Adding into Jupyter notebook
1 parent fa3a253 commit 9e557ac

File tree

5 files changed

+589
-18
lines changed

5 files changed

+589
-18
lines changed

FCFS.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ def solve():
8787

8888
plt.xticks(range(max_yticks + 1))
8989
plt.grid(True)
90+
plt.title('FCFS')
9091
plt.show()
9192

9293
if __name__ == "__main__":
9394
n = 1
9495
# n = int(input())
9596
while n > 0:
9697
solve()
97-
n -= 1
98+
n -= 1

Priority_scheduling.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def solve():
3434
procompleted[i] = 1
3535
if len(p):
3636
runnn = heapq.heappop(p)
37-
print(runnn)
38-
# print(runnn[0] , " " , runnn[1] , " " , runnn[2])
3937
temp = []
4038
for i in range(process):
4139
if i == runnn[2]:
@@ -53,21 +51,16 @@ def solve():
5351
else:
5452
temp = []
5553
for i in range(process):
56-
# print(i)
5754
temp.append(0)
5855
v.append(temp)
5956
time += 1
60-
61-
# print(v)
6257

6358
for i in range(process):
6459
last_ind = 0
6560
for j in range(len(v)):
66-
print(v[j][i], end='')
6761
if v[j][i] == 1:
6862
last_ind = j
6963
finish.append(last_ind + 1)
70-
print()
7164

7265
matrix_vec = np.array(v)
7366

@@ -92,11 +85,11 @@ def solve():
9285

9386
plt.xticks(range(max_yticks + 1))
9487
plt.grid(True)
88+
plt.title('Priority_scheduling')
9589
plt.show()
9690

9791
if __name__ == "__main__":
9892
n = 1
99-
# n = int(input())
10093
while n > 0:
10194
solve()
102-
n -= 1
95+
n -= 1

SJF.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def solve():
3333
if len(p):
3434
running_process = heapq.heappop(p)
3535
total = running_process[0] + time
36-
# print(running_process[0] , " " , running_process[1] , " " , running_process[2])
3736
while time < total:
3837
temp = []
3938
for i in range(process):
@@ -57,8 +56,6 @@ def solve():
5756
temp.append(0)
5857
v.append(temp)
5958
time += 1
60-
61-
# print(v)
6259

6360
for i in range(process):
6461
last_ind = 0
@@ -92,11 +89,11 @@ def solve():
9289

9390
plt.xticks(range(max_yticks + 1))
9491
plt.grid(True)
92+
plt.title('SJF')
9593
plt.show()
9694

9795
if __name__ == "__main__":
9896
n = 1
99-
# n = int(input())
10097
while n > 0:
10198
solve()
10299
n -= 1

SRTF.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def solve():
5656
temp.append(0)
5757
v.append(temp)
5858
time += 1
59-
60-
# print(v)
6159

6260
for i in range(process):
6361
last_ind = 0
@@ -71,6 +69,7 @@ def solve():
7169
matrix_vec = np.array(v)
7270

7371
nonzero = np.argwhere(matrix_vec == 1)
72+
plt.subplot(2,2,1)
7473

7574
for i, j in nonzero:
7675
plt.fill([i, i + 1, i + 1, i], [len(matrix_vec) - j - 1, len(matrix_vec) - j - 1, len(matrix_vec) - j, len(matrix_vec) - j], 'blue')
@@ -91,11 +90,11 @@ def solve():
9190

9291
plt.xticks(range(max_yticks + 1))
9392
plt.grid(True)
93+
plt.title('SRTF')
9494
plt.show()
9595

9696
if __name__ == "__main__":
9797
n = 1
98-
# n = int(input())
9998
while n > 0:
10099
solve()
101-
n -= 1
100+
n -= 1

0 commit comments

Comments
 (0)