Class Climate Surveys and Course Overview

S
E
3
9
1
0
W
e
e
k
 
1
0
,
 
C
l
a
s
s
 
3
Today
Class Climate Surveys
All quizzes & exams from this quarter:
https://faculty-web.msoe.edu/yoder/se3910/quizzes/
SE-2811
Slide design: Dr. Mark L. Hornick
Content: Dr. Hornick
Errors: Dr. Yoder
1
R
e
v
i
e
w
Overview of course
Muddiest Point of the quarter
Practice Exercises from quarter
TBA?: Graphical Overview of course
TBA?: Review material for multithreading
based on my review of your final projects
SE-2811
Dr.Yoder
2
W
h
a
t
 
i
s
/
w
a
s
 
S
E
3
9
1
0
 
a
b
o
u
t
?
Embedded Systems
Terminology
Electronics and Interfacing
Low-level I/O (simple digital input and output)
Real-Time Systems
Terminology
Meeting deadlines
Predicting and measuring latency
Predicting bandwidth, both analog and digital
Scheduling, especially RMA
Multithreading
SE-2811
Dr.Yoder
3
R
E
A
L
-
T
I
M
E
 
S
Y
S
T
E
M
S
It’s got to be fast… or does it?
SE-2811
Dr.Yoder
4
E
x
e
r
c
i
s
e
Select all that are real-time systems
a.
Video Game
b.
Aircraft Autopilot
c.
Refinery Process Control
d.
Cash Register
e.
Smartphone
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
5
E
x
e
r
c
i
s
e
Select all that are embedded systems
a.
Video Game
b.
Aircraft Autopilot
c.
Refinery Process Control
d.
Cash Register
e.
Smartphone
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
6
C
I
R
C
U
I
T
S
What fun to wire and smoke…
SE-2811
Dr.Yoder
7
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
 
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
8
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
 
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
9
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
10
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
11
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
12
E
x
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
e
s
i
s
t
a
n
c
e
 
o
f
t
h
i
s
 
r
e
s
i
s
t
o
r
?
13
O
R
A
N
G
E
 
O
R
A
N
G
E
 
V
I
O
L
E
T
 
G
O
L
D
E
x
:
 
G
P
I
O
 
s
a
f
e
t
y
Considering any one of the resistors on the
previous slides, is it large enough to not
damage a GPIO pin configured as output, if the
resistor ties the output to ground?
Sourcing limit: 4mA
Sinking limit: 8mA
Voltage: 3.3 V
SE-2811
Dr.Yoder
14
E
x
:
 
G
P
I
O
 
s
a
f
e
t
y
C
o
n
s
i
d
e
r
i
n
g
 
a
n
y
 
o
n
e
 
o
f
 
t
h
e
 
r
e
s
i
s
t
o
r
s
 
o
n
 
t
h
e
p
r
e
v
i
o
u
s
 
s
l
i
d
e
s
,
 
i
s
 
i
t
 
l
a
r
g
e
 
e
n
o
u
g
h
 
t
o
 
n
o
t
d
a
m
a
g
e
 
a
 
G
P
I
O
 
p
i
n
 
c
o
n
f
i
g
u
r
e
d
 
a
s
 
o
u
t
p
u
t
,
 
i
f
 
t
h
e
r
e
s
i
s
t
o
r
 
t
i
e
s
 
t
h
e
 
o
u
t
p
u
t
 
t
o
 
3
.
3
V
?
Sourcing limit: 4mA
Sinking limit: 8mA
Voltage: 3.3 V
SE-2811
Dr.Yoder
15
E
x
:
W
h
a
t
 
i
s
 
t
h
e
 
v
o
l
t
a
g
e
 
a
c
r
o
s
s
 
R
2
?
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
16
E
x
:
 
C
o
m
p
u
t
e
 
v
o
l
t
a
g
e
 
a
c
r
o
s
s
C
1
 
If S1 is closed, and
S2 is opened, what is
the voltage across
C1?
If S2 is closed, and
S1 is opened?
I
f
 
b
o
t
h
 
a
r
e
 
o
p
e
n
e
d
?
I
f
 
b
o
t
h
 
a
r
e
 
c
l
o
s
e
d
?
SE-2811
Dr.Yoder
17
E
x
:
 
C
o
m
p
u
t
e
 
v
o
l
t
a
g
e
 
i
n
t
o
 
G
P
I
O
 
If S1 is open and S2
is closed, compute
the voltage from
GPIO 12 to ground.
(Assume GPIO 12 is
not connected to
anything)
SE-2811
Dr. Yoder
18
E
x
:
 
W
h
a
t
s
 
w
r
o
n
g
 
w
i
t
h
 
t
h
i
s
s
i
m
p
l
e
 
c
i
r
c
u
i
t
s
 
