<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JSEA</journal-id><journal-title-group><journal-title>Journal of Software Engineering and Applications</journal-title></journal-title-group><issn pub-type="epub">1945-3116</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jsea.2016.95015</article-id><article-id pub-id-type="publisher-id">JSEA-66661</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject></subj-group></article-categories><title-group><article-title>
 
 
  A Generic Graph Model for WCET Analysis of Multi-Core Concurrent Applications
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>obert</surname><given-names>Mittermayr</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Johann</surname><given-names>Blieberger</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Institute of Computer Aided Automation, TU Vienna, Vienna, Austria</addr-line></aff><pub-date pub-type="epub"><day>11</day><month>05</month><year>2016</year></pub-date><volume>09</volume><issue>05</issue><fpage>182</fpage><lpage>198</lpage><history><date date-type="received"><day>29</day>	<month>March</month>	<year>2016</year></date><date date-type="rev-recd"><day>accepted</day>	<month>20</month>	<year>May</year>	</date><date date-type="accepted"><day>23</day>	<month>May</month>	<year>2016</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Worst-case execution time (WCET) analysis of multi-threaded software is still a challenge. This comes mainly from the fact that synchronization has to be taken into account. In this paper, we focus on this issue and on automatically calculating and incorporating stalling times (e.g. caused by lock contention) in a generic graph model. The idea that thread interleavings can be studied with a matrix calculus is novel in this research area. Our sparse matrix representations of the program are manipulated using an extended Kronecker algebra. The resulting graph represents multi-threaded programs similar as CFGs do for sequential programs. With this graph model, we are able to calculate the WCET of multi-threaded concurrent programs including stalling times which are due to synchronization. We employ a generating function-based approach for setting up data flow equations which are solved by well-known elimination-based dataflow analysis methods or an off-the-shelf equation solver. The WCET of multi-threaded programs can finally be calculated with a non-linear function solver.
 
