public void TaskBlockingByResource()
        {
            var taskSet = new List <Task>
            {
                new Task {
                    ExecutionTime = 2, Period = 5, Id = "A", StaticPriority = 5
                },
                new Task {
                    ExecutionTime = 4, Period = 20, Id = "B", StaticPriority = 4
                },
                new Task {
                    ExecutionTime = 4, Period = 20, Id = "C", StaticPriority = 3
                },
                new Task {
                    ExecutionTime = 5, Period = 200, Id = "D", StaticPriority = 2
                },
                new Task {
                    ExecutionTime = 5, Period = 200, Id = "E", StaticPriority = 1
                }
            };

            var resources = new List <Resource>();

            var X = new Resource
            {
                Name  = "X",
                tasks = new List <TaskUsingResource>
                {
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "B"),
                        UsageTime = 2
                    },
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "D"),
                        UsageTime = 3
                    },
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "E"),
                        UsageTime = 1
                    }
                }
            };

            var Y = new Resource
            {
                Name  = "Y",
                tasks = new List <TaskUsingResource>
                {
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "C"),
                        UsageTime = 4
                    }
                }
            };

            var Z = new Resource
            {
                Name  = "Z",
                tasks = new List <TaskUsingResource>
                {
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "D"),
                        UsageTime = 1
                    },
                    new TaskUsingResource
                    {
                        Task      = taskSet.Find(o => o.Id == "E"),
                        UsageTime = 2
                    }
                }
            };

            resources.Add(X);
            resources.Add(Y);
            resources.Add(Z);

            SystemWithSharedResources s = new SystemWithSharedResources
            {
                Tasks     = taskSet,
                Resources = resources
            };

            foreach (var task in taskSet)
            {
                var blockingTimeNCPS = s.BlockingTimeOnAResourceNCPS(task);
                task.BlockingTime = blockingTimeNCPS;
            }
            ResponseTimeAnalysis.WorstCaseStartTimeAnalysis(taskSet);
            ResponseTimeAnalysis.WorstCaseFinishTime(taskSet);
            ResponseTimeAnalysis.WorstCaseResponseTimeAnalysis(taskSet);

            foreach (var task in taskSet)
            {
                var blockingTimeNCPS = s.BlockingTimeOnAResourcePriorityCeiling(task);
                task.BlockingTime = blockingTimeNCPS;
            }
            ResponseTimeAnalysis.WorstCaseStartTimeAnalysis(taskSet);
            ResponseTimeAnalysis.WorstCaseFinishTime(taskSet);
            ResponseTimeAnalysis.WorstCaseResponseTimeAnalysis(taskSet);
            var i = 0;
        }
        public void Test_BlockingTime2()
        {
            var taskSet = new List <Task>
            {
                new Task {
                    ExecutionTime = 5, Period = 50, Id = "1", Deadline = 15, StaticPriority = 9, DynamicPriority = 9
                },
                new Task {
                    ExecutionTime = 5, Period = 60, Id = "2", Deadline = 25, StaticPriority = 8, DynamicPriority = 8
                },
                new Task {
                    ExecutionTime = 7, Period = 80, Id = "3", Deadline = 30, StaticPriority = 7, DynamicPriority = 7
                },
                new Task {
                    ExecutionTime = 7, Period = 200, Id = "4", Deadline = 40, StaticPriority = 6, DynamicPriority = 6
                },
                new Task {
                    ExecutionTime = 10, Period = 200, Id = "5", Deadline = 50, StaticPriority = 5, DynamicPriority = 5
                },
                new Task {
                    ExecutionTime = 8, Period = 200, Id = "6", Deadline = 60, StaticPriority = 4, DynamicPriority = 4
                },
                new Task {
                    ExecutionTime = 12, Period = 220, Id = "7", Deadline = 70, StaticPriority = 3, DynamicPriority = 8
                },
                new Task {
                    ExecutionTime = 10, Period = 230, Id = "8", Deadline = 70, StaticPriority = 2, DynamicPriority = 8
                },
                new Task {
                    ExecutionTime = 15, Period = 240, Id = "9", Deadline = 100, StaticPriority = 1, DynamicPriority = 1
                }
            };

            taskSet.ForEach(o => o.CalcUtilization());

            ResponseTimeAnalysis.BlockingTime(taskSet);

            Assert.Equal(taskSet.Single(o => o.Id == "1").BlockingTime, 0);
            Assert.Equal(taskSet.Single(o => o.Id == "2").BlockingTime, 12);
            Assert.Equal(taskSet.Single(o => o.Id == "3").BlockingTime, 12);
            Assert.Equal(taskSet.Single(o => o.Id == "4").BlockingTime, 12);
            Assert.Equal(taskSet.Single(o => o.Id == "5").BlockingTime, 12);
            Assert.Equal(taskSet.Single(o => o.Id == "6").BlockingTime, 12);
            Assert.Equal(taskSet.Single(o => o.Id == "7").BlockingTime, 10);
            Assert.Equal(taskSet.Single(o => o.Id == "8").BlockingTime, 0);
            Assert.Equal(taskSet.Single(o => o.Id == "9").BlockingTime, 0);

            ResponseTimeAnalysis.WorstCaseStartTimeAnalysis(taskSet);

            Assert.Equal(taskSet.Single(o => o.Id == "1").StartTimeWorstCase, 0);
            Assert.Equal(taskSet.Single(o => o.Id == "2").StartTimeWorstCase, 17);
            Assert.Equal(taskSet.Single(o => o.Id == "3").StartTimeWorstCase, 22);
            Assert.Equal(taskSet.Single(o => o.Id == "4").StartTimeWorstCase, 29);
            Assert.Equal(taskSet.Single(o => o.Id == "5").StartTimeWorstCase, 36);
            Assert.Equal(taskSet.Single(o => o.Id == "6").StartTimeWorstCase, 46);
            Assert.Equal(taskSet.Single(o => o.Id == "7").StartTimeWorstCase, 57);
            Assert.Equal(taskSet.Single(o => o.Id == "8").StartTimeWorstCase, 59);
            Assert.Equal(taskSet.Single(o => o.Id == "9").StartTimeWorstCase, 74);

            ResponseTimeAnalysis.WorstCaseFinishTime(taskSet);
            Assert.Equal(taskSet.Single(o => o.Id == "1").FinishTimeWorstCase, 5);
            Assert.Equal(taskSet.Single(o => o.Id == "2").FinishTimeWorstCase, 22);
            Assert.Equal(taskSet.Single(o => o.Id == "3").FinishTimeWorstCase, 29);
            Assert.Equal(taskSet.Single(o => o.Id == "4").FinishTimeWorstCase, 36);
            Assert.Equal(taskSet.Single(o => o.Id == "5").FinishTimeWorstCase, 46);
            Assert.Equal(taskSet.Single(o => o.Id == "6").FinishTimeWorstCase, 59);
            Assert.Equal(taskSet.Single(o => o.Id == "7").FinishTimeWorstCase, 69);
            Assert.Equal(taskSet.Single(o => o.Id == "8").FinishTimeWorstCase, 69);
            Assert.Equal(taskSet.Single(o => o.Id == "9").FinishTimeWorstCase, 96);

            ResponseTimeAnalysis.WorstCaseResponseTimeAnalysis(taskSet);

            Assert.Equal(taskSet.Single(o => o.Id == "1").WorstCaseRunTime, 5);
            Assert.Equal(taskSet.Single(o => o.Id == "2").WorstCaseRunTime, 22);
            Assert.Equal(taskSet.Single(o => o.Id == "3").WorstCaseRunTime, 29);
            Assert.Equal(taskSet.Single(o => o.Id == "4").WorstCaseRunTime, 36);
            Assert.Equal(taskSet.Single(o => o.Id == "5").WorstCaseRunTime, 46);
            Assert.Equal(taskSet.Single(o => o.Id == "6").WorstCaseRunTime, 59);
            Assert.Equal(taskSet.Single(o => o.Id == "7").WorstCaseRunTime, 69);
            Assert.Equal(taskSet.Single(o => o.Id == "8").WorstCaseRunTime, 69);
            Assert.Equal(taskSet.Single(o => o.Id == "9").WorstCaseRunTime, 96);
        }