Ejemplo n.º 1
0
class TestProcess(unittest.TestCase):
    def setUp(self):
        self.process = Process()
        
    def test_compare_strings_with_some_matches(self):
        self.process.compare_strings("egy\nketto","egy\nmeg egy az\nketto?")
        self.assertEqual(2, self.process.get_matches())

    def test_get_data_with_more_pieces(self):
        expected = ['Ez egy','egyszeru','unit teszt.']
        result = []
        for data in self.process.get_data("Ez egy\negyszeru\nunit teszt."):
            result.append(data)
        self.assertEqual(expected, result)

    def test_load(self):
        self.process.load("tmp/file.txt")
        self.assertRaises(FileNotFoundError)
Ejemplo n.º 2
0
def indent():
    lines = text.get(0.0,END)
    p = Process()
    lines= p.send_string(lines)
    text.delete(0.0,END)
    text.insert(0.0,lines)
Ejemplo n.º 3
0
 def setUp(self):
     self.process = Process()
Ejemplo n.º 4
0
from main import Process, inputFunction
import sys

processes = inputFunction()
print("The entered Information is provided below:")
Process.print_array(processes)

flag = input("Is it correct [Y/N]: ").lower()
if flag == 'n':
    sys.exit("Wrong Input!")

print("\n<--------------- Implementing FCFS --------------->\n")
processes = Process.sort_processes(processes, 'arrivalTime')
end_time_last = 0

for proc in processes:
    if proc.arrivalTime >= end_time_last:
        proc.waitingTime = 0
        proc.startTime = proc.arrivalTime
        proc.endTime = proc.arrivalTime + proc.burstTime
    else:
        proc.waitingTime = end_time_last - proc.arrivalTime
        proc.endTime = end_time_last + proc.burstTime
        proc.startTime = end_time_last

    end_time_last = proc.endTime
    proc.leftovers = 0

Process.print_proc_with_leftover(processes)
print(
    f'Hence the average waiting time is {Process.avg_waiting_time_FCFS(processes):.2f}'
Ejemplo n.º 5
0
from main import Process
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

data = pd.read_csv('E:/Janestreet_data/train.csv',
                   usecols=['date', 'weight', 'resp'])
df = pd.DataFrame()
for p in np.arange(0, 0.005, 0.001):
    ProcessedData = Process(data).pDist(p)
    df = df.append(ProcessedData, ignore_index=True)
df = df.set_index(['p'])
df[[c for c in df.columns if 'count' in c]].plot.bar(rot=0)
plt.show()
df[[c for c in df.columns if 'respmean' in c]].plot(style='o')
plt.show()
from main import Process, inputFunction
import copy

processes = inputFunction()

processes = Process.sort_processes(processes, 'arrivalTime')
timeDelta = float(input("Enter the time frame: "))
current_time = processes[0].arrivalTime
process_execution_order = []

ready_queue = []

while True:

    new_processes = [proc for proc in processes if proc.arrivalTime <= current_time and proc not in ready_queue]
    ready_queue = new_processes + ready_queue

    # end of all process ...
    if len(ready_queue) == 0 and len(processes) == 0:
        break

    # Dealing with cases where cpu is in rest condition ...
    if len(ready_queue) == 0:
        current_time = Process.sort_processes(processes, 'arrivalTime')[0].arrivalTime
        continue

    # Dealing with general case ...
    for process in ready_queue:
        if process.leftovers <= timeDelta:
            process.startTime = current_time
            current_time += process.leftovers
Ejemplo n.º 7
0
from main import Process, inputFunction
import sys

processes = inputFunction()

print("The entered Information is provided below:")
Process.print_array(processes)

flag = input("Is input correct [Y/N]: ").lower()
if flag == 'n':
    sys.exit("Wrong Input!")

print("<--------------------------------------------->")

choice = input("Preemptive or Non-Preemptive[P/N]: ").lower()
processes = Process.sort_processes(processes, 'arrivalTime')
last_end_time = processes[0].arrivalTime
ordered_sjf = []

if choice == 'n':
    print("Performing Non - Preemptive SJF\n")
    print("The processes in the order of execution is provided below:")
    while True:
        if len(processes) == 0:
            break
        else:
            jobs_arrived_initially = [
                proc for proc in processes if proc.arrivalTime <= last_end_time
            ]

            if len(jobs_arrived_initially) == 0: