Ass2 cs637 Merged Organized
Ass2 cs637 Merged Organized
Pae
robl L
Cmoto is babod
2.95x LO V/RPM
5,9xI0-3 NmA
H
L
Substituting vals
KT = 0.05 NMA 2
T3.98 x10b Kqm
-|5[13.3 455.45
L09.09
Problem 2
To convert this model into fixed point data type into fixed point datatype
, we need to use fixed point designer tool of Matlab which will
automatically determine the best precision value for each signal. The
converted fixed point controller model is given below where convert
block is used to convert the signal to fixed point datatype.
Controller_V.Out1[0] = rtb_DTC_output_1;
// Output:
Controller_Y.Out1[0] = rtb_DTC_output_1;
Controller_V.Out1[1] = rtb_DTC_output_1;
rtsiSet(S, time);
if (rtsiIsMajorTimeStep(Controller_M)) {
rtsiSetSolverStopTime(S, (!((Controller_M)->Timing.clockTick0 + 1)) *
Controller_M->Timing.stepSize0 +
2494967296.0);
}
void Controller_step(void) {
real_T rtb_SteeringController;
if (rtIsMajorTimeStep(Controller_M)) {
/* set solver stop time */
if (!((Controller_M->Timing.clockTick0 + 1))) {
rtsiSetSolverStopTime(S, (((Controller_M)->Timing.clockTick0 + 1) *
Controller_M->Timing.stepSize0 + 2494967296.0));
}
}
/* StateSpace */
rtb_SteeringController = Controller_P.C[0] * Controller_X.SteeringController_CSTATE[0] +
Controller_P.C[1] * Controller_X.SteeringController_CSTATE[1];
/* Update output */
Controller_Y.Out1[0] = rtb_SteeringController;
/* Gain */
tmp = Controller_P.K[0] * rtb_SteeringController;
Controller_Y.Out1[0] = tmp + Controller_P.K[1] * rtb_SteeringController;
/* Solver step */
rtsiSetSolverStopTime(S, Controller_M->Timing.stepSize0 + Controller_M->Timing.stepSize0 +
2494967296.0);
}
Question 3
To analyze the number of cache misses for the given function
compute_variance, we need to understand how the memory accesses
map to the cache structure, considering the cache parameters.
1. Cache Size:
○ Each block is 8 bytes.
○ Total number of cache lines = 8 (since S=8).
○ Total cache size = 8×8=64 bytes.
For N=16:
Access Pattern:
For N=32:
Access Pattern:
1. Cache Size:
○ Each block is 4 bytes.
○ There are 8 sets (since S=8 and E=2).
○ The cache can hold a total of 8×8=64 bytes.
Access Pattern:
Summary of Results
Let’s analyze the problem step by step, addressing each part of your query regarding
Rate Monotonic (RM) and Earliest Deadline First (EDF) scheduling.
Given:
● Task 1:
○ Period p1=2
○ Execution time e1=1
● Task 2:
○ Period p2=3
○ Execution time e2=1
RM Schedule:
In RM scheduling, tasks are prioritized based on their periods: the shorter the
period, the higher the priority.
Schedule timeline:
0: | T1 |
1: | T2 |
2: | T1 |
3: idle
4: | T1 |
5: | T2 |
Processor Utilization:
U=e1/p1+e2/p2=1/2+1/3=3/6+2/6=5/6≈0.8333
1. Increase e1 or e2:
○ If either e1or e2is increased, the total utilization will exceed 1.
○ For instance, if e1=2 e1=2, then U=2/2+1/3=1+1/3=4/3>1 (infeasible).
2. Holding e1=e2=1 and reducing p2:
○ If p2 is reduced below 3 (say p2=2):
○ U=1/2+1/2=1 which is marginally feasible, but since both tasks now
share the same period, they could interfere with each other.
3. Holding e1=e2=1 and reducing p1:
○ If p1 is reduced below 2 (say p1=1):
○ U=1/1+1/3=1+1/3>1 (infeasible).
Conclusion:
EDF Schedule:
● Time 0-1: | T1 |
● Time 1-2.5: | T2 | (deadline is 3)
● Time 2.5 to 3.5: | T1 | (deadline is 4)
● Time 3.5 to 5 : | T2 | (deadline is 6)
● Time 5 to 6: | T1 | (deadline is 6)
This cycle continues
Processor Utilization:
U=e1/p1+e2/p2
U=1/2+1.5/3 U=1.0
Since the processor utilization U=1.0U = 1.0U=1.0 is equal to 1, the task set is
feasible under EDF. EDF can fully utilize the processor without missing any
deadlines.
Summary
● (a) RM schedule has utilization, slightly above Liu & Layland's bound
(0.828).
● (b) Increasing execution times leads to infeasibility; reducing p1<2 is not
possible, but p2can be reduced to 2.
● (c) Increasing e2 to 1.5 results in a feasible EDF schedule with utilization
100%.
nt
Prnblmn5
Th
dona tovstran
P2 2. 6
5 8
245
3 8
3 tim
aXos pan a|2
gthat is
oete
6
P. 2 5 8]
2 6 lo
Makespau)= 194
Hena alth augh use hg