i
n
p
u
t
?
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
19
E
x
:
 
W
h
a
t
s
 
w
r
o
n
g
 
w
i
t
h
 
t
h
i
s
c
i
r
c
u
i
t
?
 
(
T
h
e
 
w
o
r
s
t
 
t
h
i
n
g
)
 
SE-3910
Dr.Yoder
20
E
x
e
r
c
i
s
e
:
 
F
i
n
d
 
a
l
l
 
o
f
:
Voltage from
GPIO to ground
if
S1 is closed
S2 is closed
Both are open
Current from
source if both
are closed
SE-2811
Dr.Yoder
21
S
e
l
e
c
t
i
n
g
 
a
n
 
L
E
D
 
r
e
s
i
s
t
a
n
c
e
v
a
l
u
e
 
Suppose L1 is a
diode with 
V
d
 = 1.8 
V
Ex: Write a formula
relating the current
through L1 to R1.
Ex: Solve for R1 if we
want the (max)
current to be 10 mA.
SE-2811
Dr.Yoder
22
C
 
L
A
N
G
U
A
G
E
It’s like Java, only with pointers…
SE-2811
Dr Yoder
23
(
E
x
t
r
a
 
E
x
e
r
c
i
s
e
)
Why  does this
6
 
unsigned short *pt;
7
 
pt = myArray[0];
Produce this?
myLib.c:7: error: data definition has no type or storage class
myLib.c:7: error: type defaults to 'int' in declaration of 'pt'
myLib.c:7: error: conflicting types for 'pt'
myLib.c:6: note: previous declaration of 'pt' was here
myLib.c:7: error: initialization makes integer from pointer without a cast
How should it be written?
Are these compile or link errors?
http://stackoverflow.com/questions/6639256/poi
nter-to-first-element-in-array-c
SE-2811
Dr Yoder
24
E
x
e
r
c
i
s
e
:
 
W
h
i
c
h
 
o
f
 
t
h
e
f
o
l
l
o
w
i
n
g
 
i
s
 
c
o
r
r
e
c
t
?
void foo(struct bar2* b);
struct bar b;
And then….
foo((struct bar2*) b*)
foo((bar2*) *b)
foo((bar2*) b&)
foo((struct bar2*) &b)
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
25
E
x
e
r
c
i
s
e
How do you get a reference (pointer) to the first
element in an array?
int x[5] = {1,2,3,4,5}
boolean foo(int *ip);
a)
foo(&x);
b)
foo(&x[0]);
c)
foo(x);
d)
foo(x[0]);
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
26
E
x
e
r
c
i
s
e
H
o
w
 
d
o
 
y
o
u
 
g
e
t
 
a
 
r
e
f
e
r
e
n
c
e
 
(
p
o
i
n
t
e
r
)
 
t
o
 
t
h
e
s
e
c
o
n
d
 
e
l
e
m
e
n
t
 
i
n
 
a
n
 
a
r
r
a
y
?
int x[5] = {1,2,3,4,5}
boolean foo(int *ip);
a)
foo(&x+1);
b)
foo(&x[0]);
c)
foo(x+1);
d)
foo(x[0]);
e)
foo(&(x+1));
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
27
E
x
:
 
C
/
C
+
+
 
(
R
e
v
i
e
w
)
Why do we have both .h and .cpp file
extensions for C++?  Why not just have .cpp
(like .java for Java classes)?
Answer these questions:
1.
What should you put into a class’s .h file?
2.
What should you put into a class’s .cpp file?
[
N
o
t
e
:
 
O
n
 
n
e
x
t
 
l
a
b
,
 
u
s
e
 
.
h
p
p
 
a
n
d
 
.
c
p
p
 
i
n
s
t
e
a
d
o
f
 
.
h
 
a
n
d
 
.
c
p
p
]
SE-2811
Dr.Yoder
28
E
x
:
 
C
/
C
+
+
C
i
r
c
l
e
 
t
h
e
 
l
i
n
k
-
t
i
m
e
 
e
r
r
o
r
s
.
 
B
o
x
 
t
h
e
 
c
o
m
p
i
l
e
-
t
i
m
e
c
a
n
n
o
t
 
f
i
n
d
 
-
l
a
s
o
u
n
d
 
[
N
E
W
!
!
!
 
(
A
s
 
o
f
 
Q
u
i
z
 
5
)
]
syntax error
warning: implicit declaration of function `...'
point.m:40: error: ‘mypoint’ undeclared (first use in
this function)
parse error before `...‘
collect2: ld returned 1 exit status
undefined reference to `filterText'
/usr/lib/crt1.o(.text+0x18): undefined reference to
`main '
SE-2811
Dr.Yoder
29
Q
u
i
z
 
P
r
a
c
t
i
c
e
:
 
