Skip to content
Snippets Groups Projects
Commit 63862a35 authored by ael-mess's avatar ael-mess
Browse files

adding svg gen + optimisation

parent bc2b3de9
Branches
No related tags found
No related merge requests found
Showing
with 1185 additions and 937 deletions
#include "pmutex.h"
#include "ptask.h"
#include "tstat.h"
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*--------------------------------------------------------------*/
void init() {
srand(time(NULL));
ptask_init(SCHED_FIFO, GLOBAL, PRIO_INHERITANCE);
}
/*--------------------------------------------------------------*/
void task() {
int i, a, b = 0;
i = ptask_get_index();
a = 2 + b;
dt = ptask_get_period(i, MILLI) / 100.;
while (1) {
while (b < 1000000) {
b++;
a = 2+b;
}
printf("%d - %d:%d \n", i, b, a);
ptask_wait_for_period();
}
}
/*--------------------------------------------------------------*/
/* MAIN process */
/*--------------------------------------------------------------*/
int main(void) {
init();
int i = task_create(task, 20, DREL, PRIO-i, NOW);
if (i != -1) printf("Task %d created and activated\n", i);
else exit(-1);
int j = task_create(task, PER, DREL, PRIO-j, NOW);
if (i != -1) printf("Task %d created and activated\n", i);
else exit(-1);
if ((k >= KEY_0) && (k <= KEY_9)) {
a = 2. * G * (float)TOP;
pthread_mutex_lock(&mxv);
v0[k - KEY_0] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
if ((k == KEY_O) && (ntasks > 9)) {
for (j = 10; j < ntasks; j++) {
h = rand() % (TOP - BASE);
a = 2. * G * (float)h;
pthread_mutex_lock(&mxv);
v0[j] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
}
if (k == KEY_A) {
for (j = 0; j < ntasks; j++) {
h = rand() % (TOP - BASE);
a = 2. * G * (float)h;
pthread_mutex_lock(&mxv);
v0[j] = sqrt(a);
pthread_mutex_unlock(&mxv);
}
}
/*
Printing deadline misses
TO BE DONE
for (j=0; j<ntasks; j++) {
sprintf(s, "%d", task_dmiss(j));
textout_ex(screen, font, s, 50+j*48, 450, 7, 0);
}
*/
} while (k != KEY_ESC);
printf("Now printing the stats\n");
for (j = 0; j < ntasks; j++) {
tspec wcet = ptask_get_wcet(j);
tspec acet = ptask_get_avg(j);
printf("TASK %d: WCET = %ld\t ACET = %ld\t NINST=%d\n", j,
tspec_to(&wcet, MICRO), tspec_to(&acet, MICRO),
ptask_get_numinstances(j));
}
printf("End of statistics\n");
allegro_exit();
return 0;
}
/*--------------------------------------------------------------*/
package com.event;
import java.math.BigInteger;
public class ptask_tracepoint extends userspace_tracepoint {
protected String flag = null;
protected String state = null;
protected Integer index = null;
protected Integer times = null;
protected Long times = null;
protected Integer prio = null;
protected Integer period = null;
protected Integer deadline = null;
public ptask_tracepoint(time_trace time, Integer cpu_id, String pid, String tid, String flag, String state, String idx, String tim, String prio, String peri, String dd) {
public ptask_tracepoint(time_trace time, Integer cpu_id, Integer pid, Integer tid, String flag, String state, Integer idx, String tim, Integer prio, Integer peri, Integer dd) {
BigInteger bigInt = new BigInteger(tim);
this.time = time;
this.cpu_id = cpu_id;
this.pid = Integer.valueOf(pid);
this.tid = Integer.valueOf(tid);
this.pid = pid;
this.tid = tid;
this.flag = flag;
this.state = state;
this.index = Integer.valueOf(idx);
this.times = Integer.valueOf(tim);
this.prio = Integer.valueOf(prio);
this.period = Integer.valueOf(peri);
this.deadline = Integer.valueOf(dd);
this.index = idx;
if(bigInt.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) this.times = Long.valueOf(tim);
this.prio = prio;
this.period = peri;
this.deadline = dd;
}
public String getFlag() {
......@@ -35,7 +39,7 @@ public class ptask_tracepoint extends userspace_tracepoint {
return this.index;
}
public Integer getTimes() {
public Long getTimes() {
return this.times;
}
......
......@@ -9,18 +9,18 @@ public class sched_switch extends kernel_tracepoint {
protected Integer next_prio = null;
protected Integer prev_state = null;
public sched_switch(time_trace time, Integer cpu_id, Integer pid, Integer tid, String pcomm, String ncomm, String ptid, String ntid, String pprio, String nprio, String ps) {
public sched_switch(time_trace time, Integer cpu_id, Integer pid, Integer tid, String pcomm, String ncomm, Integer ptid, Integer ntid, String pprio, String nprio, Integer ps) {
this.time = time;
this.cpu_id = cpu_id;
this.pid = pid;
this.tid = tid;
this.prev_comm = pcomm;
this.next_comm = ncomm;
this.prev_tid = Integer.valueOf(ptid);
this.next_tid = Integer.valueOf(ntid);
this.prev_tid = ptid;
this.next_tid = ntid;
this.prev_prio = Integer.valueOf(pprio);
this.next_prio = Integer.valueOf(nprio);
this.prev_state = Integer.valueOf(ps);
this.prev_state = ps;
}
public String getPrev_comm() {
......
......@@ -10,7 +10,7 @@ public class time_trace {
this.hour = (double) h;
this.minute = (double) m;
this.seconde = (double) s + Double.valueOf("0."+os);
this.delta = Double.valueOf(d);
if(!d.equals("?.?????????")) this.delta = Double.valueOf(d);
}
public void setTime(Double h, Double m, Double s, Double d) {
......
......@@ -3,22 +3,20 @@ package com;
import com.parser.*;
import com.event.*;
import com.task.*;
import com.printer.*;
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
public class main {
public static void main(String[] arg) {
parser_service parser = new parser_service("../test2.txt"); //secure path
task_service tasks = new task_service();
public static void main(String[] arg) throws IOException {
parser_service parser = new parser_service("../mytest.txt"); //secure path
task_service tasks = new task_service(parser.getTraces());
//System.out.println(parser.description());
System.out.println("");
//tasks.check();
System.err.println(tasks.description());
System.err.println("start:"+tasks.getStart()+" end:"+tasks.getEnd()+" nb task:"+tasks.getNb_task());
tasks.setTraces(parser.getTraces());
tasks.setTasks();
tasks.check();
//System.out.println(tasks.description());
printer_service printer = new printer_service(tasks);
}
}
......@@ -11,7 +11,7 @@ public class parser_service {
protected List<trace> traces = new ArrayList<>();
protected String file_name = null;
public parser_service(String file_name) {
public parser_service(String file_name) throws IOException {
try {
CharStream in = CharStreams.fromFileName(file_name);
traceLexer lexer = new traceLexer(in);
......@@ -19,7 +19,7 @@ public class parser_service {
traceParser parser = new traceParser(tokens);
this.traces = parser.start().traces;
} catch (IOException e) {
System.err.println("parser_service.const");
System.err.println("parser_service.const : file not found "+ file_name);
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -79,49 +79,13 @@ public class traceParserBaseListener implements traceParserListener {
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFields_exit_clone(traceParser.Fields_exit_cloneContext ctx) { }
@Override public void enterComm(traceParser.CommContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFields_exit_clone(traceParser.Fields_exit_cloneContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFields_entry_clone(traceParser.Fields_entry_cloneContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFields_entry_clone(traceParser.Fields_entry_cloneContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFields_sched_switch(traceParser.Fields_sched_switchContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFields_sched_switch(traceParser.Fields_sched_switchContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFields_ptask_tracepoint(traceParser.Fields_ptask_tracepointContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFields_ptask_tracepoint(traceParser.Fields_ptask_tracepointContext ctx) { }
@Override public void exitComm(traceParser.CommContext ctx) { }
/**
* {@inheritDoc}
*
......
......@@ -61,45 +61,15 @@ public interface traceParserListener extends ParseTreeListener {
*/
void exitContext(traceParser.ContextContext ctx);
/**
* Enter a parse tree produced by {@link traceParser#fields_exit_clone}.
* Enter a parse tree produced by {@link traceParser#comm}.
* @param ctx the parse tree
*/
void enterFields_exit_clone(traceParser.Fields_exit_cloneContext ctx);
void enterComm(traceParser.CommContext ctx);
/**
* Exit a parse tree produced by {@link traceParser#fields_exit_clone}.
* Exit a parse tree produced by {@link traceParser#comm}.
* @param ctx the parse tree
*/
void exitFields_exit_clone(traceParser.Fields_exit_cloneContext ctx);
/**
* Enter a parse tree produced by {@link traceParser#fields_entry_clone}.
* @param ctx the parse tree
*/
void enterFields_entry_clone(traceParser.Fields_entry_cloneContext ctx);
/**
* Exit a parse tree produced by {@link traceParser#fields_entry_clone}.
* @param ctx the parse tree
*/
void exitFields_entry_clone(traceParser.Fields_entry_cloneContext ctx);
/**
* Enter a parse tree produced by {@link traceParser#fields_sched_switch}.
* @param ctx the parse tree
*/
void enterFields_sched_switch(traceParser.Fields_sched_switchContext ctx);
/**
* Exit a parse tree produced by {@link traceParser#fields_sched_switch}.
* @param ctx the parse tree
*/
void exitFields_sched_switch(traceParser.Fields_sched_switchContext ctx);
/**
* Enter a parse tree produced by {@link traceParser#fields_ptask_tracepoint}.
* @param ctx the parse tree
*/
void enterFields_ptask_tracepoint(traceParser.Fields_ptask_tracepointContext ctx);
/**
* Exit a parse tree produced by {@link traceParser#fields_ptask_tracepoint}.
* @param ctx the parse tree
*/
void exitFields_ptask_tracepoint(traceParser.Fields_ptask_tracepointContext ctx);
void exitComm(traceParser.CommContext ctx);
/**
* Enter a parse tree produced by {@link traceParser#sint}.
* @param ctx the parse tree
......
package com.printer;
import java.awt.*;
import java.awt.geom.*;
public class form {
protected Graphics2D graph = null;
protected Shape line = null;
protected Shape rec = null;
protected Stroke stro = null;
protected String font = null;
public form(Graphics2D graph) {
this.graph = graph;
this.line = new Line2D.Double();
this.rec = new Rectangle2D.Double();
this.stro = new BasicStroke(0.4f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, new float[]{1,0}, 0);
this.graph.setPaint(Color.black);
this.font = "arial-plain-4";
this.setFont();
this.setStroke();
this.graph.setBackground(Color.white);
}
public void setFont() {
this.graph.setFont(Font.decode(this.font));
}
public void setStroke() {
this.graph.setStroke(stro);
}
public void arrow(String orio, Double x, Double y, Double size) {
if(orio.equals("up")) {
((Line2D.Double)this.line).setLine(x, y, x-size, y+size);
this.graph.draw(this.line);
((Line2D.Double)this.line).setLine(x, y, x+size, y+size);
this.graph.draw(this.line);
}
else if(orio.equals("right")) {
((Line2D.Double)this.line).setLine(x, y, x-size, y-size);
this.graph.draw(this.line);
((Line2D.Double)this.line).setLine(x, y, x-size, y+size);
this.graph.draw(this.line);
}
else if(orio.equals("down")) {
((Line2D.Double)this.line).setLine(x, y, x-size, y-size);
this.graph.draw(this.line);
((Line2D.Double)this.line).setLine(x, y, x+size, y-size);
this.graph.draw(this.line);
}
}
public void wakeLine(Double x, Double yh, Double yl) {
Stroke wakeS = new BasicStroke(0.3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, new float[]{2,2}, 0);
this.graph.setStroke(wakeS);
this.graph.setPaint(Color.blue);
((Line2D.Double)this.line).setLine(x, yh, x, yl);
this.graph.draw(this.line);
this.graph.setStroke(this.stro);
this.arrow("up", x, yl, 1.0);
this.graph.setPaint(Color.black);
wakeS = null;
}
public void deadLine(Double x, Double yh, Double yl) {
Stroke deadS = new BasicStroke(0.3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 0, new float[]{3,3}, 0);
this.graph.setStroke(deadS);
this.graph.setPaint(Color.red);
((Line2D.Double)this.line).setLine(x, yh, x, yl);
this.graph.draw(this.line);
this.graph.setStroke(this.stro);
this.arrow("down", x, yh, 1.0);
this.graph.setPaint(Color.black);
deadS = null;
}
public void axis(Double width, Double height, Double scale) {
((Line2D.Double)this.line).setLine(0.0, height, width, height);
this.graph.draw(this.line);
((Line2D.Double)this.line).setLine(0.0, height, 0.0, 0.0);
this.graph.draw(this.line);
this.arrow("right", width, height, 2.0);
this.arrow("up", 0.0, 0.0, 2.0);
for(double h=0.0; h*scale<width; h+=1.0) {
((Line2D.Double)this.line).setLine(h*scale, height, h*scale, height+2);
this.graph.draw(this.line);
}
for(double h=0.0; h*scale<width; h+=0.20) {
((Line2D.Double)this.line).setLine(h*scale, height, h*scale, height+1);
this.graph.draw(this.line);
}
}
public void job(Double x, Double y, Double width, Double height, Color col) {
((Rectangle2D.Double)this.rec).setRect(x, y, width, height);
this.graph.setPaint(col);
this.graph.fill(rec);
this.graph.setPaint(Color.black);
this.graph.draw(rec);
}
}
package com.printer;
import com.task.*;
import java.io.IOException;
public class printer_service {
protected svggen svg = null;
protected task_service tasks = null;
public printer_service(task_service t) throws IOException {
this.tasks = t;
this.svg = new svggen(t);
svg.setCanvas();
this.draw_tasks();
svg.streamOut();
}
public void draw_tasks() {
double h = 0.0;
double w = 0.0;
double x = 0.0;
double y = this.svg.getTask_hei();
boolean started = false;
boolean switched = false;
int test = 0;
for(task t : this.svg.getTasks()) {
test = 0;
for(t_event t_e : t.getEvents()) {
switch(t_e.getType()) {
case START :
started = true;
x = (t_e.getValue() - this.svg.getStart())*this.svg.getScale();
break;
case FINISH :
if(started && !switched) {
started = false;
w = (t_e.getValue() - this.svg.getStart())*this.svg.getScale() - x;
this.svg.getForm().job(x, h*y, w, y, t.getColor());
System.err.println("Finish x:"+x+" y:"+h*y+" w:"+w+" h:"+y);
test++;
}
break;
case SWITCH_OUT :
if(started && !switched) {
switched = true;
w = (t_e.getValue() - this.svg.getStart())*this.svg.getScale() - x;
this.svg.getForm().job(x, h*y, w, y, t.getColor());
System.err.println("Switch out x:"+x+" y:"+h*y+" w:"+w+" h:"+y);
test++;
}
break;
case SWITCH_IN :
if(started && switched) {
switched = false;
x = (t_e.getValue() - this.svg.getStart())*this.svg.getScale();
}
break;
}
}
h += 1.0;
System.err.println(" Task:"+t.getName()+" (nb of actions = "+test+")");
}
}
}
package com.printer;
import com.task.*;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.awt.*;
import java.awt.geom.*;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.svggen.SVGGeneratorContext;
import org.apache.batik.dom.GenericDOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
public class svggen {
protected Document doc = null;
protected SVGGeneratorContext ctx = null;
protected SVGGraphics2D svgGenerator = null;
protected form f = null;
protected Double start = 0.0;
protected Double height = 0.0;
protected Double width = 0.0;
protected Double scale = 1000.0;
protected Double task_hei = 20.0;
protected List<task> tasks = null;
public svggen(task_service serv) {
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
this.doc = domImpl.createDocument(svgNS, "svg", null);
this.ctx = SVGGeneratorContext.createDefault(this.doc);
this.svgGenerator = new SVGGraphics2D(ctx, false);
this.f = new form((Graphics2D)this.svgGenerator);
this.tasks = serv.getTasks();
this.start = serv.getStart();
this.width = (serv.getEnd() - this.start) * this.scale;
this.height = serv.getNb_task() * this.task_hei;
}
public Double getStart() {
return this.start;
}
public Double getTask_hei() {
return this.task_hei;
}
public Double getHeight() {
return this.height;
}
public Double getWidth() {
return this.width;
}
public Double getScale() {
return this.scale;
}
public List<task> getTasks() {
return this.tasks;
}
public form getForm() {
return this.f;
}
public void setCanvas() {
this.svgGenerator.setSVGCanvasSize(new Dimension(this.width.intValue()+1+100, this.height.intValue()+1+50));
this.svgGenerator.translate(0, 25);
this.setText();
this.svgGenerator.translate(50, 0);
this.setTInfo();
}
private void setText() {
int h = 0;
for(task t : this.tasks) {
this.svgGenerator.drawString("Task"+t.getName()+" TID:"+t.getId()+": CPU:"+t.getCpu_id(), 10.0f, (float)(this.task_hei*(h+0.5)));
this.svgGenerator.drawString("(P:"+t.getPeriod()/1000.0+"ms D:"+t.getDeadline()/1000.0+"ms)", 5.0f, (float)(this.task_hei*(h+0.75)));
h+=1.0;
}
}
private void setTInfo() {
int h = 0;
int period = 0, deadline = 0;
Double start = null;
for(task t : this.tasks) {
period = t.getPeriod();
deadline = t.getDeadline();
start = t.getStart();
if(period != 0 && deadline != 0 && start!=null) for(int nb_period=0; ((start-this.start+((nb_period/1000000.0)*period))*this.scale)<this.width; nb_period++) {
this.f.wakeLine((start - this.start + (nb_period/1000000.0)*period)*this.scale, (1+h)*this.task_hei, h*this.task_hei);
this.f.deadLine((start - this.start + (nb_period/1000000.0)*deadline)*this.scale, (1+h)*this.task_hei, h*this.task_hei);
}
h++;
}
this.f.axis(this.width, this.height, period*this.scale/1000000.0);
this.svgGenerator.setFont(Font.decode("arial-plain-2"));
for(int nb_period=0; ((nb_period/1000000.0)*period*this.scale*2)<this.width; nb_period+=1) this.svgGenerator.drawString(""+String.format("%.3f", ((nb_period/1000.0)*period*2))+"ms", (float)((nb_period/1000000.0)*period*this.scale*2.0f), (float)(this.height+5.0f));
this.f.setFont();
start = null;
}
public void streamOut() throws IOException {
Boolean useCSS = true;
try {
Writer out = new OutputStreamWriter(System.out, "UTF-8");
this.svgGenerator.stream(out, useCSS);
} catch (IOException e) {
System.err.println("streamout.const : file not found ");
}
useCSS = null;
}
}
package com.task;
public enum Types { START, FINISH, SWITCH_IN, SWITCH_OUT; }
package com.task;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
public class os_task extends task {
protected Map<Integer, String> tids = null;
public Map<Integer, String> getTids() {
return this.tids;
}
public void setTids(Map<Integer, String> tids) {
this.tids = tids;
}
}
package com.task;
enum Types { START, FINISH, SWITCH_IN, SWITCH_OUT }
public class t_event {
protected Double value = null;
protected Types type = null;
......
......@@ -10,23 +10,39 @@ public class task_service {
protected List<trace> traces = null;
protected Integer nb_cpu = 0;
protected Integer nb_task = 0;
protected Double start = 0.0;
protected Double end = 0.0;
public void setTraces(List<trace> traces) {
public task_service(List<trace> traces) {
this.traces = traces;
for(trace tr : this.traces) if((tr.getCpu_id()+1)>this.nb_cpu) this.nb_cpu = tr.getCpu_id()+1;
this.tasks = new ArrayList<>();
List<Integer> tids = new ArrayList<>();
for(trace tr : this.traces) {
if((tr.getCpu_id()+1)>this.nb_cpu) this.nb_cpu = tr.getCpu_id()+1;
if(tr instanceof ptask_tracepoint && !tids.contains(tr.getTid())) tids.add(tr.getTid());
}
for(trace tr : this.traces) if(tr instanceof ptask_tracepoint && tids.remove(tr.getTid())) this.setTask(tr);
this.nb_task = this.tasks.size();
this.start = this.traces.get(0).getTime().getTime("seconde");
this.end = this.traces.get(traces.size()-1).getTime().getTime("seconde");
tids = null;
}
public Integer getNb_cpu() {
return this.nb_cpu;
private void setMainTask(trace tr) {
task t = new task();
this.tasks.add(t);
t.setId(tr.getTid());
t.setCpu_id(tr.getCpu_id());
t.setName(((ptask_tracepoint) tr).getIndex());
t.setPeriod(((ptask_tracepoint) tr).getPeriod());
t.setDeadline(((ptask_tracepoint) tr).getDeadline());
t.setColor();
this.setEvents(t);
t = null;
}
public void setTasks() {
task t;
this.tasks = new ArrayList<>();
List<Integer> tids = new ArrayList<>();
for(trace tr : this.traces) if(tr instanceof ptask_tracepoint && !tids.contains(tr.getTid())) tids.add(tr.getTid());
for(trace tr : this.traces) if(tr instanceof ptask_tracepoint && tids.remove(tr.getTid())) {
t = new task();
private void setTask(trace tr) {
task t = new task();
this.tasks.add(t);
t.setId(tr.getTid());
t.setCpu_id(tr.getCpu_id());
......@@ -37,14 +53,27 @@ public class task_service {
this.setEvents(t);
t = null;
}
this.nb_task = this.tasks.size();
tids = null;
public Integer getNb_cpu() {
return this.nb_cpu;
}
public Integer getNb_task() {
return this.nb_task;
}
public Double getStart() {
return this.start;
}
public Double getEnd() {
return this.end;
}
public List<task> getTasks() {
return this.tasks;
}
public Integer getNb_task_per_cpu(Integer cpu_id) {
List<Integer> tids = new ArrayList<>();
for(trace tr : this.traces) if(tr.getCpu_id().equals(cpu_id) && !tids.contains(tr.getTid())) tids.add(tr.getTid());
......@@ -52,21 +81,46 @@ public class task_service {
}
public void check() {
Integer nb = 0;
int nb = 0;
for(int i=0; i<this.nb_cpu; i++) nb += this.getNb_task_per_cpu(i);
if(nb != this.getNb_task()) { System.out.println(" Unknown trace (nb of trace = "+this.getNb_task()+"!="+nb+")"); }
if(nb != this.getNb_task()) { System.err.println(" Unknown trace (nb of trace = "+this.getNb_task()+"!="+nb+")"); }
nb = this.traces.get(0).getPid();
for(trace tr : this.traces) if(!tr.getPid().equals(nb)) { System.out.println(" Unknown pid (pid = "+tr.getPid()+"!="+nb+")"); }
for(trace tr : this.traces) if(!tr.getPid().equals(nb)) { System.err.println(" Unknown pid (pid = "+tr.getPid()+"!="+nb+")"); }
boolean started = false;
for(task t : this.tasks) {
nb = 0;
for(t_event t_e : t.getEvents()) {
if(t_e.getType().equals(Types.START)) {
started = true;
nb ++;
}
else if(t_e.getType().equals(Types.FINISH)) started = false;
else if(t_e.getType().equals(Types.SWITCH_OUT) && started) nb++;
}
System.err.println(" Task:"+t.getName()+" (nb of actions = "+nb+")");
}
}
private void setEvents(task t) {
List<t_event> events = new ArrayList<>();
int i = 0, idx = 0;
boolean once = true;
for(trace tr : this.traces) {
i = 0;
if(t.getId().equals(tr.getTid())) {
if(tr instanceof clone_exit && (((clone_exit) tr).getRet().equals(0))) t.setStart(tr.getTime().getTime("seconde"));
if(tr instanceof clone_exit && (((clone_exit) tr).getRet().equals(0))) {
t.setStart(tr.getTime().getTime("seconde"));
idx = i;
}
else if(tr instanceof ptask_tracepoint) {
if(((ptask_tracepoint) tr).getFlag().equals("\"NOW\"")) t.setState(true);
if(((ptask_tracepoint) tr).getFlag().equals("\"NOW\"")) {
t.setState(true);
if(once && t.getStart()!=null) events.add(idx, new t_event(Types.START, t.getStart()));
once = false;
}
i++;
if(t.isActivated()) {
if(((ptask_tracepoint) tr).getState().equals("\"b_wait_period\"")) events.add(new t_event(Types.FINISH, tr.getTime().getTime("seconde")));
......@@ -79,9 +133,15 @@ public class task_service {
events.add(new t_event(Types.START, tr.getTime().getTime("seconde")));
}
}
else if(tr instanceof sched_switch) events.add(new t_event(Types.SWITCH_OUT, tr.getTime().getTime("seconde"), ((sched_switch) tr).getNext_tid()));
else if(tr instanceof sched_switch) {
events.add(new t_event(Types.SWITCH_OUT, tr.getTime().getTime("seconde"), ((sched_switch) tr).getNext_tid()));
i++;
}
}
else if(tr instanceof sched_switch && t.getId().equals(((sched_switch) tr).getNext_tid())) {
events.add(new t_event(Types.SWITCH_IN, tr.getTime().getTime("seconde"), ((sched_switch) tr).getPrev_tid()));
i++;
}
else if(tr instanceof sched_switch && t.getId().equals(((sched_switch) tr).getNext_tid())) events.add(new t_event(Types.SWITCH_IN, tr.getTime().getTime("seconde"), ((sched_switch) tr).getPrev_tid()));
}
t.setEvents(events);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment