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.isstation(ind) && isfield(sn,'impatienceClass') && ~isempty(sn.impatienceClass) ...
24 && sn.impatienceClass(sn.nodeToStation(ind),r) == ImpatienceType.RENEGING ...
25 && sn.impatienceType(sn.nodeToStation(ind),r) == ProcessType.EXP
26 % Reneging action (exponential patience): a waiting class-r job
27 % abandons the queue at a memoryless per-job rate; the job leaves
28 % the system (passive LOCAL, mirroring the phase-change action).
29 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
30 sync{end,1}.active{1} = Event(EventType.RENEGE, ind, r);
31 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
32 end
33 if sn.isstation(ind) && isfield(sn,'retrialProc') && ~isempty(sn.retrialProc) ...
34 && ~isempty(sn.retrialProc{sn.nodeToStation(ind),r}) ...
35 && sn.retrialType(sn.nodeToStation(ind),r) == ProcessType.EXP
36 % see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync) for rationale
37 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
38 sync{end,1}.active{1} = Event(EventType.RETRY, ind, r);
39 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
40 end
41 if sn.isstation(ind) && r == 1 && isfield(sn,'hasbreakdown') && ~isempty(sn.hasbreakdown) ...
42 && numel(sn.hasbreakdown) >= ind && sn.hasbreakdown(ind) == 1
43 % Server failure and repair actions. Both are properties of the
44 % SERVER, not of a class, so exactly one pair is emitted per station
45 % (guarded on r == 1) rather than one pair per class. Like the
46 % phase-change action they move no job, so the passive half is LOCAL.
47 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
48 sync{end,1}.active{1} = Event(EventType.FAILURE, ind, r);
49 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
50 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
51 sync{end,1}.active{1} = Event(EventType.REPAIR, ind, r);
52 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
53 end
54 if sn.isstation(ind) && sn.sched(sn.nodeToStation(ind)) == SchedStrategy.POLLING
55 % see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync) for rationale
56 pinfoSync = State.pollingInfo(sn, ind);
57 if ~isempty(pinfoSync) && pinfoSync.hasSw(r)
58 sync{end+1,1} = struct('active',cell(1),'passive',cell(1));
59 sync{end,1}.active{1} = Event(EventType.SWITCH, ind, r);
60 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, r, 1.0);
61 end
62 end
63 if sn.isstateful(ind)
64 if sn.nodetype(ind) == NodeType.Cache
65 if ~isnan(sn.nodeparam{ind}.pread{r}) % class can read
66 sync{end+1,1}.active{1} = Event(EventType.READ, ind, r);
67 sync{end,1}.passive{1} = Event(EventType.READ, local, r, 1.0);
68 end
69 elseif sn.nodetype(ind) == NodeType.Transition
70 for m=1:sn.nodeparam{ind}.nmodes
71 % server phase change
72 sync{end+1,1}.active{1} = Event(EventType.PHASE, ind, m);
73 sync{end,1}.passive{1} = Event(EventType.LOCAL, local, m, 1.0);
74 end
75 end
76 if sn.nodetype(ind) == NodeType.Fork
77 % Stateful Fork nodes (FJ-augmented copies) do not emit
78 % departure syncs: the atomic multi-branch emission is
79 % handled by the fork firing synchronizations (sn.fjsync)
80 continue
81 end
82 isf = sn.nodeToStateful(ind);
83 for jnd=1:sn.nnodes
84 if sn.isstateful(jnd)
85 jsf = sn.nodeToStateful(jnd);
86 for s=1:nclasses
87 p = rtmask((isf-1)*nclasses+r,(jsf-1)*nclasses+s);
88 if p > 0
89 new_sync = struct('active',cell(1),'passive',cell(1));
90 new_sync.active{1} = Event(EventType.DEP, ind, r);
91 switch sn.routing(ind,s)
92 case {RoutingStrategy.RROBIN, RoutingStrategy.WRROBIN, RoutingStrategy.JSQ, RoutingStrategy.RL, RoutingStrategy.SQ}
93 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));
94 otherwise
95 new_sync.passive{1} = Event(EventType.ARV, jnd, s, sn.rt((isf-1)*nclasses+r, (jsf-1)*nclasses+s));
96 end
97 sync{end+1,1} = new_sync;
98 end
99 end
100 end
101 end
102 end
103 end
104end
105if ~isempty(self.sn) %&& isprop(self.sn,'nvars')
106 self.sn.sync = sync;
107end
108end
Definition fjtag.m:161