C
/
C
+
+
C
i
r
c
l
e
 
t
h
e
 
l
i
n
k
-
t
i
m
e
 
e
r
r
o
r
s
.
 
B
o
x
 
t
h
e
 
c
o
m
p
i
l
e
-
t
i
m
e
syntax error
point.m:40: error: ‘mypoint’ undeclared (first use in
this function)
collect2: ld returned 1 exit status
/usr/lib/crt1.o(.text+0x18): undefined reference to
`main '
parse error before `...‘
undefined reference to `filterText'
warning: implicit declaration of function `...'
SE-2811
Dr.Yoder
30
O
t
h
e
r
 
Q
u
i
z
 
S
u
b
j
e
c
t
s
Creating a signal from sine waves
Frequency content of a signal
Analog bandwidth
Stroboscopic effect
Why some cables can carry more data than
others
Even more outcomes on outcomes page, if
desired
SE-2811
Dr.Yoder
31
S
I
G
N
A
L
S
Wiggly and squiggly…
SE-2811
Dr.Yoder
32
E
x
e
r
c
i
s
e
:
 
W
h
a
t
 
i
s
 
t
h
e
 
t
i
m
e
d
e
l
a
y
 
b
e
t
w
e
e
n
 
t
h
e
 
t
w
o
 
f
a
l
l
i
n
g
e
d
g
e
s
?
 
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
33
E
x
e
r
c
i
s
e
:
 
W
h
a
t
 
i
s
 
t
h
e
 
t
i
m
e
d
e
l
a
y
 
b
e
t
w
e
e
n
 
t
h
e
 
t
w
o
 
f
a
l
l
i
n
g
e
d
g
e
s
?
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
34
5
 
m
s
 
/
 
D
i
v
E
x
e
r
c
i
s
e
:
 
W
h
a
t
 
i
s
 
t
h
e
 
r
i
s
e
-
t
i
m
e
o
f
 
t
h
i
s
 
s
i
g
n
a
l
?
 
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
35
0
1 Volt/div
 
1 ms/div
D
A
T
A
-
R
A
T
E
S
[Witty saying needed…]
SE-2811
Dr.Yoder
36
 
TODO: Get all the noisy-analog-channel
data-rates
SE-2811
Dr Yoder
37
S
I
 
m
u
l
t
i
p
l
i
e
r
s
P   = 1,000,0000,000,000,000
T   = 1,000,000,000,000
G   = 1,000,000,000
M  = 1,000,000
K   =  1,000
()   =  1
m = 1/1,000
us = 1/1,000,000
ns = 1/1,000,000,000  (us = 
μ
s)
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
38
B
i
n
a
r
y
 
m
u
l
t
i
p
l
i
e
r
s
Pi   = 1024
5
Ti   = 1024
4
Gi   = 1024
3
Mi  = 1024
2
Ki   =  1,024
()   =  1
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
39
E
x
How many SI Kb is 4 Gibibytes (GiB)?
N
o
t
e
:
 
T
h
a
t
s
 
S
I
 
k
i
l
o
b
i
t
s
,
 
n
o
t
 
k
i
l
o
b
y
t
e
s
!
SE-2811
Dr.Yoder
40
E
x
:
Suppose you are designing a real-time
system, and the “remote display” design team
says they can handle a data rate of 100MB/s
according to their current design.
What should you ask?
SE-2811
Dr. Yoder
41
Q
u
i
z
 
p
r
a
c
t
i
c
e
:
A
n
a
l
o
g
 
t
o
 
d
i
g
i
t
a
l
 
b
a
n
d
w
i
d
t
h
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
42
S
a
m
p
l
i
n
g
 
R
a
t
e
Suppose an audio signal has a maximum
frequency of 60 KHz (SI).
What is the minimum sampling rate needed to
reconstruct this signal completely?
What bit-rate is needed if each sample has
65,536 possible values? (Use a binary multiplier)
SE-2811
Dr.Yoder
43
B
u
f
f
e
r
i
n
g
With 1 KB buffer, there will be ____ samples
per buffer.
With a 40KHz sampling rate, the buffer must
be filled every ____ milliseconds (audio
deadline)
With 40KHz sampling, the maximum
frequency sine-wave that can be encoded
is…
[HINT: To compute:   buffer size / sample size
= samples per buffer
Similarly, samples per buffer / sample rate =
time to empty buffer]
SE-2811
Dr.Yoder
44
E
x
TODO: Various unit analyses (e.g. audio
rates, video rates, Nyquist theorem)
SE-2811
Dr.Yoder
45
S
C
H
E
D
U
L
I
N
G
When will I ever get all this done?
SE-2811
Dr.Yoder
46
R
a
t
e
-
M
o
n
o
t
o
n
i
c
 
E
x
a
m
p
l
e
 
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
47
O
t
h
e
r
 
