Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/9/2015COSC-4301-01, Lecture 51 Real-Time Systems, COSC-4301-01, Lecture 5 Stefan Andrei.

Similar presentations


Presentation on theme: "10/9/2015COSC-4301-01, Lecture 51 Real-Time Systems, COSC-4301-01, Lecture 5 Stefan Andrei."— Presentation transcript:

1 10/9/2015COSC-4301-01, Lecture 51 Real-Time Systems, COSC-4301-01, Lecture 5 Stefan Andrei

2 10/9/2015 COSC-4301-01, Lecture 5 2 Reminder of the last lecture Multiprocessor Scheduling Available scheduling tools Available real-time operating systems

3 10/9/2015 COSC-4301-01, Lecture 5 3 Overview of This Lecture A Satisfiability Approach for the Scheduling Problem

4 10/9/2015 COSC-4301-01, Lecture 5 4 Introduction Most of the existing scheduling problems are NP-hard. Researchers have been putting many efforts in finding good heuristics for solving scheduling problem in polynomial time. However, there still exist classes of task sets that are feasible and most traditional schedulers (e.g. RM, EDF, LL) fail to solve the scheduling problem. Existing SAT encodings could not be adopted for the given scheduling problem.

5 10/9/2015 COSC-4301-01, Lecture 5 5 The main idea We present a new satisfiability (SAT) based approach to the scheduling problem. We transform time constraints into a satisfiability problem. The obtained clauses are converted to the DIMACS format and passed as input to a SAT solver, such as Zchaff. We conclude that our satisfiability-based approach is a promising technique for scheduling.

6 10/9/2015 COSC-4301-01, Lecture 5 6 Related work At first glance it seems to be an obvious translation of scheduling problems into SAT:  Create variables to represent the start times of the operations and create clauses to represent the necessary inequalities.  However the search space in SAT problems so generated turns out to be much larger than necessary.  Previous SAT encodings approaches like those expressed in [Memik, Fallah; 2002] and [Crawford, Baker; 1994] could not be applied either because they do not consider the exact time relations [Crawford, Baker; 1994] or they are too large [Memik, Fallah; 2002].

7 10/9/2015 COSC-4301-01, Lecture 5 7 References [Memik, Fallah; 2002] S.O.Memik, F.Fallah: “Accelerated SAT-based scheduling of control/data flow graphs”, Computer Design: VLSI in Computers and processors, 2002. Proceedings, 2002 [Crawford, Baker; 1994] J.M.Crawford, A.B.Baker: Experimental Results on the Application of Satisfiability Algorithms to Scheduling Problems, The 12th National Conference on Artificial Intelligence, 1994.

