LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
refreshSync.m
1function sync = refreshSync(self)
2% SYNC = REFRESHSYNC()
3
4sn = self.sn;
5local = self.getNumberOfNodes+1;
6nclasses = sn.nclasses;
7sync = {};
8emptystate = cellzeros(sn.nnodes,1,0,0);
9if any(sn.isstatedep(:))
10 rtmask = self.sn.rtfun(emptystate, emptystate);
11else
12 rtmask = ceil(self.sn.rt);
13end
14
15for ind=1:sn.nnodes
16 for r=1:sn.nclasses
17 if sn.isstation(ind) && sn.phases(sn.nodeToStation(ind),r)> 1
18 % Phase-change action
19 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
20 sync{end,1}.active{1} = Event(EventType.PHASE, ind, r);
21 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
22 end
23 if sn.isstateful(ind)
24 if sn.nodetype(ind) == NodeType.Cache
25 if ~isnan(sn.nodeparam{ind}.pread{r}) % class can read
26 sync{end+1,1}.active{1} = Event(EventType.READ, ind, r);
27 sync{end,1}.passive{1} = Event(EventType.READ, local, r, 1.0);
28 end
29 elseif sn.nodetype(ind) == NodeType.Transition
30 for m=1:sn.nodeparam{ind}.nmodes
31 % server phase change
32 sync{end+1,1}.active{1} = Event(EventType.PHASE, ind, m);
33 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, m, 1.0);
34 end
35 end
36 isf = sn.nodeToStateful(ind);
37 for jnd=1:sn.nnodes
38 if sn.isstateful(jnd)
39 jsf = sn.nodeToStateful(jnd);
40 for s=1:nclasses
41 p = rtmask((isf-1)*nclasses+r,(jsf-1)*nclasses+s);
42 if p > 0
43 new_sync = struct('active',cell(1),'passive',cell(1));
44 new_sync.active{1} = Event(EventType.DEP, ind, r);
45 switch sn.routing(ind,s)
46 case {RoutingStrategy.RROBIN, RoutingStrategy.WRROBIN, RoutingStrategy.JSQ, RoutingStrategy.RL}
47 new_sync.passive{1} = Event(EventType.ARV, jnd, s, @(state_before, state_after) at(self.sn.rtfun(state_before, state_after), (isf-1)*nclasses+r, (jsf-1)*nclasses+s));
48 otherwise
49 new_sync.passive{1} = Event(EventType.ARV, jnd, s, sn.rt((isf-1)*nclasses+r, (jsf-1)*nclasses+s));
50 end
51 sync{end+1,1} = new_sync;
52 end
53 end
54 end
55 end
56 end
57 end
58end
59if ~isempty(self.sn) %&& isprop(self.sn,'nvars')
60 self.sn.sync = sync;
61end
62end