R
M
A
 
a
n
d
 
S
c
h
e
d
u
l
i
n
g
q
u
e
s
t
i
o
n
s
Does this meet the theoretical 69% bound?
Is it guaranteed to succeed?
Is it guaranteed to fail?
What simplifying assumptions do we make in
RMA scheduling?
Round-robin vs. Cyclic Code Scheduling
SE-2811
Dr Yoder
48
M
U
L
T
I
T
H
R
E
A
D
I
N
G
Two hands, twice the productivity…
SE-2811
Dr.Yoder
49
I
 
w
a
s
 
a
s
k
e
d
 
t
h
i
s
 
q
u
e
s
t
i
o
n
 
i
n
 
a
n
i
n
t
e
r
v
i
e
w
 
t
o
d
a
y
.
 
(
c
o
n
t
i
n
u
e
d
)
"
W
h
e
n
 
w
e
 
c
r
e
a
t
e
 
a
 
t
h
r
e
a
d
w
i
t
h
 
p
t
h
r
e
a
d
_
c
r
e
a
t
e
(
)
 
(
P
O
S
I
X
 
T
h
r
e
a
d
s
)
,
 
t
h
e
t
h
r
e
a
d
 
s
t
a
r
t
s
 
o
n
 
i
t
s
 
o
w
n
.
 
W
h
y
 
d
o
 
w
e
 
n
e
e
d
 
t
o
e
x
p
l
i
c
i
t
l
y
 
c
a
l
l
 
s
t
a
r
t
(
)
 
i
n
 
J
a
v
a
.
 
W
h
a
t
 
i
s
 
t
h
e
r
e
a
s
o
n
 
t
h
a
t
 
J
a
v
a
 
d
o
e
s
n
t
 
s
t
a
r
t
 
t
h
e
 
t
h
r
e
a
d
 
w
h
e
n
w
e
 
c
r
e
a
t
e
 
a
n
 
i
n
s
t
a
n
c
e
 
o
f
 
i
t
.
"
I was blank and interviewer was short of time
and eventually he couldnt explain the reason to
me.
http://stackoverflow.com/questions/5269535/jav
a-threads-vs-pthreads
SE-3910  - Dr. Josiah Yoder
Slide style: Dr. Hornick
Much Material: Dr. Schilling
50
E
x
:
 
E
d
i
t
 
t
o
 
i
n
c
l
u
d
e
 
n
o
t
i
f
y
/
w
a
i
t
t
o
 
i
n
t
e
r
l
e
a
v
e
 
t
h
e
s
e
 
t
h
r
e
a
d
s
.
Consider this code-
snippet
Queue q = …
synchronized(q) {
   while(true) {
     img = getImage();
     q.offer(img);
   }
}
// on another thread
synchronized(q) {
   while(true) {
      img = q.poll();
      showImage();
   }
}
SE-2811
Dr.Yoder
51
E
x
:
 
E
d
i
t
 
t
o
 
i
n
c
l
u
d
e
 
n
o
t
i
f
y
/
w
a
i
t
t
o
 
i
n
t
e
r
l
e
a
v
e
 
t
h
e
s
e
 
t
h
r
e
a
d
s
.
Consider this code-
snippet
Queue q = …
synchronized(q) {
 
 
 
i
m
g
 
=
 
g
e
t
I
m
a
g
e
(
)
;
   while(true) {
      q.offer(img);
   }
}
// on another thread
synchronized(q) {
   while(true) {
      img = q.poll();
   }
 
 
 
s
h
o
w
I
m
a
g
e
(
)
;
}
SE-2811
Dr.Yoder
52
C
o
d
i
n
g
 
e
x
a
m
p
l
e
.
E
x
e
r
c
i
s
e
:
Both the Java and Qt solutions will behave
poorly if I start multiple threads.
P
r
e
d
i
c
t
 
h
o
w
 
e
a
c
h
 
s
o
l
u
t
i
o
n
 
w
i
l
l
 
b
e
h
a
v
e
 
i
f
 
I
:
Click start
Click start
// what happens? (For Java? For Qt?)
Click stop
// what happens? (For Java? For Qt?)
SE-2811
Dr.Yoder
53
M
o
r
e
 
o
n
 
s
i
g
n
a
l
s
/
s
o
c
k
e
t
s
 
i
n
 
Q
t
Why is it necessary to include a fifth
argument when connecting the “stop” button
to the “interrupt” socket on the prime worker
thread?
SE-2811
Dr.Yoder
54
S
e
q
u
e
n
t
i
a
l
 
C
o
n
s
i
s
t
e
n
c
y
What are the two major things that a compiler
does that invalidate the sequential
consistency memory model?
Why does it do these things?
SE-2811
Dr Yoder
55
D
e
f
i
n
i
t
i
o
n
s
E
x
p
l
a
i
n
 
