def test_sem_lock_and_sched_np(self): self.oheads(sched=True) self.no_reads() self.assertIs(locking.charge_semaphore_overheads(self.o, False, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() ecost = 2 * 17 + 2 * 19 + 3 + 5 + 3 * 27 + 3 * 31 + 2 * 41 + 23 xcost = 1 * 27 + 1 * 31 + 17 + 19 + 5 + 23 xcost_local = xcost + 27 + 31 # additional scheduler invocation self.assertEqual(self.ts[0].cost, 10000 + 6 * ecost) self.assertEqual(self.ts[1].cost, 5000 + 4 * ecost) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[0].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + xcost) self.assertEqual(self.ts[1].resmodel[0].max_write_length_local, 17 + xcost_local) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_write_length_local, 11 + xcost_local)
def test_sem_lock_only(self): self.oheads() self.no_reads() self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() scost = 17 + 19 xcost = 3 + 5 ocost = 5 self.assertEqual(self.ts[0].cost, 10000 + 6 * xcost + 12 * scost) self.assertEqual(self.ts[1].cost, 5000 + 4 * xcost + 8 * scost) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + scost + ocost) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + scost + ocost) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + scost + ocost)
def test_sem_lock_and_sched_saw(self): self.oheads(sched=True) self.no_reads() self.init_susp() self.assertIs(locking.charge_semaphore_overheads(self.o, True, True, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() ecost = 2 * 17 + 2 * 19 + 3 + 5 + 3 * 27 + 3 * 31 + 2 * 41 xcost = 2 * 27 + 2 * 31 + 17 + 19 + 5 + 23 esusp = 23 self.assertEqual(self.ts[0].cost, 10000 + 6 * ecost) self.assertEqual(self.ts[1].cost, 5000 + 4 * ecost) self.assertEqual(self.ts[0].suspended, 6 * esusp) self.assertEqual(self.ts[1].suspended, 4 * esusp) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + xcost)
def test_sem_none(self): self.assertIs(locking.charge_semaphore_overheads(None, True, True, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.unchanged_cost() self.not_lossy() self.unchanged_resmodel()
def test_sem_lock_and_sched_saw(self): self.oheads(sched=True) self.no_reads() self.init_susp() self.assertIs( locking.charge_semaphore_overheads(self.o, True, True, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() ecost = 2 * 17 + 2 * 19 + 3 + 5 + 3 * 27 + 3 * 31 + 2 * 41 xcost = 2 * 27 + 2 * 31 + 17 + 19 + 5 + 23 esusp = 23 self.assertEqual(self.ts[0].cost, 10000 + 6 * ecost) self.assertEqual(self.ts[1].cost, 5000 + 4 * ecost) self.assertEqual(self.ts[0].suspended, 6 * esusp) self.assertEqual(self.ts[1].suspended, 4 * esusp) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + xcost) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + xcost)
def test_sem_integral(self): self.no_reads() self.o.unlock = const(1.75) self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def test_sem_zero(self): self.no_reads() self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.unchanged_cost() self.not_lossy_no_reads() self.unchanged_resmodel_no_reads()
def test_sem_none(self): self.assertIs( locking.charge_semaphore_overheads(None, True, True, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.unchanged_cost() self.not_lossy() self.unchanged_resmodel()
def test_sem_zero(self): self.no_reads() self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.unchanged_cost() self.not_lossy_no_reads() self.unchanged_resmodel_no_reads()
def test_sem_lock_and_sched_np(self): self.oheads(sched=True) self.no_reads() self.assertIs( locking.charge_semaphore_overheads(self.o, False, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() ecost = 2 * 17 + 2 * 19 + 3 + 5 + 3 * 27 + 3 * 31 + 2 * 41 + 23 xcost = 1 * 27 + 1 * 31 + 17 + 19 + 5 + 23 xcost_local = xcost + 27 + 31 # additional scheduler invocation self.assertEqual(self.ts[0].cost, 10000 + 6 * ecost) self.assertEqual(self.ts[1].cost, 5000 + 4 * ecost) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[0].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + xcost) self.assertEqual(self.ts[1].resmodel[0].max_write_length_local, 17 + xcost_local) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[1].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_write_length_local, 11 + xcost_local) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + xcost) self.assertEqual(self.ts[0].resmodel[2].max_write_length_local, 11 + xcost_local)
def test_sem_lock_only(self): self.oheads() self.no_reads() self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.unchanged_period() self.unchanged_deadline() self.not_lossy_no_reads() scost = 17 + 19 xcost = 3 + 5 ocost = 5 self.assertEqual(self.ts[0].cost, 10000 + 6 * xcost + 12 * scost) self.assertEqual(self.ts[1].cost, 5000 + 4 * xcost + 8 * scost) self.assertEqual(self.ts[0].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[0].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[0].max_write_length, 17 + scost + ocost) self.assertEqual(self.ts[0].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[1].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[1].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[1].max_write_length, 17 + scost + ocost) self.assertEqual(self.ts[0].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[0].resmodel[2].max_write_length, 11 + scost + ocost) self.assertEqual(self.ts[1].resmodel[2].max_read_length, 0) self.assertEqual(self.ts[1].resmodel[2].max_write_length, 17 + scost + ocost)
def test_sem_integral(self): self.no_reads() self.o.unlock = const(1.75) self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), self.ts) self.assertEqual(self.ts[0].resmodel[0].max_write_length, 11 + 2)
def test_sem_infeasible(self): self.no_reads() self.o.syscall_in = const(10000000) self.assertIs(locking.charge_semaphore_overheads(self.o, True, False, self.ts), False)
def test_sem_infeasible(self): self.no_reads() self.o.syscall_in = const(10000000) self.assertIs( locking.charge_semaphore_overheads(self.o, True, False, self.ts), False)