</p></abstract><kwd-group><kwd>Worst-Case Execution Time Analysis</kwd><kwd> Program Analysis; Concurrency</kwd><kwd> Multi-Threaded Programs</kwd><kwd> Kronecker Algebra</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>It is widely agreed that the problem of determining upper bounds on execution times for sequential programs has been more or less solved [<xref ref-type="bibr" rid="scirp.66661-ref1">1</xref>] . With the advent of multi-core processors scientific and industrial interest focuses on analysis and verification of multi-threaded applications. The scientific challenge comes from the fact that synchronization has to be taken into account. In this paper, we focus on how to incorporate stalling times in a WCET analysis of shared memory concurrent programs running on a multi-core architecture. The stress is on a formal definition and description of both, our graph model and the dataflow equations for timing analysis.</p><p>We allow communication between threads in multiple ways e.g. via shared memory accesses protected by critical sections. Anyway, we use a rather abstract view on synchronization primitives. Modeling thread interactions on the hardware-level is out of the scope of this paper. A lot of research projects have been launched to make time predictable multi-core hardware architectures available. Our approach may benefit from this research.</p><p>Previous work done in the field of timing analysis for multi-core (e.g. [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] ) assumes that the threads are more or less executed in parallel and the threads do not heavily synchronize with each other, except when forking and joining. Our approach supports critical sections and the corresponding stalling times (e.g. caused by lock contention) in the heart of its matrix operations. Forking and joining of threads can also easily be modeled. Thus, our model is suitable for systems from a concurrent to a (fork and join) parallel execution model. Anyway, the focus in this paper is on a concurrent execution model.</p><p>The idea that thread interleavings and synchronization between threads can be studied with a matrix calculus is novel in this research area. Our sparse matrix representations of the program are manipulated using a lazy implementation of our extended Kronecker algebra. In [<xref ref-type="bibr" rid="scirp.66661-ref3">3</xref>] the Kronecker product is used in order to model synchronization. Similar to [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref5">5</xref>] , we describe synchronization by our selective Kronecker products and thread interleavings by Kronecker sums. The first goal is the generation of a data structure called concurrent program graph (CPG) which describes all possible interleavings and incorporates synchronization while preserving completeness. In general, our model can be represented by sparse adjacency matrices. The number of entries in the matrices is linear in their number of lines. In the worst case, the number of lines increases exponentially in the number of threads. The CPG, however, contains many nodes and edges unreachable from the entry node. If the program contains a lot of synchronization, only a very small part of the CPG is reachable. Our lazy implementation computes only this part which we call reachable CPG (RCPG). The implementation is very memory-efficient and has been parallelized to exploit modern many-core hardware architectures. These optimizations speed up processing significantly.</p><p>RCPGs represent concurrent and parallel programs similar as control flow graphs (CFGs) do for sequential programs. In this paper, we use RCPGs to calculate the WCET of the underlying concurrent system. In contrast to [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] , we (1) adopt the generating functions based approach of [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] for timing analysis and (2) are able to handle loops. For timing analysis, we set up a data flow equation for each RCPG node. It turns out that at certain synchronizing nodes, stalling times (e.g. caused by lock contention) can be formulated within dataflow equations as simple maximum operations. Choosing this approach, the calculated WCET includes stalling time. This is in contrast to most of the work done in this field (e.g. [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] ), which usually adopts a partial approach, where stalling times are calculated in a second step. We successively apply the following steps:</p><p>1. Generate CFGs out of binary or program code (cf. Subsection 2.1).</p><p>2. Generate RCPG out of the CFGs (cf. Section 3).</p><p>3. Apply hardware-level analysis based on the RCPG. Such an analysis may take into account e.g. shared resources like memory, data caches, and buses, and other hardware components like instruction caches and pipelining. Annotate this information at the corresponding RCPG edges. As mentioned above, this step is out of scope of this paper. Anyway, in order to get tight bounds this step is necessary (cf. [<xref ref-type="bibr" rid="scirp.66661-ref7">7</xref>] ). Some of these analyses (e.g. cache analysis) may be performed together with the next step.</p><p>4. Establish and solve dataflow equations based on the RCPG (cf. Section 4). Stalling times are incorporated via the equations.</p><p>Similar to [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] and [<xref ref-type="bibr" rid="scirp.66661-ref8">8</xref>] , which provide exact WCET for sequential programs, our approach calculates an exact worst-case execution time for concurrent programs running on a multi-core CPU (not only an upper bound) provided that the number of how often each loop is executed, the execution frequencies and execution times of the basic blocks (also of the semaphore operations p and v)<sup>1</sup> on RCFG level are known, and hardware impact is given. We assume timing predictability on the hardware level as discussed e.g. in [<xref ref-type="bibr" rid="scirp.66661-ref8">8</xref>] .</p><p>The outline of our paper is as follows. In Section 2, refined CFGs and Kronecker algebra are introduced. Our model of concurrency, some properties, and our lazy approach are presented in Section 3. Section 4 is devoted to WCET analysis of multi-threaded programs. An example is presented in Section 5. In Section 6, we survey related work. Finally, we draw our conclusion in Section 7.</p></sec><sec id="s2"><title>2. Preliminaries</title><p>In this paper, we refer to both, a processor and a core, as a processor. Our computational model can be described as follows. We model concurrent programs by threads which use semaphores for synchronization. We assume that on each processor exactly one thread is running and each thread immediately executes its next statement, if the thread is not stalled. Stalling may occur only in succession of semaphore calls.</p><p>Threads and semaphores are represented by slightly adapted CFGs. Each CFG is represented by an adjacency matrix. We assume that the edges of CFGs are labeled by elements of a semiring. A prominent example for such semirings are regular expressions [<xref ref-type="bibr" rid="scirp.66661-ref9">9</xref>] describing the behavior of finite state automata.</p><p>The set of labels <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x7.png" xlink:type="simple"/></inline-formula> is defined by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x8.png" xlink:type="simple"/></inline-formula>, where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x9.png" xlink:type="simple"/></inline-formula> is the set of ordinary (non-synchronization) labels and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x10.png" xlink:type="simple"/></inline-formula> is the set of labels representing semaphore calls (<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x11.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x12.png" xlink:type="simple"/></inline-formula> are disjoint). In order to model</p><p>e.g. a critical section usually two or more distinct thread CFGs refer to the same semaphore [<xref ref-type="bibr" rid="scirp.66661-ref10">10</xref>] . The operations on the basic blocks are<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x13.png" xlink:type="simple"/></inline-formula>, and * from a semiring [<xref ref-type="bibr" rid="scirp.66661-ref9">9</xref>] . Intuitively, these operations model consecutive program parts, conditionals, and loops, respectively.</p><sec id="s2_1"><title>2.1. Refined Control Flow Graphs</title><p>CFG nodes usually represent basic blocks [<xref ref-type="bibr" rid="scirp.66661-ref11">11</xref>] . Because our matrix calculus manipulates the edges, we need to have basic blocks on the (incoming) edges. A basic block consists of multiple consecutive statements without jumps. For our purpose, we need a finer granularity which we achieve by splitting edges. We apply it to basic blocks containing semaphore calls (e.g. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x14.png" xlink:type="simple"/></inline-formula>and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x15.png" xlink:type="simple"/></inline-formula>) and require that a semaphore call <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x16.png" xlink:type="simple"/></inline-formula> has to be the only statement on the corresponding edge. Roughly speaking, edge splitting maps a CFG edge e whose corresponding basic block contains k semaphore calls to a subgraph <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x17.png" xlink:type="simple"/></inline-formula>, such that each <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x18.png" xlink:type="simple"/></inline-formula> represents a single semaphore call, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x19.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x20.png" xlink:type="simple"/></inline-formula> represent the consecutive parts before and after<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x21.png" xlink:type="simple"/></inline-formula>, respectively (<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x21.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x22.png" xlink:type="simple"/></inline-formula>). Applying edge splitting to a CFG results in a refined control flow graph (RCFG). Note that a shared memory access aware analysis requires additional edge splitting for e.g. shared variables as done in [<xref ref-type="bibr" rid="scirp.66661-ref12">12</xref>] .</p><p>In the following, we use the labels as defined above as representatives for the basic blocks of RCFGs. To keep things simple, we refer to edges, their labels, the corresponding basic blocks and the corresponding entries of the adjacency matrices synonymously. In a similar fashion, we refer to nodes, their row and column numbers in the corresponding adjacency matrix synonymously. A matrix entry a in row i and column j is interpreted as a directed edge from node i to node j labeled by a.</p><p>In <xref ref-type="fig" rid="fig1">Figure 1</xref>(a) a binary semaphore is depicted. In a similar way it is possible to model counting semaphores allowing n non-blocking p-calls. Entry nodes have an incoming edge with no source node. A double circled node indicates that it is a final node. In the remainder, we use the RCFGs of the threads A and B presented in the <xref ref-type="fig" rid="fig1">Figure 1</xref>(b) and <xref ref-type="fig" rid="fig1">Figure 1</xref>(c), respectively, as a running example.</p></sec><sec id="s2_2"><title>2.2. Modeling Synchronization and Interleavings</title><p>Kronecker product and Kronecker sum form Kronecker algebra. In the following, we define both operations. Proofs, additional properties, and examples can be found in [<xref ref-type="bibr" rid="scirp.66661-ref13">13</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref14">14</xref>] . From now on, we use matrices out of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x23.png" xlink:type="simple"/></inline-formula> only.</p><fig-group id="fig1"><label><xref ref-type="fig" rid="fig1">Figure 1</xref></label><caption><title> RCFGs of a binary semaphore and the threads A and B. (a) Binary semaphore; (b) RCFG of thread A; (c) RCFG of thread B.</title></caption><fig id ="fig1_1"><label> (b)</label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x24.png"/></fig><fig id ="fig1_2"><label> (c)</label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x25.png"/></fig><fig id ="fig1_3"><label></label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x26.png"/></fig></fig-group><p>Definition 1 (Kronecker Product) Given a m-by-n matrix A and a p-by-q matrix B, their Kronecker product <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x27.png" xlink:type="simple"/></inline-formula> is a mp-by-nq block matrix defined by</p><disp-formula id="scirp.66661-formula1098"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x28.png"  xlink:type="simple"/></disp-formula><p>Kronecker product allows to model synchronization [<xref ref-type="bibr" rid="scirp.66661-ref3">3</xref>] . Properties concerning connectedness when applied to directed graphs can be found in [<xref ref-type="bibr" rid="scirp.66661-ref15">15</xref>] .</p><p>Definition 2 (Kronecker Sum) Given a matrix A of order<sup>2</sup> m and a matrix B of order n, their Kronecker sum <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x29.png" xlink:type="simple"/></inline-formula> is a matrix of order mn defined by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x30.png" xlink:type="simple"/></inline-formula>, where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x31.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x29.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x30.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x31.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x32.png" xlink:type="simple"/></inline-formula> denote identity matrices of order m and n, respectively.</p><p>The Kronecker sum calculates all possible interleavings of two concurrently executing automata (see [<xref ref-type="bibr" rid="scirp.66661-ref16">16</xref>] for a proof) even for general CFGs including conditionals and loops. In <xref ref-type="fig" rid="fig2">Figure 2</xref> the Kronecker sum of the threads A and B depicted in <xref ref-type="fig" rid="fig1">Figure 1</xref> is shown. It can be seen that the Kronecker sum calculates all possible interleavings of the two threads. In particular, note that thread A’s loop is copied five times (B’s number of nodes). We write <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x33.png" xlink:type="simple"/></inline-formula> to refer to the i-th copy of label l. If it is not clear in the context to which thread a label l belongs, we write <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x33.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x34.png" xlink:type="simple"/></inline-formula> to denote that l belongs to thread X. In particular, this is necessary for semaphore operations which are usually called by at least two threads. Otherwise the executing thread would be unknown.</p></sec></sec><sec id="s3"><title>3. Concurrent Program Graphs</title><p>Our system model consists of a finite number of threads and semaphores which are both represented by RCFGs. Threads call semaphores in order to implement synchronization or locks i.e. mutual exclusion for access to shared resources like shared variables or shared buses. The RCFGs are stored in form of adjacency matrices. The matrices have entries which are referred to as labels <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x36.png" xlink:type="simple"/></inline-formula> as defined in Section 2.</p><p>Formally, the system model consists of the tuple<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x37.png" xlink:type="simple"/></inline-formula>, where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x37.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x38.png" xlink:type="simple"/></inline-formula> is the set of RCFG adjacency matrices describing threads, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x37.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x38.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x39.png" xlink:type="simple"/></inline-formula>refers to the set of RCFG adjacency matrices describing semaphores, and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x37.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x38.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x39.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x40.png" xlink:type="simple"/></inline-formula></p><p>denotes the set of labels out of the semiring defined in the previous section. The labels (or matrix entries) of the</p><p>i-th thread's adjacency matrix <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x41.png" xlink:type="simple"/></inline-formula> are elements of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x41.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x42.png" xlink:type="simple"/></inline-formula>, whereas the labels (or matrix entries) of the j-th</p><fig id="fig2"  position="float"><label><xref ref-type="fig" rid="fig2">Figure 2</xref></label><caption><title> Kronecker sum <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x44.png" xlink:type="simple"/></inline-formula> of threads A and B</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x43.png"/></fig><p>synchronization primitive's adjacency matrix <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x45.png" xlink:type="simple"/></inline-formula> are elements of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x45.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x46.png" xlink:type="simple"/></inline-formula>. The matrices are manipulated by</p><p>using conventional Kronecker algebra operations together with extensions which we define in the course of this section.</p><p>A concurrent program graph (CPG) is a graph <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula> with a set of nodes V, a set of directed edges<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x48.png" xlink:type="simple"/></inline-formula>, a so-called entry node <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x48.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x49.png" xlink:type="simple"/></inline-formula> and a set of final nodes<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x48.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x49.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x50.png" xlink:type="simple"/></inline-formula>. The sets V and E are constructed out of the elements of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x48.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x49.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x51.png" xlink:type="simple"/></inline-formula>. Details on how we generate the sets V and E follow below. Similar to RCFGs the edges of CPGs are labeled by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x47.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x48.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x49.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x50.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x51.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x52.png" xlink:type="simple"/></inline-formula>.</p><p>In general, a thread’s CPG may have several final nodes. We refer to a node without outgoing edges as a sink node. A sink node appears as zero line in the corresponding adjacency matrix. A CPG’s final node may also be a sink node (if the program terminates). However, sink nodes and final nodes can be distinguished as follows. We</p><p>use a vector determining the final nodes of thread i, namely<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x53.png" xlink:type="simple"/></inline-formula>. In addition, vector <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x53.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x54.png" xlink:type="simple"/></inline-formula> determines the final</p><p>node of synchronization primitive j. Both have ones at places q, when node q is a final node, zeros elsewhere.</p><p>Then the vector <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x55.png" xlink:type="simple"/></inline-formula> determines the final nodes of the CPG.</p><p>In the remainder of this paper, we assume that all threads do have only one single final node. Our results, however, can be generalized easily to an arbitrary number of final nodes.</p><sec id="s3_1"><title>3.1. Generating a Concurrent Program’s Matrix</title><p>Let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x56.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x56.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x57.png" xlink:type="simple"/></inline-formula> refer to the matrices representing thread i and synchronization primitive (e.g. semaphore) i, respectively. According to <xref ref-type="fig" rid="fig1">Figure 1</xref>(a) we have for binary semaphore i the adjacency matrix <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x56.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x57.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x58.png" xlink:type="simple"/></inline-formula> of order two. We obtain the matrix T representing k interleaved threads and the matrix S repre- senting r interleaved synchronization primitives by</p><disp-formula id="scirp.66661-formula1099"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x59.png"  xlink:type="simple"/></disp-formula><p>Because the operations <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x60.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x60.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x61.png" xlink:type="simple"/></inline-formula> are associative [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] , the corresponding n-fold versions are well defined. Hence, we can apply the operations on multiple matrices (representing threads and synchronization primitives).</p><p>In the following, we define the selective Kronecker product which we denote by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x62.png" xlink:type="simple"/></inline-formula>. This operator synchronizes only labels identical in the two input matrices.</p><p>Definition 3 (Selective Kronecker Product) Given an m-by-n matrix A and a p-by-q matrix B, we call <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x63.png" xlink:type="simple"/></inline-formula> their selective Kronecker product. For all <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x63.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x64.png" xlink:type="simple"/></inline-formula> let<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x63.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x64.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x65.png" xlink:type="simple"/></inline-formula>, where</p><disp-formula id="scirp.66661-formula1100"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x66.png"  xlink:type="simple"/></disp-formula><p>The ordinary Kronecker product on the automata-level calculates the product automaton. In contrast, the selective Kronecker product is defined for only one active component. One thread executes the synchronization primitives’ operations. The synchronization primitive itself is a passive component. In contrast to the ordinary Kronecker product, the selective Kronecker product is defined such that a label l in the left operand is paired</p><p>with the same label in the right operand and not with any other label in the right operand and for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x67.png" xlink:type="simple"/></inline-formula></p><p>the resulting entry is l and not<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula>. Definition 3 is defined for a set of labels L. In the following, we use it exclusively for<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x69.png" xlink:type="simple"/></inline-formula>. Thus, we use this operation only for labels referring to synchronization primitive calls. Used that way, the selective Kronecker product ensures that, e.g., a p-call to semaphore i, i.e. a <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x70.png" xlink:type="simple"/></inline-formula>-call, in the left operand is paired with the corresponding <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x70.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x71.png" xlink:type="simple"/></inline-formula>-operation in the right operand and not with any other label (e.g. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x70.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x71.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x72.png" xlink:type="simple"/></inline-formula>of a semaphore<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x68.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x69.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x70.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x71.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x72.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x73.png" xlink:type="simple"/></inline-formula>) in the right operand.</p><p>Definition 4 (Filtered Matrix) We call <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x74.png" xlink:type="simple"/></inline-formula> a filtered matrix and define it as a matrix of order <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x74.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x75.png" xlink:type="simple"/></inline-formula> containing entries of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x74.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x75.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x76.png" xlink:type="simple"/></inline-formula> of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x74.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x75.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x76.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x77.png" xlink:type="simple"/></inline-formula> and zeros elsewhere:</p><disp-formula id="scirp.66661-formula1101"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x78.png"  xlink:type="simple"/></disp-formula><p>The adjacency matrix representing a program is referred to as P. As stated in [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref17">17</xref>] , P can be computed efficiently by</p><disp-formula id="scirp.66661-formula1102"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x79.png"  xlink:type="simple"/></disp-formula><p>Intuitively, the selective Kronecker product term on the left allows for synchronization between the threads represented by T and the synchronization primitives S. Both T and S are Kronecker sums of the involved threads and synchronization primitives, respectively, in order to represent all possible interleavings of the concurrently executing threads. The right term allows the threads to perform steps that are not involved in synchronization. Summarizing, the threads (represented by T) may perform their steps concurrently, where all interleavings are allowed, except when they call synchronization primitives. In the latter case the synchronization primitives (represented by S) together with Kronecker product ensure that these calls are executed in the order prescribed by the finite automata (FA) of the synchronization primitives. So, for example, a thread cannot do semaphore calls in the order v followed by p when the semaphore FA only allows a p-call before a v-call. The CPG of such an erroneous program will contain a node from which the final node of the CPG cannot be reached. This node is the one preceding the v-call. Such nodes can easily be found by traversing CPGs. Thus, deadlocks of concurrent systems can be detected with little effort [<xref ref-type="bibr" rid="scirp.66661-ref12">12</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref17">17</xref>] .</p><p>Until now the following synchronization primitives have been successfully applied. In [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref12">12</xref>] semaphores are the only synchronization primitives. In [<xref ref-type="bibr" rid="scirp.66661-ref17">17</xref>] the approach is extended in order to model Ada’s protected objects, too. Finally, in [<xref ref-type="bibr" rid="scirp.66661-ref5">5</xref>] it is shown that barriers can be used as synchronization primitives. In the latter paper it is also presented that initially locked and unlocked semaphores can be incorporated to our Kronecker algebra-based approach.</p><p>It can easily be shown that CPGs have at most <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x80.png" xlink:type="simple"/></inline-formula> nodes and at most <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x80.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x81.png" xlink:type="simple"/></inline-formula> edges, if k is the number of threads and each thread has n nodes in its RCFG. Hence, each CPG has a sparse adjacency matrix<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x80.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x81.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x82.png" xlink:type="simple"/></inline-formula>.</p><p>Thus, memory saving data structures and efficient algorithms suggest themselves. In the worst-case, however, the number of CPG nodes increases exponentially in k.</p></sec><sec id="s3_2"><title>3.2. Lazy Implementation of Kronecker Algebra</title><p>In general, a CPG contains unreachable parts if a concurrent program contains synchronization. This can be summarized as follows: The way we adopt the Kronecker product limits the number of possible paths such that the p- and v-operations are present in correct p-v-pairs in the RCPG. In contrast <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x83.png" xlink:type="simple"/></inline-formula> contains all</p><p>possible paths even those containing semantically wrong uses of the synchronization primitive (e.g. semaphore) operations. This contrast can be seen in our running example in <xref ref-type="fig" rid="fig2">Figure 2</xref> and <xref ref-type="fig" rid="fig3">Figure 3</xref>. The Kronecker sum of thread A and B in <xref ref-type="fig" rid="fig2">Figure 2</xref> contains five copies of thread A’s loop, whereas the RCPG in <xref ref-type="fig" rid="fig3">Figure 3</xref> contains this loop only three times. It can be easily seen that the latter reflects the correct use of the semaphore operations.</p><p>Choosing a lazy implementation for the matrix operations ensures that, when extracting the reachable parts of the underlying graph, the overall effort is reduced to exactly these parts. By starting from the RCPG’s entry node and calculating all reachable successor nodes, our lazy implementation exactly does this [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] . Thus, for example, if the resulting RCPG’s size is linear in terms of the involved threads, only linear effort will be necessary to generate the RCPG.</p></sec></sec><sec id="s4"><title>4. WCET Analysis on RCPGs</title><p>In order to calculate the WCET of a concurrent program, we adopt the generating functions based approach introduced in [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] . We generalize this approach such that we are able to analyze multi-threaded programs. Each node of the RCPG is assigned a dataflow variable and a dataflow equation is set up based on the predecessors of the RCPG node. A dataflow variable is represented by a vector. Each component of the vector reflects a processor and is used to calculate the WCET of the corresponding thread. Recall that only one single thread is allocated to a processor. Even though RCPGs support multiple concurrent threads on one CPU also, we restrict</p><fig id="fig3"  position="float"><label><xref ref-type="fig" rid="fig3">Figure 3</xref></label><caption><title> RCPG</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x84.png"/></fig><p>the WCET analysis to one thread per processor. This assumption eases the definition of the dataflow equations and it is not a restriction from our approach itself.</p><sec id="s4_1"><title>4.1. Execution Frequencies</title><p>In the remaining part of the paper, we will use execution frequencies [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] . The execution frequency <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula> is a measure of how often the edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x86.png" xlink:type="simple"/></inline-formula> is taken compared to the other outgoing edges of node k. Thus, each execution frequency is a rational number. Its values range from 0 (which models a dead path) to 1, i.e.,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x86.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x87.png" xlink:type="simple"/></inline-formula>. For each node k, it is required that the execution frequencies of all outgoing edges sum to 1. If node k has at least two outgoing edges, then we have a so-called node constraint<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x86.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x88.png" xlink:type="simple"/></inline-formula>. We assign a variable to each<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x86.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x88.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x89.png" xlink:type="simple"/></inline-formula>. A concrete value is assigned to each of these variables during the maximization process which is described below in Section 4.6. If a node m has only one outgoing edge to node n, then the execution frequency <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x85.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x86.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x87.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x88.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x89.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x90.png" xlink:type="simple"/></inline-formula> is statically known and neither a node constraint nor an additional variable for the execution frequency is needed.</p></sec><sec id="s4_2"><title>4.2. Loops</title><p>Let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x91.png" xlink:type="simple"/></inline-formula> refer to the set of natural numbers including zero, i.e.,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x91.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x92.png" xlink:type="simple"/></inline-formula>. From now on, we use the variable <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x91.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x92.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x93.png" xlink:type="simple"/></inline-formula> to refer to the number of loop iterations of loop i at CFG level. For each loop, we require that</p><p>this number is constant<sup>3</sup> and statically known. As we have seen in <xref ref-type="fig" rid="fig2">Figure 2</xref>, RCPGs contain several copies of basic blocks (in our case edges) and loops in different places.</p><p>Since RCPGs model all interleavings of the involved threads, a certain execution of the underlying concurrent program (a certain path in the RCPG) may divide the code of a loop in the CFG among all its copies in the RCPG. In particular, we do not know a priori how a loop will be split among its copies in the RCPG for the path producing the WCET. For this reason, we assign variables (with unknown values) to the number of loop iterations of the loop copies in the RCPG. Later on (during the maximization process), concrete values for this loop iteration variables are chosen such that the execution time is maximized. Note that assigning variables to loop iteration numbers implies that some execution frequencies have also to be considered variable. These execution frequencies also get concrete values during the maximization process.</p><p>We refer to the number of loop iterations of the j-th copy of loop i as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x95.png" xlink:type="simple"/></inline-formula>. This variable denotes the number of how often the loop entry edge of the j-th copy of loop i is executed. The loop entry of the j-th copy (out of n) of loop i gets assigned the execution frequency variable<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x95.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x96.png" xlink:type="simple"/></inline-formula>, where<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x95.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x96.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x97.png" xlink:type="simple"/></inline-formula>. Note that the variables <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x95.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x96.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x97.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x98.png" xlink:type="simple"/></inline-formula> get numerical values during the maximization process. Thus, the execution frequency of each loop entry edge is calculated automatically.</p><p>If node m has multiple outgoing loop entry edges for the loops <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x99.png" xlink:type="simple"/></inline-formula> and there exists exactly one outgoing non loop entry edge, then the execution frequency for the loop entry edge of loop i is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x99.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x100.png" xlink:type="simple"/></inline-formula>.</p><p>Loop Iteration Constraints. Assume CFG loop i is executed <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x101.png" xlink:type="simple"/></inline-formula> times and n copies (as mentioned above due to the Kronecker sum) of that loop are in the RCPG, then we have the constraint<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x101.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x102.png" xlink:type="simple"/></inline-formula>. We assume that</p><p>the value of variable<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x103.png" xlink:type="simple"/></inline-formula>, i.e., the number of loop iterations on thread (CFG) level is known a priori. The variables <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x103.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x104.png" xlink:type="simple"/></inline-formula> are used as variables during the maximization process. During the generation of the RCPG it is possible to remember each copy of a CFG loop entry edge. In order to establish the loop iteration constraints, we go through this information.</p><p>Loop Exit Constraints. For loop i’s j-th copy we have <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x105.png" xlink:type="simple"/></inline-formula> iterations. Then we have the loop exit constraint<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x106.png" xlink:type="simple"/></inline-formula>, where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x105.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x106.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x107.png" xlink:type="simple"/></inline-formula> is the sum of execution frequencies of all loop exiting edges of the j-th copy of loop i.</p><p>In general, such loop exiting edges do also include edges from other threads which do not execute any part of loop i. Note that we can calculate the loop exit constraints automatically. Our approach does support nested loops [<xref ref-type="bibr" rid="scirp.66661-ref18">18</xref>] which result in non-linear constraints. This is one reason which prohibits applying an ILP-based approach like [<xref ref-type="bibr" rid="scirp.66661-ref8">8</xref>] for solving the concurrent WCET problem.</p></sec><sec id="s4_3"><title>4.3. Synchronizing Nodes</title><p>A thread calling a semaphore’s p-operation potentially blocks [<xref ref-type="bibr" rid="scirp.66661-ref10">10</xref>] . On the other hand, a thread calling a semaphore’s v-operation may unblock a waiting thread [<xref ref-type="bibr" rid="scirp.66661-ref10">10</xref>] . In RCPGs, blocking occurs at what we call synchronizing nodes. We distinguish two types of synchronizing nodes, namely vp- and pp-synchronizing nodes.</p><p>Each vp-synchronizing node has an incoming edge labeled by a semaphore v-operation, an outgoing edge labeled by a p-operation of the same semaphore, and these two edges are part of different threads. In this case, the thread calling the p-operation (potentially) has to wait until the other thread’s v-operation is finished.</p><p>Definition 5. A vp-synchronizing node is a RCPG node s such that</p><p>• there exists an edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x108.png" xlink:type="simple"/></inline-formula> with label <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x108.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x109.png" xlink:type="simple"/></inline-formula> and</p><p>• there exists an edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x110.png" xlink:type="simple"/></inline-formula> with label<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x110.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x111.png" xlink:type="simple"/></inline-formula>,</p><p>where k denotes the same semaphore and the edges <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x112.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x112.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x113.png" xlink:type="simple"/></inline-formula> are mapped to different processors, i.e.,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x112.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x113.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x114.png" xlink:type="simple"/></inline-formula>.</p><p>For vp-synchronizing nodes, we establish specific data flow equations as described in the following subsection.</p><p>Definition 6. A pp-synchronizing node is a RCPG node s such that</p><p>• there exists an edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x115.png" xlink:type="simple"/></inline-formula> with label <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x115.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x116.png" xlink:type="simple"/></inline-formula> and</p><p>• there exists an edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x117.png" xlink:type="simple"/></inline-formula> with label<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x117.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x118.png" xlink:type="simple"/></inline-formula>,</p><p>where k denotes the same semaphore and the edges <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x119.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x119.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x120.png" xlink:type="simple"/></inline-formula> are mapped to different processors, i.e.,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x119.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x120.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x121.png" xlink:type="simple"/></inline-formula>.</p><p>For pp-synchronizing nodes, we establish fairness constraints ensuring a deterministic choice when e.g. the time of both involved CPUs at node s is exactly the same.</p></sec><sec id="s4_4"><title>4.4. Setting Up and Solving Dataflow Equations</title><p>In this section, we extend the generating function based approach of Section 4 of [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] such that we are able to calculate the WCET of concurrent programs modeled by RCPGs. Each RCPG node’s dataflow equation is set up according to its predecessors and the incoming edges (including execution frequency, execution time and in case of vp-synchronizing nodes stalling time).</p><p>Let the vector<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x122.png" xlink:type="simple"/></inline-formula>. We write <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x122.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x123.png" xlink:type="simple"/></inline-formula> to denote the i-th component <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x122.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x124.png" xlink:type="simple"/></inline-formula> of vector<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x122.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x124.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x125.png" xlink:type="simple"/></inline-formula>. In addition, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x122.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x123.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x124.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x125.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x126.png" xlink:type="simple"/></inline-formula>refers to the vector of node x.</p><p>Let a be a scalar and let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x127.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x127.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x128.png" xlink:type="simple"/></inline-formula> be two n-dimensional vectors. The addition and multiplication of vectors and the multiplication of a scalar with a vector are defined as follows:</p><disp-formula id="scirp.66661-formula1103"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x129.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.66661-formula1104"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x130.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.66661-formula1105"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x131.png"  xlink:type="simple"/></disp-formula><p>Definition 7 (Setting up Dataflow Equations) Let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x132.png" xlink:type="simple"/></inline-formula> refer to the time assigned to edge<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x133.png" xlink:type="simple"/></inline-formula>. In addition, the set of predecessor nodes of node n is referred to as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x132.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x133.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x134.png" xlink:type="simple"/></inline-formula>.</p><p>If n is a non-vp-synchronizing node and edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x135.png" xlink:type="simple"/></inline-formula> is mapped to processor k, then</p><disp-formula id="scirp.66661-formula1106"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x136.png"  xlink:type="simple"/></disp-formula><p>where the kth component of vector <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x137.png" xlink:type="simple"/></inline-formula> is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x137.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x138.png" xlink:type="simple"/></inline-formula> and the other components are equal to 1.</p><p>Let s be a vp-synchronizing node. In addition, let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula> be the processors which the edges <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x141.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x141.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x142.png" xlink:type="simple"/></inline-formula> are mapped to, i.e., <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x141.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x142.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x143.png" xlink:type="simple"/></inline-formula>and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x141.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x142.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x143.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x144.png" xlink:type="simple"/></inline-formula>.<sup>4</sup> Then for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x139.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x140.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x141.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x142.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x143.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x144.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x145.png" xlink:type="simple"/></inline-formula></p><disp-formula id="scirp.66661-formula1107"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x146.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.66661-formula1108"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x147.png"  xlink:type="simple"/></disp-formula><p>where the first term considers the incoming p-edge and the second term takes into account all other incoming edges of the blocking thread running on processor<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x150.png" xlink:type="simple"/></inline-formula>.</p><p>The max-operator in Def. 7 is not an ordinary maximum operation for numbers. During the maximization process, we actually do the whole calculation twice. One time, we replace <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x151.png" xlink:type="simple"/></inline-formula> by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x151.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x152.png" xlink:type="simple"/></inline-formula> and then, we do this calculation using the second solution<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x151.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x152.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x153.png" xlink:type="simple"/></inline-formula>. In the end, the solution with the highest WCET value will be taken.</p><p>The entry node’s equation <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x154.png" xlink:type="simple"/></inline-formula> follows the rules above and, in addition, for n threads adds an</p><p>n-dimensional vector<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x155.png" xlink:type="simple"/></inline-formula>.</p><p>The dataflow equations can intuitively be explained as follows. We cumulate the execution times in an interleavings semantics fashion. One can think of taking one edge after the other. Nevertheless, edges may be executed in parallel and the execution and stalling times are added to the corresponding vector components. In the overall process, we get the WCET of the concurrent program.</p><p>The system of dataflow equations can be solved efficiently by applying an algorithm presented in [<xref ref-type="bibr" rid="scirp.66661-ref15">15</xref>] . As a result, we get explicit formulas for the final node. In order to double-check that we calculate a correct solution, we used Mathematica<sup>&#211;</sup> to solve the node equations, too. Both of the two approaches for solving the node equations calculate the same and correct results.</p></sec><sec id="s4_5"><title>4.5. Partial Loop Unrolling</title><p>For vp-synchronizing nodes having at least one outgoing loop entry edge<sup>5</sup>, we have to partly unroll the corresponding loop such that one iteration is statically present in the RCPG’s equations. Partial loop unrolling ensures that synchronization is modelled correctly. Only the unrolled part contains a synchronizing node. Some execution frequencies and equations have to be added or adapted. Edges have to be added to ensure that the original and the unrolled loop behave semantically equivalent. For example, if the original loop was able to iterate <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x157.png" xlink:type="simple"/></inline-formula> times, then the new construct must also allow the same number of iterations. In order to define some execution frequencies correctly, we are using the Kronecker delta function. We do such partial loop unrolling for our example in the appendix in Subsection 5.2. In our example, we e.g. have to add edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x157.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x158.png" xlink:type="simple"/></inline-formula> to allow a zero number of iterations (compare <xref ref-type="fig" rid="fig3">Figure 3</xref> and <xref ref-type="fig" rid="fig4">Figure 4</xref>). Note that partial loop unrolling can be fully automated.</p></sec><sec id="s4_6"><title>4.6. Maximization Process</title><p>In order to determine the WCET, we have to differentiate the solution for the final node <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x159.png" xlink:type="simple"/></inline-formula> with respect to z and after that set<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x159.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x160.png" xlink:type="simple"/></inline-formula>.</p><p>Let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x161.png" xlink:type="simple"/></inline-formula> refer to the function representing the solution of the kth component of the final node<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x161.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x162.png" xlink:type="simple"/></inline-formula>. According to well-known facts of generating functions [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] it is defined as</p><disp-formula id="scirp.66661-formula1109"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x163.png"  xlink:type="simple"/></disp-formula><fig-group id="fig4"><label><xref ref-type="fig" rid="fig4">Figure 4</xref></label><caption><title> Adapted RCPG.</title></caption><fig id ="fig4_1"><label></label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/4-9302209x164.png"/></fig></fig-group><p>In order to calculate the loop iteration count for all loop copies and to calculate the undefined execution frequencies within the given constraints, we maximize this function. This goes beyond the approaches given in [<xref ref-type="bibr" rid="scirp.66661-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.66661-ref6">6</xref>] . During this maximization step, for which we used NMaximize of Mathematica<sup>&#211;</sup>, e.g. all <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x165.png" xlink:type="simple"/></inline-formula> are treated as variables. For each of these variables, Mathematica finds values within the given constraints. Thus, Mathematica assigns valid values for all <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x165.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x166.png" xlink:type="simple"/></inline-formula> and all the unknown execution frequencies. Of course, instead of Mathematica, any non-linear function solver capable of handling constraints can be used. The WCET of the kth CPU core is given by</p><disp-formula id="scirp.66661-formula1110"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x167.png"  xlink:type="simple"/></disp-formula><p>In the following, the variable configuration found during this maximization is used. The WCET of a concurrent program consisting of n threads is defined as</p><disp-formula id="scirp.66661-formula1111"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x168.png"  xlink:type="simple"/></disp-formula><p>where the max is the ordinary maximum operator for numbers.</p><p>If the RCPG contains s vp-synchronizing nodes, then the maximization process has to be done <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x169.png" xlink:type="simple"/></inline-formula> times. One time for each possible value of <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x169.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x170.png" xlink:type="simple"/></inline-formula> originating from the vp-synchronizing nodes. At last the largest value of those <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x169.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x170.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x171.png" xlink:type="simple"/></inline-formula> results represents the WCET of the concurrent program. Hence, the computational complexity may increase exponentially in s. Anyhow, s is usually small. For n threads and r semaphores, the</p><p>number of vp-synchronizing nodes in the CPG is bounded above by<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x172.png" xlink:type="simple"/></inline-formula>, where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x172.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x173.png" xlink:type="simple"/></inline-formula> is the</p><p>number of v-operations of semaphore j in thread i and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x174.png" xlink:type="simple"/></inline-formula> is the number of p-operations of semaphore j in thread k. Depending on how the semaphores are used not all vp-synchronizing nodes may be part of the RCPG. In addition, information may be available which allows to conclude that even some of the present cases cannot result in the final WCET value. Then, these cases need not be considered in the maximization process. In [<xref ref-type="bibr" rid="scirp.66661-ref19">19</xref>] an example with CPG matrix size of 298721280 has been analyzed within 400 ms. It contained 13 semaphores and only 15 synchronization nodes. Even though the CPGs for travel time analysis do not contain loops, the number of synchronizing nodes is comparable.</p></sec></sec><sec id="s5"><title>5. Example</title><p>This small example includes synchronization and one single loop. We use two threads, namely A and B, sharing one single semaphore with the operations p and v. The CFGs of the two threads are depicted in <xref ref-type="fig" rid="fig1">Figure 1</xref>(b) and <xref ref-type="fig" rid="fig1">Figure 1</xref>(c). Each edge is labeled by a basic block l. Together with a RCFG of a binary semaphore, we calculate the adjacency matrix P of the corresponding RCPG in the following steps: The interleaved threads are given by</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x175.png" xlink:type="simple"/></inline-formula>Because we have only one semaphore, the interleaved semaphores are trivially defined as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x175.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x176.png" xlink:type="simple"/></inline-formula>. The program’s matrix P is given by <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x175.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x176.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x177.png" xlink:type="simple"/></inline-formula> where <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x175.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x176.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x177.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x178.png" xlink:type="simple"/></inline-formula> and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x175.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x176.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x177.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x178.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x179.png" xlink:type="simple"/></inline-formula>. The</p><p>RCPG of the A-B-system is depicted in <xref ref-type="fig" rid="fig3">Figure 3</xref>. The edges for the RCPG are labeled by their execution frequencies on RCPG level. Anyway, we indicate for each execution frequency <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x181.png" xlink:type="simple"/></inline-formula> that it is the execution frequency for the x-th copy of basic block l.<sup>6</sup></p><p>We assume that both threads access shared variables in the basic blocks a and d. Thus, the basic blocks a and d are only allowed to be executed in a mutually exclusive fashion. This is ensured by using a semaphore. The basic blocks a and d are protected by p-calls. After the corresponding thread finishes the execution of a or d, the semaphore is released by a v-call. We assume that all the other basic blocks do not access shared variables. Note that the threads are mapped to distinct processors and that these mappings are immutable.</p><p>Each variable x in this example (except<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula>and<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula>) is a rational number such that<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula>. We assume that thread A's loop is executed <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula> times and the three copies of the loop are executed<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x188.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x188.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x189.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x188.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x189.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x190.png" xlink:type="simple"/></inline-formula> times, respectively. Hence, we have the loop iteration constraint<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x188.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x189.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x190.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x191.png" xlink:type="simple"/></inline-formula>, where<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x182.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x183.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x184.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x185.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x186.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x187.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x188.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x189.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x190.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x191.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x192.png" xlink:type="simple"/></inline-formula>.</p><sec id="s5_1"><title>5.1. Equations Not Affected by Partial Loop Unrolling</title><p>Following the rules of Section 3, we obtain the following equations.</p><disp-formula id="scirp.66661-formula1112"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x193.png"  xlink:type="simple"/></disp-formula><p>Note again that the max-operators in <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x194.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x194.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x195.png" xlink:type="simple"/></inline-formula> (stated in Subsection 5.2) originate because the</p><p>original nodes 9 and 14, respectively, are vp-synchronizing nodes and that max is not the ordinary maximum operation using numbers as input. During the maximization process, for each max -operator we do the whole calculation twice, once for each possible solution.</p></sec><sec id="s5_2"><title>5.2. Partial Loop Unrolling</title><p>Node 13 is a vp-synchronizing node and edge <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x196.png" xlink:type="simple"/></inline-formula> constitutes a loop entry edge. Thus, we have to apply partial loop unrolling.</p><disp-formula id="scirp.66661-formula1113"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x197.png"  xlink:type="simple"/></disp-formula><p>The changes in the equations can be interpreted on RCPG-level as depicted in <xref ref-type="fig" rid="fig4">Figure 4</xref> (compare to <xref ref-type="fig" rid="fig3">Figure 3</xref>). For edges whose execution frequency is 1 we write 1(a) in order to state that the edge refers to the basic block a. For these edges, the execution time would otherwise be unclear. In the following, we use the Kronecker delta function. Kronecker delta <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x198.png" xlink:type="simple"/></inline-formula> is defined as</p><disp-formula id="scirp.66661-formula1114"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x199.png"  xlink:type="simple"/></disp-formula><p>By partially unrolling the loop, we get the execution frequencies:</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x200.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x200.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x201.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x200.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x201.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x202.png" xlink:type="simple"/></inline-formula></p><p>Note that the non-linear function solver employed for the maximization process must be able to handle <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x203.png" xlink:type="simple"/></inline-formula> and case functions (like that used in the right hand side of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x203.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x204.png" xlink:type="simple"/></inline-formula>) correctly.</p></sec><sec id="s5_3"><title>5.3. Execution Frequencies and Constraints</title><p>The following execution frequencies and constraints are extracted out of the RCPG. The execution frequencies of the loop entry edges <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x205.png" xlink:type="simple"/></inline-formula> and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x205.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x206.png" xlink:type="simple"/></inline-formula> are established as follows:</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x207.png" xlink:type="simple"/></inline-formula>,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x207.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x208.png" xlink:type="simple"/></inline-formula>.</p><p>From the node constraints, we get<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x212.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x212.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x213.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x212.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x213.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x214.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x212.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x213.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x214.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x215.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x209.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x210.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x211.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x212.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x213.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x214.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x215.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x216.png" xlink:type="simple"/></inline-formula> statically set to 1. The remaining node constraints contribute execution frequency variables and the corresponding constraints for the final maximization process.</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x219.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x219.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x220.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x219.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x220.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x221.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x219.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x220.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x221.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x222.png" xlink:type="simple"/></inline-formula>,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x217.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x218.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x219.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x220.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x221.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x222.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x223.png" xlink:type="simple"/></inline-formula>.</p><p>The loop exit constraints are as follows:</p><p><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x224.png" xlink:type="simple"/></inline-formula>,<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x224.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x225.png" xlink:type="simple"/></inline-formula>.</p><p>The time needed for executing basic block b is referred to as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x226.png" xlink:type="simple"/></inline-formula>. We assume that all copies of a certain basic block lead to the same execution time. Thus, e.g., each one out of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x226.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x227.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x226.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x227.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x228.png" xlink:type="simple"/></inline-formula>and <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x226.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x227.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x228.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x229.png" xlink:type="simple"/></inline-formula> has an execution time of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x226.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x227.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x228.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x229.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x230.png" xlink:type="simple"/></inline-formula>. Finally, for node 5, which is a pp-synchronizing node, we have the following constraints. These conditions follow from our computational model described in Section 2 and the fairness constraints from Subsection 4.3:</p><p>•<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x231.png" xlink:type="simple"/></inline-formula>,</p><p>•<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x232.png" xlink:type="simple"/></inline-formula>,</p><p>•<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x233.png" xlink:type="simple"/></inline-formula>.</p></sec><sec id="s5_4"><title>5.4. Solving the Equations</title><p>For a concise presentation, we use the notation<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x234.png" xlink:type="simple"/></inline-formula>. We used two approaches to solve the equations. At first, we applied [<xref ref-type="bibr" rid="scirp.66661-ref20">20</xref>] . To double-check the solution, we used Mathematica<sup>&#211;</sup>, too.</p><p>The resulting equations for the final node 16 are:</p><p><img data-original="http://html.scirp.org/file/4-9302209x236.png" /><img data-original="http://html.scirp.org/file/4-9302209x235.png" /></p><p>where</p><disp-formula id="scirp.66661-formula1115"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x237.png"  xlink:type="simple"/></disp-formula></sec><sec id="s5_5"><title>5.5. Maximization Process</title><p>Finally, we have to differentiate <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x238.png" xlink:type="simple"/></inline-formula> with respect to z and then set<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x238.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x239.png" xlink:type="simple"/></inline-formula>.</p><disp-formula id="scirp.66661-formula1116"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x240.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.66661-formula1117"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x241.png"  xlink:type="simple"/></disp-formula><p>where the set constraints consists of the constraints set up in Section 5.3. The WCET of the concurrent program consisting of two threads is defined by</p><disp-formula id="scirp.66661-formula1118"><graphic  xlink:href="http://html.scirp.org/file/4-9302209x242.png"  xlink:type="simple"/></disp-formula><p>In <xref ref-type="table" rid="table1">Table 1</xref> some WCET values of the program and its components, namely the threads A and B, are depicted. The time needed for executing basic block b is referred to as<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula>. We assume that all copies of a certain basic block lead to the same execution time. Further we set<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x244.png" xlink:type="simple"/></inline-formula>, <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x244.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x245.png" xlink:type="simple"/></inline-formula>, and let <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x244.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x245.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x246.png" xlink:type="simple"/></inline-formula> range from 1 to 10. As described above, during the maximization process, we let Mathematica<sup>&#211;</sup> choose the values of the variables <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x244.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x245.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x246.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x247.png" xlink:type="simple"/></inline-formula> and all the unknown execution frequencies. We used the execution time <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x243.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x244.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x245.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x246.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x247.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x248.png" xlink:type="simple"/></inline-formula> as an input parameter to see how it affects the WCET of the program. Note that the calculated values are exact WCET values. In the rightmost column of <xref ref-type="table" rid="table1">Table 1</xref>, we present the average time needed by Mathematica to calculate the time of the component leading to the WCET. Note that the maximization dominates the overall CPU time. Generating the RCPG and solving the data flow equations takes only a few milli seconds. Mathematica 10 was executed on a CentOS 6.0, Intel Core i7 870 CPU, 2.96 GHz, 8 MB cache and 4GB RAM. Until now, our focus was not on using specialized non-linear solvers which would probably lead to much better maximization times. Finding the best non-linear function solver is ongoing research.</p></sec></sec><sec id="s6"><title>6. Related Work</title><p>Our approach is the first one capable of handling parallel and concurrent software. There exist several approaches for parallel systems which we will discuss in the following (see e.g. [<xref ref-type="bibr" rid="scirp.66661-ref21">21</xref>] for an overview).</p><p>In [<xref ref-type="bibr" rid="scirp.66661-ref7">7</xref>] an IPET based approach is presented. Communication between code regions in form of message passing is detected via source code annotations specifying the recipient and the latency of the communication. For each communication between code regions, the corresponding CFGs are connected via an additional edge. Hence, the data structure are CFGs connected via communication edges. This is not enough for programs containing recurring communication between threads. In contrast to that, our approach generates a new data structure (RCPG) out of the input CFGs in a fully automated way. The RCPG incorporates thread synchronization of</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> WCET for <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x249.png" xlink:type="simple"/></inline-formula> and multiple values of<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x249.png" xlink:type="simple"/></inline-formula><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x250.png" xlink:type="simple"/></inline-formula></title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Thread</th><th align="center" valign="middle" >1</th><th align="center" valign="middle" >2</th><th align="center" valign="middle" >3</th><th align="center" valign="middle" >4</th><th align="center" valign="middle" >5</th><th align="center" valign="middle" >6</th><th align="center" valign="middle" >7</th><th align="center" valign="middle" >8</th><th align="center" valign="middle" >9</th><th align="center" valign="middle" >10</th><th align="center" valign="middle" >11</th><th align="center" valign="middle" >12</th><th align="center" valign="middle" >13</th><th align="center" valign="middle" >Parameter <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x251.png" xlink:type="simple"/></inline-formula></th><th align="center" valign="middle" >WCET PROG. <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x252.png" xlink:type="simple"/></inline-formula></th><th align="center" valign="middle" >Time [s]</th></tr></thead><tr><td align="center" valign="middle" >A</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >b</td><td align="center" valign="middle" ></td><td align="center" valign="middle" >1, 2, 3</td><td align="center" valign="middle" >12</td><td align="center" valign="middle" >48.45</td></tr><tr><td align="center" valign="middle" >B</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >&#215;</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" ></td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >d</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x253.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ></td></tr><tr><td align="center" valign="middle" >A</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >b</td><td align="center" valign="middle" ></td><td align="center" valign="middle" >4</td><td align="center" valign="middle" >12</td><td align="center" valign="middle" >53.21</td></tr><tr><td align="center" valign="middle" >B</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >d</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x254.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ></td></tr><tr><td align="center" valign="middle" >A</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >b</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" >5, 6, 7, 8</td><td align="center" valign="middle" >11</td><td align="center" valign="middle" >9.11</td></tr><tr><td align="center" valign="middle" >B</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >&#215;</td><td align="center" valign="middle" >&#215;</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >d</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x255.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ></td></tr><tr><td align="center" valign="middle" >A</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >b</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" >9</td><td align="center" valign="middle" >12</td><td align="center" valign="middle" >8.59</td></tr><tr><td align="center" valign="middle" >B</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >d</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x256.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ></td></tr><tr><td align="center" valign="middle" >A</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >a</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" >b</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" ></td><td align="center" valign="middle" >10</td><td align="center" valign="middle" >13</td><td align="center" valign="middle" >8.77</td></tr><tr><td align="center" valign="middle" >B</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >c</td><td align="center" valign="middle" >p</td><td align="center" valign="middle" >d</td><td align="center" valign="middle" >v</td><td align="center" valign="middle" ></td><td align="center" valign="middle" ><inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/4-9302209x257.png" xlink:type="simple"/></inline-formula></td><td align="center" valign="middle" ></td></tr></tbody></table></table-wrap><p>the multi-threaded program and thus contains only the reachable interleavings. Our approach is not limited to one single synchronization mechanism, it can be used to model e.g. semaphores or locks. In addition, RCPGs play a similar role for multi-threaded programs as CFGs do for sequential programs and can be used for further analysis purposes. The hardware analysis on basic block level of [<xref ref-type="bibr" rid="scirp.66661-ref7">7</xref>] can be applied to our approach too.</p><p>As our approach for loops, the work presented in [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] also relies on annotations. The worst case stalling time is estimated for each synchronization operation. This time is added to the time of the corresponding basic block. Our approach exactly detects the points where stalling will occur, i.e., at the vp-synchronizing nodes, and establishes dataflow equations to handle that problem in an explicit and natural way. It calculates the stalling times which need not be given by the user. At these points (e.g. critical section protected via a semaphore), we can also incorporate hardware penalties for all kinds of external communication and optimizations for e.g. shared data caches. Our approach allows synchronization within loops in a concurrent program whereas [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] does not support that. This is the main reason why [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] can use an ILP approach. Similar to [<xref ref-type="bibr" rid="scirp.66661-ref2">2</xref>] , we use a rather abstract view of synchronization primitives and assume timing predictability on the hardware level as discussed e.g. in [<xref ref-type="bibr" rid="scirp.66661-ref22">22</xref>] .</p><p>Current steps towards multi-core analysis including hardware modelling try to restrict interleavings and use a rigorous bus protocol (e.g. TDMA) that increases the predictability [<xref ref-type="bibr" rid="scirp.66661-ref23">23</xref>] . A worst-case resource usage bound to compute the WCET overlap is used. Hence, it finds a WCET upper bound only, while our approach determines the exact WCET that includes stalling times.</p><p>Since the model-checking attempt in [<xref ref-type="bibr" rid="scirp.66661-ref24">24</xref>] has scalability problems the authors switched to the abstract execution approach of [<xref ref-type="bibr" rid="scirp.66661-ref25">25</xref>] . It allows to calculate safe approximations of the WCET of programs using threads, shared memory and locks. Locks are modeled in a spinlock-like fashion. The problem of nontermination is inherent in abstract execution. Thus, it is not guaranteed in [<xref ref-type="bibr" rid="scirp.66661-ref25">25</xref>] that the algorithm will terminate. This issue is only partly solved by setting timeouts.</p></sec><sec id="s7"><title>7. Conclusion and Future Work</title><p>In this paper, we focused on calculating stalling times automatically in an exact WCET analysis of shared memory concurrent programs running on a multi-core architecture. The stress was on a formal definition of both, our graph model and the dataflow equations for timing analysis. This is the first approach suited for parallel and concurrent systems.</p><p>We established a generic graph model for multi-threaded programs. Thread synchronization is modeled by semaphores. Our graph representation of multi-threaded programs plays a similar role for concurrent programs as control flow graphs do for sequential programs. Thus, a suitable graph model for timing analysis of multi- threaded software has been set up. The graph model serves as a framework for WCET analysis of multi-threaded concurrent programs. The usefulness of our approach has been proved by a lazy implementation of our extended Kronecker algebra. The implementation is very memory-efficient and has been parallelized to exploit modern many-core hardware architectures. Currently there is work in progress for a GPGPU implementation generating RCPGs. The first results are very promising.</p><p>We applied a generating functions approach. Dataflow equations are set up. The WCET is calculated by a non-linear function solver. Non-linearity is inherent to the multi-threaded WCET problem. The reasons are that (1) several copies of loops show up in the RCPG and (2) partial loop unrolling has to be done in certain cases. (1) implies that loop iteration numbers for loop copies have to be considered variable until the maximization process takes place. Thus, nested loops cause non-linear constraints to be handed to the function solver. (2) generates additional non-linear constraints.</p><p>In terms of WCET analysis a lot of work remains to be done. The focus of this paper is on how to model concurrent programs. One future work may be modelling hardware features. In general, without taking into account e.g. pipelining, shared cache, shared bus, branch prediction and prefetching, we might overestimate the WCET. Our approach could benefit from e.g. [<xref ref-type="bibr" rid="scirp.66661-ref26">26</xref>] - [<xref ref-type="bibr" rid="scirp.66661-ref28">28</xref>] which support shared L2 instruction caches.</p><p>Finding the best non-linear function solver is ongoing research. Mathematica<sup>&#211;</sup> was just the first attempt. This will probably lead to better maximization times. A direction of future work is to generalize for multiple threads running on one CPU core. We will investigate how an implicit path enumeration technique (IPET) approach [<xref ref-type="bibr" rid="scirp.66661-ref8">8</xref>] together with non-linear solvers can produce similar results to our approach. Finally, a possible direction for future work could be a WCET analysis of semaphore-based barrier implementations [<xref ref-type="bibr" rid="scirp.66661-ref5">5</xref>] .</p></sec><sec id="s8"><title>Cite this paper</title><p>Robert Mittermayr,Johann Blieberger, (2016) A Generic Graph Model for WCET Analysis of Multi-Core Concurrent Applications. Journal of Software Engineering and Applications,09,182-198. doi: 10.4236/jsea.2016.95015</p></sec><sec id="s9"><title>NOTES</title></sec></body><back><ref-list><title>References</title><ref id="scirp.66661-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Wilhelm, R., Engblom, J., Ermedahl, A., Holsti, N., Thesing, S., Whalley, D., Bernat, G., Ferdinand, C., Heckmann, R., Mitra, T., Mueller, F., Puaut, I., Puschner, P., Staschulat, J. and Stenstrom, P. (2008) The Worst-Case Execution-Time Problem—Overview of Methods and Survey of Tools. ACM Transactions on Embedded Computing Systems, 7, Article No. 36. http://dx.doi.org/10.1145/1347375.1347389</mixed-citation></ref><ref id="scirp.66661-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Ozaktas, H., Rochange, C. and Sainrat, P. (2013) Automatic WCET Analysis of Real-Time Parallel Applications. WCET 2013, 30, 11-20.</mixed-citation></ref><ref id="scirp.66661-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Buchholz, P. and Kemper, P. (2002) Efficient Computation and Representation of Large Reachability Sets for Composed Automata. Discrete Event Dynamic Systems, 12, 265-286. http://dx.doi.org/10.1023/A:1015669415634</mixed-citation></ref><ref id="scirp.66661-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Mittermayr, R. and Blieberger, J. (2012) Timing Analysis of Concurrent Programs. WCET 2012, 23, 59-68.</mixed-citation></ref><ref id="scirp.66661-ref5"><label>5</label><mixed-citation publication-type="book" xlink:type="simple">Mittermayr, R. and Blieberger, J. (2016) Kronecker Algebra for Static Analysis of Barriers in Ada (to Appear). In: Bertogna, M., Pinho, L.M. and Quinones, E., Eds., 21st International Conference on Reliable Software Technologies, LNCS, Springer Press.</mixed-citation></ref><ref id="scirp.66661-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Blieberger, J. (2002) Data-Flow Frameworks for Worst-Case Execution Time Analysis. Real-Time Systems, 22, 183-227. http://dx.doi.org/10.1023/A:1014535317056</mixed-citation></ref><ref id="scirp.66661-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Potop-Butucaru, D. and Puaut, I. (2013) Integrated Worst-Case Execution Time Estimation of Multicore Applications. WCET 2013, 30, 21-31.</mixed-citation></ref><ref id="scirp.66661-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Puschner, P. and Schedl, A. (1997) Computing Maximum Task Execution Times—A Graph-Based Approach. Journal of Real-Time Systems, 13, 67-91. http://dx.doi.org/10.1023/A:1007905003094</mixed-citation></ref><ref id="scirp.66661-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Tarjan, R.E. (1981) A Unified Approach to Path Problems. Journal of the ACM, 28, 577-593. 
http://dx.doi.org/10.1145/322261.322272</mixed-citation></ref><ref id="scirp.66661-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Stallings, W. (2011) Operating Systems—Internals and Design Principles. 7th Edition, Prentice Hall, Upper Saddle River.</mixed-citation></ref><ref id="scirp.66661-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Aho, A., Sethi, R. and Ullman, J. (1986) Compilers: Principles, Techniques, and Tools. Addison Wesley, Massachusetts.</mixed-citation></ref><ref id="scirp.66661-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Mittermayr, R. and Blieberger, J. (2011) Shared Memory Concurrent System Verification Using Kronecker Algebra. Technical Report 183/1-155, Automation Systems Group, TU Vienna. http://arxiv.org/abs/1109.5522</mixed-citation></ref><ref id="scirp.66661-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Davio, M. (1981) Kronecker Products and Shuffle Algebra. IEEE Transactions on Computers, 30, 116-125. 
http://dx.doi.org/10.1109/TC.1981.6312174</mixed-citation></ref><ref id="scirp.66661-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Graham, A. (1981) Kronecker Products and Matrix Calculus with Applications. Ellis Horwood Ltd., New York.</mixed-citation></ref><ref id="scirp.66661-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Harary, F. and Trauth Jr., C.A. (1966) Connectedness of Products of Two Directed Graphs. SIAM Journal on Applied Mathematics, 14, 250-254. http://dx.doi.org/10.1137/0114024</mixed-citation></ref><ref id="scirp.66661-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Küster, G. (1991) On the Hurwitz Product of Formal Power Series and Automata. Theoretical Computer Science, 83, 261-273. http://dx.doi.org/10.1016/0304-3975(91)90278-A</mixed-citation></ref><ref id="scirp.66661-ref17"><label>17</label><mixed-citation publication-type="book" xlink:type="simple">Burgstaller, B. and Blieberger, J. (2014) Kronecker Algebra for Static Analysis of Ada Programs with Protected Objects. In: George, L. and Vardanega, T., Eds., Reliable Software Technologies—Ada-Europe 2014, Springer International Publishing, New York, 27-42. http://dx.doi.org/10.1007/978-3-319-08311-7_4</mixed-citation></ref><ref id="scirp.66661-ref18"><label>18</label><mixed-citation publication-type="other" xlink:type="simple">Kirner, R., Knoop, J., Prantl, A., Schordan, M. and Kadlec, A. (2011) Beyond Loop Bounds: Comparing Annotation Languages for Worst-Case Execution Time Analysis. Software &amp; Systems Modeling, 10, 411-437.  
http://dx.doi.org/10.1007/s10270-010-0161-0</mixed-citation></ref><ref id="scirp.66661-ref19"><label>19</label><mixed-citation publication-type="other" xlink:type="simple">Volcic, M., Blieberger, J. and Schobel, A. (2012) Kronecker Algebra Based Travel Time Analysis for Railway Systems. 9th Symposium on Formal Methods for Automation and Safety in Railway and Automotive Systems, Braunschweig, 12-13 December 2012, 273-281.</mixed-citation></ref><ref id="scirp.66661-ref20"><label>20</label><mixed-citation publication-type="other" xlink:type="simple">Sreedhar, V.C., Gao, G.R. and Lee, Y.-F. (1998) A New Framework for Elimination-Based Data Flow Analysis Using DJ Graphs. ACM Transactions on Programming Languages and Systems, 20, 388-435.  
http://dx.doi.org/10.1145/276393.278523</mixed-citation></ref><ref id="scirp.66661-ref21"><label>21</label><mixed-citation publication-type="other" xlink:type="simple">Axer, P., Ernst, R., Falk, H., Girault, A., Grund, D., Guan, N., Jonsson, B., Marwedel, P., Reineke, J., Rochange, C., Sebastian, M., Von Hanxleden, R., Wilhelm, R. and Wang, Y. (2014) Building Timing Predictable Embedded Systems. ACM Transactions on Embedded Computing Systems, 13, Article No. 82. http://dx.doi.org/10.1145/2560033</mixed-citation></ref><ref id="scirp.66661-ref22"><label>22</label><mixed-citation publication-type="other" xlink:type="simple">Gerdes, M., Kluge, F., Ungerer, T. and Rochange, C. (2012) The Split-Phase Synchronisation Technique: Reducing the Pessimism in the WCET Analysis of Parallelised Hard Real-Time Programs. IEEE International Conference on Embedded and Real-Time Computing Systems and Applications, Seoul, 19-22 August 2012, 88-97.  
http://dx.doi.org/10.1109/rtcsa.2012.11</mixed-citation></ref><ref id="scirp.66661-ref23"><label>23</label><mixed-citation publication-type="other" xlink:type="simple">Nowotsch, J., Paulitsch, M., Buhler, D., Theiling, H., Wegener, S. and Schmidt, M. (2014) Multi-Core Interference-Sensitive WCET Analysis Leveraging Runtime Resource Capacity Enforcement. 26th Euromicro Conference on Real-Time Systems, Madrid, 8-11 July 2014, 109-118. http://dx.doi.org/10.1109/ecrts.2014.20</mixed-citation></ref><ref id="scirp.66661-ref24"><label>24</label><mixed-citation publication-type="other" xlink:type="simple">Gustavsson, A., Ermedahl, A., Lisper, B. and Pettersson, P. (2010) Towards WCET Analysis of Multicore Architectures Using UPPAAL. 10th International Workshop on Worst-Case Execution Time Analysis, Brussels, 6 July 2010, 101-112.</mixed-citation></ref><ref id="scirp.66661-ref25"><label>25</label><mixed-citation publication-type="book" xlink:type="simple">Gustavsson, A., Gustafsson, J. and Lisper, B. (2014) Timing Analysis of Parallel Software Using Abstract Execution. In: McMillan, K.L. and Rival, X., Eds., Lecture Notes in Computer Science, Springer, Berlin, 59-77.  
http://dx.doi.org/10.1007/978-3-642-54013-4_4</mixed-citation></ref><ref id="scirp.66661-ref26"><label>26</label><mixed-citation publication-type="other" xlink:type="simple">Chattopadhyay, S., Chong, L.K., Roychoudhury, A., Kelter, T., Marwedel, P. and Falk, H. (2012) A Unified WCET Analysis Framework for Multi-Core Platforms. IEEE 18th Real Time and Embedded Technology and Applications Symposium, Beijing, 16-19 April 2012, 99-108. http://dx.doi.org/10.1109/rtas.2012.26</mixed-citation></ref><ref id="scirp.66661-ref27"><label>27</label><mixed-citation publication-type="other" xlink:type="simple">Liang, Y., Ding, H.P., Mitra, T., Roychoudhury, A., Li, Y. and Suhendra, V. (2012) Timing Analysis of Concurrent Programs Running on Shared Cache Multi-Cores. Real-Time Systems, 48, 638-680.  
http://dx.doi.org/10.1007/s11241-012-9160-2</mixed-citation></ref><ref id="scirp.66661-ref28"><label>28</label><mixed-citation publication-type="other" xlink:type="simple">Yan, J. and Zhang, W. (2008) WCET Analysis for Multi-Core Processors with Shared L2 Instruction Caches. IEEE Real-Time and Embedded Technology and Applications Symposium, St. Louis, 22-24 April 2008, 80-89.  
http://dx.doi.org/10.1109/rtas.2008.6</mixed-citation></ref></ref-list></back></article>