w
h
a
t
 
a
 
d
a
t
a
 
r
a
c
e
 
a
s
 
d
e
f
i
n
e
d
 
i
n
 
t
h
e
J
a
v
a
 
L
a
n
g
u
a
g
e
 
S
p
e
c
i
f
i
c
a
t
i
o
n
,
 
i
n
 
y
o
u
r
 
o
w
n
w
o
r
d
s
,
 
b
u
t
 
w
i
t
h
 
e
n
o
u
g
h
 
r
i
g
o
r
 
t
o
 
g
e
t
 
t
h
e
e
s
s
e
n
t
i
a
l
s
E
x
p
l
a
i
n
 
w
h
a
t
 
s
e
q
u
e
n
t
i
a
l
 
c
o
n
s
i
s
t
e
n
c
y
 
i
s
 
i
n
y
o
u
r
 
o
w
n
 
w
o
r
d
s
E
x
p
l
a
i
n
 
w
h
y
 
i
t
 
i
s
 
i
m
p
o
r
t
a
n
t
 
f
o
r
 
s
o
m
e
o
p
e
r
a
t
i
o
n
s
 
t
o
 
b
e
 
a
t
o
m
i
c
.
D
e
f
i
n
e
 
v
o
l
a
t
i
l
e
,
 
a
s
 
u
s
e
d
 
i
n
 
J
a
v
a
,
 
i
n
 
y
o
u
r
 
o
w
n
w
o
r
d
s
.
SE-2811
Dr.Yoder
56
T
h
r
e
a
d
i
n
g
 
a
n
d
 
J
C
F
 
(
J
a
v
a
C
o
l
l
e
c
t
i
o
n
s
 
F
r
a
m
e
w
o
r
k
)
Explain the advantage of the
ConcurrentSkipListMap over a TreeMap that
has been synchronized with
Collections.synchronizedMap(Map<K,V> m)
SE-2811
Dr.Yoder
57
H
a
p
p
e
n
i
n
g
 
B
e
f
o
r
e
 
D
o
e
s
 
N
o
t
I
m
p
l
y
 
H
a
p
p
e
n
s
-
B
e
f
o
r
e
void publishMessage() {
    answer = 42;
    isReady = 1;
}
void consumeMessage() {
    if (isReady)
        
sout
("%d\n", answer);
}
http://preshing.com/2013070
2/the-happens-before-
relation/
Exercise:
How might this code
execute to print 
0
instead of 
42
?
(You may use
reordering and/or
caching in your solution)
SE-2811
Dr.Yoder
58
E
x
.
public void a() {
   System.out.println(“x”);
   System.out.println(“y”);
}
public void b() {
   System.out.println(“x”);
   System.out.println(“y”);
}
SE-2811
Dr.Yoder
59
Prove the following code is(n’t) free of data races:
E
x
.
public void a() {
   x = 5;
   System.out.println(“x”);
}
public void a() {
   x = 5;
  System.out.println(“x”);
}
SE-2811
Dr.Yoder
60
Prove the following code is(n’t) free of data races:
E
x
.
public void a() {
  synchronized {
    x = 5;
    System.out.println(“x”);
  }
}
 
SE-2811
Dr.Yoder
61
Prove the following code is(n’t) free of data races:
E
x
.
if(theLogger==null){
 
  synchronized (EventLogger.class){
    if(theLogger == null){
       theLogger = new EventLogger(path);
    }
  }
}
SE-2811
Dr.Yoder
62
W
r
i
t
e
 
w
h
e
t
h
e
r
 
t
h
i
s
 
c
o
d
e
 
c
o
n
t
a
i
n
s
 
a
n
y
 
d
a
t
a
 
r
a
c
e
s
.
E
x
p
l
a
i
n
 
y
o
u
r
 
a
n
s
w
e
r
.
 
A
s
s
u
m
e
 
l
o
g
g
e
r
s
 
i
s
 
n
o
t
v
o
l
a
t
i
l
e
.
E
x
.
if(theLogger==null){
 
  synchronized (EventLogger.class){
    if(theLogger == null){
       theLogger = new EventLogger(path);
    }
  }
}
SE-2811
Dr.Yoder
63
W
r
i
t
e
 
w
h
e
t
h
e
r
 
t
h
i
s
 
c
o
d
e
 
c
o
n
t
a
i
n
s
 
a
n
y
 
d
a
t
a
 
r
a
c
e
s
.
E
x
p
l
a
i
n
 
y
o
u
r
 
a
n
s
w
e
r
.
 
A
s
s
u
m
e
 
l
o
g
g
e
r
s
 
i
s
 
v
o
l
a
t
i
l
e
.
E
x
e
r
c
i
s
e
Loggers is a map.
I
f
 