8 10/9/2015 COSC-4301-01, Lecture 5 8 Scheduling A task T is characterized by the following parameters:  S: start (also called release, ready, or arrival) time.  c: (maximum) computation time.  d: relative deadline (deadline relative to the task's start time)  p: period (how often the tasks are supposed to be executed)  D: absolute deadline (wall clock time deadline) e.g., D = S + d.

9 10/9/2015 COSC-4301-01, Lecture 5 9 The propositional satisfiability problem The SAT problem: “Given a set of clauses C (disjunction of literals – also known as CNF: Conjunctive Normal Form) on a finite set U of variables, find a truth assignment for U that satisfies all the clauses in C”. The SAT problem is solved by the SAT solvers. Example: Given U = {A, B, C} the set of variables and F = (A   B    C)  (        C)  (       C  a propositional formula, then a truth assignment for F is A = false, B = false, C = false.

10 10/9/2015 COSC-4301-01, Lecture 5 10 Encoding Scheduling problems as SAT problems For each operation i executing between time t and t+1 there exists a boolean variable e i,t. We have considered this encoding for solving many types of problems which are elaborated as follows, such as:  Scheduling unit computation tasks in uniprocessor environment  Scheduling preemptive non-unit tasks for uniprocessor environment  Scheduling non-preemptive tasks in uniprocessor environment

11 10/9/2015 COSC-4301-01, Lecture 5 11 Scheduling unit computation tasks in uniprocessor environment Consider T={T 1,.., T n } a task set with T i = (S i, c i, d i, p i ). For simplicity, we assume p i =d i. If task T i can execute one time unit between times t, t+1, …, t+c i, then the corresponding SAT clause is e i,t V e i,t+1 V... V e i,t+ci-2 V e i,t+ci-1. Given tasks T i and T j for time between t and t+1, only either T i or T j is executing between t and t+1. Hence, there exists a clause  e i,t V  e j,t (this is equivalent to: e i,t   e j,t and e j,t   e i,t ). The SAT encoding has to be done from 0 to LCM(p 1, p 2, …, p n ).

12 Scheduling unit computation tasks in uniprocessor environment. Example T 1 : s 1 = 0, c 1 = 1, d 1 = p 1 = 2 T 2 : s 2 = 0, c 2 = 1, d 2 = p 2 = 3 The SAT encoding has to be done by LCM(d 1, d 2 ), that is, 6:  e 1,0 V e 1,1  e 1,2 V e 1,3  e 1,4 V e 1,5  e 2,0 V e 2,1 V e 2,2  e 2,3 V e 2,4 V e 2,5 10/9/2015 COSC-4301-01, Lecture 5 12   e 1,0 V  e 2,0   e 1,1 V  e 2,1   e 1,2 V  e 2,2   e 1,3 V  e 2,3   e 1,4 V  e 2,4   e 1,5 V  e 2,5

13 10/9/2015 COSC-4301-01, Lecture 5 13 Scheduling preemptive non-unit tasks for uniprocessor environment Solution:  Divide each non unit-time task into tasks with unit computation time, then apply the previous SAT encoding.  The starting time and deadline for the subsequent tasks are incremented.  Precedence constraints are introduces between the sub-tasks created.  Consider sub-task j with less precedence than sub- task i then at any time t, sub-task i will not occur after sub-task j is executing, that is,  e j,t V  e i,z where z > t.

14 Scheduling preemptive non-unit tasks for uniprocessor environment. Example T 1 : s 1 = 0, c 1 = 2, d 1 = p 1 = 4 T 2 : s 2 = 0, c 2 = 2, d 2 = p 2 = 4 The task set is converted to unit computation time:  T 1 =T 1,1 : s 1,1 = 0, c 1,1 = 1, d 1,1 = 3, p 1,1 = 4  T 2 =T 1,2 : s 1,2 = 1, c 1,2 = 1, d 1,2 = 4, p 1,2 = 4  T 3 =T 2,1 : s 2,1 = 0, c 2,1 = 1, d 2,1 = 3, p 2,1 = 4  T 4 =T 2,2 : s 2,2 = 1, c 2,2 = 1, d 2,2 = 4, p 2,2 = 4  The precedence constraints: T 1  T 2, T 3  T 4 10/9/2015 COSC-4301-01, Lecture 5 14

15 Scheduling preemptive non-unit tasks for uniprocessor environment. Example  e 1,0 V e 1,1 V e 1,2  e 2,1 V e 2,2 V e 2,3  e 3,0 V e 3,1 V e 3,2  e 4,1 V e 4,2 V e 4,3   e 1,0 V  e 3,0   e 1,1 V  e 2,1   e 1,1 V  e 3,1 10/9/2015 COSC-4301-01, Lecture 5 15   e 1,1 V  e 4,1   e 1,2 V  e 2,2   e 1,2 V  e 3,2   e 1,2 V  e 4,2  d 1 = 3   e 1,3  s 2 = 1   e 2,0  d 3 = 3   e 3,3  s 4 = 1   e 4,0

16 10/9/2015 COSC-4301-01, Lecture 5 16  The precedence constraints:   e 2,1 V  e 1,2   e 4,1 V  e 3,2

17 10/9/2015 COSC-4301-01, Lecture 5 17 Scheduling non-preemptive tasks in uniprocessor environment A non-preemptable task is the one that once started cannot be stopped by any other process or task. In practice tasks may contain critical sections that cannot be interrupted. These critical sections are needed to access and modify shared variables or use shared resources. The non-preemptable condition can be obtained by grouping together executing constraints from starting time to deadline with size equal to that of computation time.

18 10/9/2015 COSC-4301-01, Lecture 5 18 Scheduling with non-preemption for uniprocessor environment - cont So, a non-preemptable task i is allowed to execute for a computation time c starting at time t until deadline d. Since a non-preemptive task T=(s, c, d, p) cannot not be interrupted, the conversion to the SAT problem should contain all possible solutions for task T to be scheduled in the intervals [s, c], [s + 1,c + 1],..., [d - c, d].

19 10/9/2015 COSC-4301-01, Lecture 5 19 Example with two non-preemptive tasks T 1 : s 1 = 0, c 1 = 2, d 1 = 4 T 2 : s 2 = 0, c 2 = 2, d 2 = 4 The SAT encoding is:  T 1 : (e 1,0 Λ e 1,1 Λ  e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ e 1,1 Λ e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 )  T 2 : (e 2,0 Λ e 2,1 Λ  e 2,2 Λ  e 2,3 ) V  (  e 1,0 Λ e 2,1 Λ e 1,2 Λ  e 2,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 )

20 10/9/2015 COSC-4301-01, Lecture 5 20 Example with two non-preemptive tasks The following are the clauses corresponding to the fact that the processor is busy with at most one task at a given time:   e 1,0 V  e 2,0   e 1,1 V  e 2,1   e 1,2 V  e 2,2   e 1,3 V  e 2,3 Problem: the sub-formula from previous slide is not expressed in CNF, but in DNF (Disjunctive Normal Form).

21 10/9/2015 COSC-4301-01, Lecture 5 21 DNF to CNF conversion Some the above clauses are in Disjunctive Normal Form (DNF). They have to be converted into Conjunctive Normal Form (CNF). Once the whole formula is expressed in CNF, it has to be converted into DIMACS format as an input for SAT solvers.

22 DNF to CNF conversion. Example New variables are introduced for each clause. Example: F = (A 1  A 2  A 3  A 4 )  (A 5  A 6  A 7  A 8 ) is converted to the following CNF formula (X 1 and X 2 are new propositional variables):  (  X 1  A 1 )  (  X 1  A 2 )  (  X 1  A 3 )  (  X 1  A 4 )  (  A 1   A 2   A 3   A 4  X 1 )  (  X 2  A 5 )  (  X 2  A 6 )  (  X 2  A 7 )  (  X 2  A 8 )  (  A 5   A 6   A 7   A 8  X 2 )  X 1  X 2 10/9/2015 COSC-4301-01, Lecture 5 22

23 Complexity of this translation The traditional approach for converting a general DNF formula needs an exponential space and time complexity:  (A 1,1  A 1,2  …  A 1,n1 )  …  (A k,1  A k,2  …  A k,nk ) leads to a propositional formula with n 1 * … * n k CNF clauses. The approach from previous slide needs only n 1 + … + n k + k + 1 CNF clauses and k new propositional clauses. 10/9/2015 COSC-4301-01, Lecture 5 23

24 DNF to CNF conversion. Example Coming back to the example from slide 18:  T 1 : (e 1,0 Λ e 1,1 Λ  e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ e 1,1 Λ e 1,2 Λ  e 1,3 ) V  (  e 1,0 Λ  e 1,1 Λ e 1,2 Λ e 1,3 ) we get the following CNF formula:  (  X 1  e 1,0 )  (  X 1  e 1,1 )  (  X 1   e 1,2 )  (  X 1   e 1,3 )  (  e 1,0   e 1,1  e 1,2  e 1,3  X 1 )  (  X 1   e 1,0 )  (  X 1  e 1,1 )  (  X 1  e 1,2 )  (  X 1   e 1,3 )  (e 1,0   e 1,1   e 1,2  e 1,3  X 1 )  (  X 1   e 1,0 )  (  X 1   e 1,1 )  (  X 1  e 1,2 )  (  X 1  e 1,3 )  (e 1,0  e 1,1   e 1,2   e 1,3  X 1 )  X 1  X 2  X 3 10/9/2015 COSC-4301-01, Lecture 5 24

25 10/9/2015 COSC-4301-01, Lecture 5 25 Some state-of-the-art SAT solvers Siege - http://www.cs.sfu.ca/research/groups/CL/software/siege/http://www.cs.sfu.ca/research/groups/CL/software/siege/ zChaff - http://www.princeton.edu/~chaff/software.htmlhttp://www.princeton.edu/~chaff/software.html Cachet - http://www.cs.rochester.edu/u/kautz/Cachet/index.htmhttp://www.cs.rochester.edu/u/kautz/Cachet/index.htm SharpSAT - http://www2.informatik.hu- berlin.de/~thurley/sharpSAT/index.htmlhttp://www2.informatik.hu- berlin.de/~thurley/sharpSAT/index.html Others: http://www.satlive.org/bytype.jsp?reftypefrom=-2http://www.satlive.org/bytype.jsp?reftypefrom=-2 If the answer provided by this SAT solver or #SAT solver is ‘Unsatisfiable’, then the corresponding propositional formula is unsatisfiable.

26 10/9/2015 COSC-4301-01, Lecture 5 26 The zChaff SAT Solver It is a state-of-the-art SAT solver designed for robustness and efficiency. It features a highly optimized deduction engine. zChaff is designed with performance and capacity in mind. zChaff has been tested on Solaris/Linux/Cygwin machines with g++ as the compiler. It can also be compiled with Visual Studio Net under Windows. zChaff can be compiled into a linkable library for integration purpose so that the users do not need to export instance into intermediate files to use zChaff.

27 10/9/2015 COSC-4301-01, Lecture 5 27 DIMACS CNF Format In the format the number of variables and the number of clauses is defined by the line “p cnf VARIABLES CLAUSES”. The variables are assumed to be numbered from 1 up to VARIABLES. It is not necessary that every variable appears in an instance. Each clause will be represented by a sequence of integers, which are separated by a space, a tab, or a new line character. The non-negated version of the variable i is represented by i; the negated version is represented by -i. Each clause is terminated by a value 0.

28 10/9/2015 COSC-4301-01, Lecture 5 28 Example The boolean formula F = (v 1 V  v 3 ) Λ (  v 1 V v 2 V v 3 ) has the following DIMACS format: p cnf 3 2 1 -3 0 2 3 -1 0

29 10/9/2015 COSC-4301-01, Lecture 5 29 Tool Description The input of our tool is the number of tasks which are to be scheduled. For each of the tasks it asks for its starting time, computation time and deadline. It develops various clauses using the SAT encoding described in above part. Based on the encoding it passes the DIMACS CNF format file to zChaff SAT Solver which gives whether it is either SAT solvable or not. The output of zChaff also gives the variables which are true, using this variables we can schedule the tasks.

30 10/9/2015 COSC-4301-01, Lecture 5 30 Running the Code Compile the zChaff code obtained from the Internet using the make command in C++ compiler and keep it inside a folder zchaff. Inside the zchaff folder create a folder called Translate. Add all the Java source code in this folder. Compile the java source code using javac *.java in J2SE. Then run the Main class file from zchaff folder using java Translate/Main

31 10/9/2015 COSC-4301-01, Lecture 5 31 Experimental Results

32 10/9/2015 COSC-4301-01, Lecture 5 32 The experimental results - comments The number of tasks in the original column are converted into unit computation time tasks and thus increasing the number of tasks in the for preemption column. The increase in the number of tasks increases the size of SAT and thus affects the performance of the SAT solver. It can be seen from the above results that the performance is faster if there are fewer tasks.

33 10/9/2015 COSC-4301-01, Lecture 5 33 Conclusion We have explored the potential of satisfiability to be used as a tool for modeling and solving scheduling problems. We have also researched on the earlier work and proven that we need to consider computation time so as to make it suitable for real time systems. We have presented experimental results on the performance of SAT solver zChaff. The performance of the SAT decreases as the number of tasks increases. We have demonstrated that a SAT solver presents a competitive alternative as a tool to find optimal solutions to the NP-complete time constrained scheduling problem.

34 10/9/2015 COSC-4301-01, Lecture 5 34 Future work We would like to consider the other categories of tasks set constraints. Also adding resourses constraints would make the system more suitable for real time systems. Minimize the number of preemptions (selects the solution provided by the SAT solver that has the minimum number of preemptions). Assuming there are new tasks added to the initial specification, design an incremental conversion to SAT without repeating the time spend for the initial tasks set).

35 10/9/2015 COSC-4301-01, Lecture 5 35 Summary A Satisfiability Approach for the Scheduling Problem

36 10/9/2015 COSC-4301-01, Lecture 5 36 Reading suggestions Research papers  Ştefan Andrei: Schedulability Analysis

37 10/9/2015 COSC-4301-01, Lecture 5 37 Coming up next An Efficient Power-Aware Scheduling Algorithm for the Multiprocessor Platform

38 10/9/2015 COSC-4301-01, Lecture 5 38 Thank you for your attention! Questions?


Download ppt "10/9/2015COSC-4301-01, Lecture 51 Real-Time Systems, COSC-4301-01, Lecture 5 Stefan Andrei."

Similar presentations


Ads by Google