public void TestRule4Negative() { // Egy adott színhez tartozó feladatokat a beadás sorrendjében kell végrehajtani. log.Add(new TaskLogEntry(blueTask2, START, thread1, null)); log.Add(new TaskLogEntry(blueTask2, FINISH, thread1, null)); log.Add(new TaskLogEntry(blueTask1, START, thread1, null)); log.Add(new TaskLogEntry(blueTask1, FINISH, thread1, null)); Assert.False(ScheduleValidator.IsValid(log)); }
public void TestRule3Negative() { // Az egész rendszerben egy adott színű feladatból egy időben csak egy lehet végrehajtás alatt. log.Add(new TaskLogEntry(blueTask1, START, thread1, null)); log.Add(new TaskLogEntry(blueTask2, START, thread2, null)); log.Add(new TaskLogEntry(blueTask1, FINISH, thread1, null)); log.Add(new TaskLogEntry(blueTask2, FINISH, thread2, null)); Assert.False(ScheduleValidator.IsValid(log)); }
public void TestRule2Negative() { // Ha a feladat végrehajtása valamilyen okból meghiúsul (pl. a végrehajtó szál elesik), a feladatot vissza kell tenni a végrehajtási sorba. log.Add(new TaskLogEntry(blueTask1, START, thread1, null)); log.Add(new TaskLogEntry(blueTask1, FAIL, thread1, null)); log.Add(new TaskLogEntry(redTask1, START, thread1, null)); log.Add(new TaskLogEntry(redTask1, FINISH, thread1, null)); Assert.False(ScheduleValidator.IsValid(log)); }
public void TestRule1Negative() { // Egy feladatot csak egy végrehajtónak szabad kiadni. log.Add(new TaskLogEntry(blueTask1, START, thread1, null)); log.Add(new TaskLogEntry(blueTask1, START, thread2, null)); log.Add(new TaskLogEntry(blueTask1, FINISH, thread1, null)); log.Add(new TaskLogEntry(blueTask1, FINISH, thread2, null)); Assert.False(ScheduleValidator.IsValid(log)); }
public static void Main() { Console.Write("How many consumer threads do you want? "); string input = Console.ReadLine(); Console.WriteLine(); if (!Int32.TryParse(input, out nConsumerThreads)) { nConsumerThreads = -1; } if (nConsumerThreads < 1) { Console.WriteLine("Your input was invalid, going with 10x threads"); nConsumerThreads = 10; } Console.WriteLine($"Starting {nConsumerThreads}x consumer threads..."); scheduler.StartConsumerThreads(nConsumerThreads); Console.WriteLine("Starting 1x producer thread..."); var producer = new Thread(Producer); producer.Name = "ProducerThread"; producer.Start(); Console.WriteLine($"Let the scheduler run for {runSeconds} seconds, while feeding it with random tasks..."); Console.WriteLine($"(with random colors out of {nColors}x)"); Thread.Sleep(runSeconds * 1000); Console.WriteLine("Stopping the scheduler..."); producerRunning = false; scheduler.AbortAndJoinConsumerThreads(); int finishedTaskCount = scheduler.FinishedTaskCount; double tasksPerSec = (double)finishedTaskCount / runSeconds; Console.WriteLine($"The scheduler has eaten {finishedTaskCount}x tasks! ({tasksPerSec} tasks/sec)"); Console.WriteLine("Checking if the scheduler has scheduled according to the rules..."); bool valid = ScheduleValidator.IsValid(log); if (valid) { Console.WriteLine("The schedule was valid! :)"); } else { Console.WriteLine("The schedule was bad!!!! :("); } }