t
h
i
s
 
m
a
p
 
i
s
 
n
o
t
d
e
s
i
g
n
e
d
 
t
o
 
b
e
 
u
s
e
d
f
r
o
m
 
m
u
l
t
i
p
l
e
 
t
h
r
e
a
d
s
,
a
n
d
 
w
e
 
r
u
n
 
t
h
i
s
p
r
o
g
r
a
m
,
 
i
t
 
i
s
n
t
 
s
a
f
e
.
E
x
p
l
a
i
n
 
w
h
a
t
 
m
i
g
h
t
 
g
o
w
r
o
n
g
.
 
(
o
n
l
y
 
t
e
x
t
 
o
n
s
l
i
d
e
 
n
e
e
d
e
d
)
if(loggers.get(path)==null){
 
  synchronized (loggers){
    if(loggers.get(path) == null){
      EventLogger n = new EventLogger(path);
    }
  }
}
SE-2811
Dr.Yoder
64
E
x
.
if(loggers.get(path)==null){
 
  synchronized (loggers){
    if(loggers.get(path) == null){
       Logger logger = new EventLogger(path);
       loggers.put(path, logger);
    }
  }
}
SE-2811
Dr.Yoder
65
W
r
i
t
e
 
w
h
e
t
h
e
r
 
t
h
i
s
 
c
o
d
e
 
c
o
n
t
a
i
n
s
 
a
n
y
 
d
a
t
a
 
r
a
c
e
s
.
E
x
p
l
a
i
n
 
y
o
u
r
 
a
n
s
w
e
r
.
 
A
s
s
u
m
e
 
l
o
g
g
e
r
s
 
i
s
 
n
o
t
t
h
r
e
a
d
 
s
a
f
e
.
E
x
.
if(loggers.get(path)==null){
 
  synchronized (loggers){
    if(loggers.get(path) == null){
       Logger logger = new EventLogger(path);
       loggers.put(path, logger);
    }
  }
}
SE-2811
Dr.Yoder
66
W
r
i
t
e
 
w
h
e
t
h
e
r
 
t
h
i
s
 
c
o
d
e
 
c
o
n
t
a
i
n
s
 
a
n
y
 
d
a
t
a
 
r
a
c
e
s
.
E
x
p
l
a
i
n
 
y
o
u
r
 
a
n
s
w
e
r
.
 
A
s
s
u
m
e
 
l
o
g
g
e
r
s
 
i
s
 
t
h
r
e
a
d
s
a
f
e
.
C
o
n
s
i
d
e
r
 
t
h
i
s
 
c
o
d
e
:
H
o
w
 
t
o
 
m
a
k
e
 
d
i
s
p
l
a
y
 
o
n
l
y
 
r
u
n
o
n
c
e
 
g
e
t
I
m
a
g
e
 
c
o
m
p
l
e
t
e
s
?
synchronized(this) {
    im = getImage();
    q.put(im);
}
synchronized(this) {
    im = q.get(im);
    display(im);
}
SE-2811
Dr.Yoder
67
E
T
H
I
C
S
But that’s not all, there’s more!
SE-2811
Dr.Yoder
68
C
a
s
e
 
S
t
u
d
i
e
s
What do you do if you are on a project that
puts human lives at risk and things are going
poorly?
What can we learn from Appollo 1, 11, and
Toyota?
SE-2811
Dr Yoder
69
Slide Note

Full agenda:

Return Exam

Questions about lab due tomorrow in class?

Threads: Locking on null object

Threads: invokeLater

Threads: The squares example

Decorator Class Diagram

More on Java IO

Class diagrams

Design Principles

in the patterns we’ve seen so far

Compare with alternatives

Decorator vs. array approach suggested in class

Non-decorator array – decorator can be added on without modifying the original hierarchy

Decorator has “before-after” and possibly other combinatorial control that would be hard-coded in array

[Show “screenshot” of discussion from class? Or just re-type?]

Strategy vs. Decorator class diagrams side-by-side

Structural difference (inheritance optional in Strategy pattern?)

Decorator vs. “Strategy” array

Perhaps next:

Coding Starbuzz coffee (?)

Add real patterns

ArrayList – null-checking

Java I/O: Students do coding examples

http://stackoverflow.com/questions/9358821/should-i-extend-arraylist-to-add-attributes-that-isnt-null

SE3910

Dr. Josiah Yoder

Embed
Share

Explore SE3910 embedded systems course content including quizzes and exams, slide designs, real-time systems, embedded systems, circuits, and exercises. Learn about the key topics such as low-level I/O, meeting deadlines, predicting latency, and more.

  • Embedded Systems
  • Real-Time Systems
  • Course Overview
  • Exams
  • Quizzes

Uploaded on Feb 26, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. SE3910 Week 10, Class 3 Today Class Climate Surveys All quizzes & exams from this quarter: https://faculty-web.msoe.edu/yoder/se3910/quizzes/ SE-2811 1 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder

  2. Review Overview of course Muddiest Point of the quarter Practice Exercises from quarter TBA?: Graphical Overview of course TBA?: Review material for multithreading based on my review of your final projects SE-2811 Dr.Yoder 2

  3. What is/was SE3910 about? Embedded Systems Terminology Electronics and Interfacing Low-level I/O (simple digital input and output) Real-Time Systems Terminology Meeting deadlines Predicting and measuring latency Predicting bandwidth, both analog and digital Scheduling, especially RMA Multithreading SE-2811 Dr.Yoder 3

  4. Its got to be fast or does it? REAL-TIME SYSTEMS SE-2811 Dr.Yoder 4

  5. Exercise Select all that are real-time systems Video Game Aircraft Autopilot Refinery Process Control Cash Register Smartphone a. b. c. d. e. SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 5

  6. Exercise Select all that are embedded systems Video Game Aircraft Autopilot Refinery Process Control Cash Register Smartphone a. b. c. d. e. SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 6

  7. What fun to wire and smoke CIRCUITS SE-2811 Dr.Yoder 7

  8. Ex: What is the resistance of this resistor? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 8

  9. Ex: What is the resistance of this resistor? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 9

  10. Ex: What is the resistance of this resistor? 10

  11. Ex: What is the resistance of this resistor? 11

  12. Ex: What is the resistance of this resistor? 12

  13. Ex: What is the resistance of this resistor? 13 ORANGE ORANGE VIOLET GOLD

  14. Ex: GPIO safety Considering any one of the resistors on the previous slides, is it large enough to not damage a GPIO pin configured as output, if the resistor ties the output to ground? Sourcing limit: 4mA Sinking limit: 8mA Voltage: 3.3 V SE-2811 Dr.Yoder 14

  15. Ex: GPIO safety Considering any one of the resistors on the previous slides, is it large enough to not damage a GPIO pin configured as output, if the resistor ties the output to 3.3V? Sourcing limit: 4mA Sinking limit: 8mA Voltage: 3.3 V SE-2811 Dr.Yoder 15

  16. Ex: What is the voltage across R2? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 16

  17. Ex: Compute voltage across C1 If S1 is closed, and S2 is opened, what is the voltage across C1? If S2 is closed, and S1 is opened? If both are opened? If both are closed? SE-2811 Dr.Yoder 17

  18. Ex: Compute voltage into GPIO If S1 is open and S2 is closed, compute the voltage from GPIO 12 to ground. (Assume GPIO 12 is not connected to anything) SE-2811 Dr. Yoder 18

  19. Ex: Whats wrong with this simple circuit s input? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 19

  20. Ex: Whats wrong with this circuit? (The worst thing) SE-3910 Dr.Yoder 20

  21. Exercise: Find all of: Voltage from GPIO to ground if S1 is closed S2 is closed Both are open Current from source if both are closed SE-2811 Dr.Yoder 21

  22. Selecting an LED resistance value Suppose L1 is a diode with Vd = 1.8 V Ex: Write a formula relating the current through L1 to R1. Ex: Solve for R1 if we want the (max) current to be 10 mA. SE-2811 Dr.Yoder 22

  23. Its like Java, only with pointers C LANGUAGE SE-2811 Dr Yoder 23

  24. (Extra Exercise) Why does this 6 unsigned short *pt; 7 pt = myArray[0]; Produce this? myLib.c:7: error: data definition has no type or storage class myLib.c:7: error: type defaults to 'int' in declaration of 'pt' myLib.c:7: error: conflicting types for 'pt' myLib.c:6: note: previous declaration of 'pt' was here myLib.c:7: error: initialization makes integer from pointer without a cast How should it be written? Are these compile or link errors? SE-2811 Dr Yoder 24

  25. Exercise: Which of the following is correct? void foo(struct bar2* b); struct bar b; And then . foo((struct bar2*) b*) foo((bar2*) *b) foo((bar2*) b&) foo((struct bar2*) &b) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 25

  26. Exercise How do you get a reference (pointer) to the first element in an array? int x[5] = {1,2,3,4,5} boolean foo(int *ip); a) foo(&x); b) foo(&x[0]); c) foo(x); d) foo(x[0]); SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 26

  27. Exercise How do you get a reference (pointer) to the second element in an array? int x[5] = {1,2,3,4,5} boolean foo(int *ip); a) foo(&x+1); b) foo(&x[0]); c) foo(x+1); d) foo(x[0]); e) foo(&(x+1)); Slide style: Dr. Hornick Much Material: Dr. Schilling SE-3910 - Dr. Josiah Yoder 27

  28. Ex: C/C++ (Review) Why do we have both .h and .cpp file extensions for C++? Why not just have .cpp (like .java for Java classes)? Answer these questions: 1. What should you put into a class s .h file? 2. What should you put into a class s .cpp file? [Note: On next lab, use .hpp and .cpp instead of .h and .cpp] SE-2811 Dr.Yoder 28

  29. Ex: C/C++ Circle the link-time errors. Box the compile- time cannot find -lasound [NEW!!! (As of Quiz 5)] syntax error warning: implicit declaration of function `...' point.m:40: error: mypoint undeclared (first use in this function) parse error before `... collect2: ld returned 1 exit status undefined reference to `filterText' /usr/lib/crt1.o(.text+0x18): undefined reference to SE-2811 Dr.Yoder 29

  30. Quiz Practice: C/C++ Circle the link-time errors. Box the compile- time syntax error point.m:40: error: mypoint undeclared (first use in this function) collect2: ld returned 1 exit status /usr/lib/crt1.o(.text+0x18): undefined reference to `main ' parse error before `... undefined reference to `filterText' warning: implicit declaration of function `...' SE-2811 Dr.Yoder 30

  31. Other Quiz Subjects Creating a signal from sine waves Frequency content of a signal Analog bandwidth Stroboscopic effect Why some cables can carry more data than others Even more outcomes on outcomes page, if desired SE-2811 Dr.Yoder 31

  32. Wiggly and squiggly SIGNALS SE-2811 Dr.Yoder 32

  33. Exercise: What is the time delay between the two falling edges? SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 33

  34. Exercise: What is the time delay between the two falling edges? 5 ms / Div SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 34

  35. Exercise: What is the rise-time of this signal? 1 Volt/div 1 ms/div 0 SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 35

  36. [Witty saying needed] DATA-RATES SE-2811 Dr.Yoder 36

  37. TODO: Get all the noisy-analog-channel data-rates SE-2811 Dr Yoder 37

  38. SI multipliers P = 1,000,0000,000,000,000 T = 1,000,000,000,000 G = 1,000,000,000 M = 1,000,000 K = 1,000 () = 1 m = 1/1,000 us = 1/1,000,000 ns = 1/1,000,000,000 (us = s) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 38

  39. Binary multipliers Pi = 10245 Ti = 10244 Gi = 10243 Mi = 10242 Ki = 1,024 () = 1 SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 39

  40. Ex How many SI Kb is 4 Gibibytes (GiB)? Note: That s SI kilobits, not kilobytes! SE-2811 Dr.Yoder 40

  41. Ex: Suppose you are designing a real-time system, and the remote display design team says they can handle a data rate of 100MB/s according to their current design. What should you ask? SE-2811 Dr. Yoder 41

  42. Quiz practice: Analog to digital bandwidth ????2 (1 +? ?) Suppose you would like to send video in a (relatively) low-frequency with a narrow bandwidth of 1 Mhz The connection is fairly noisy and you can only get 20dB SNR What bit-rate can you achieve? (use closest binary multiplier) 42 SE-3910 - Dr. Josiah Yoder

  43. Sampling Rate Suppose an audio signal has a maximum frequency of 60 KHz (SI). What is the minimum sampling rate needed to reconstruct this signal completely? What bit-rate is needed if each sample has 65,536 possible values? (Use a binary multiplier) SE-2811 Dr.Yoder 43

  44. Buffering With 1 KB buffer, there will be ____ samples per buffer. With a 40KHz sampling rate, the buffer must be filled every ____ milliseconds (audio deadline) With 40KHz sampling, the maximum frequency sine-wave that can be encoded is SE-2811 Dr.Yoder 44

  45. Ex TODO: Various unit analyses (e.g. audio rates, video rates, Nyquist theorem) SE-2811 Dr.Yoder 45

  46. When will I ever get all this done? SCHEDULING SE-2811 Dr.Yoder 46

  47. Rate-Monotonic Example SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 47

  48. Other RMA and Scheduling questions Does this meet the theoretical 69% bound? Is it guaranteed to succeed? Is it guaranteed to fail? What simplifying assumptions do we make in RMA scheduling? Round-robin vs. Cyclic Code Scheduling SE-2811 Dr Yoder 48

  49. Two hands, twice the productivity MULTITHREADING SE-2811 Dr.Yoder 49

  50. I was asked this question in an interview today . (continued) "When we create a thread with pthread_create() (POSIX Threads), the thread starts on its own. Why do we need to explicitly call start() in Java. What is the reason that Java doesnt start the thread when we create an instance of it." I was blank and interviewer was short of time and eventually he couldnt explain the reason to me. http://stackoverflow.com/questions/5269535/jav a-threads-vs-pthreads SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 50

Related


More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#