author | Christian Urban <urbanc@in.tum.de> |
Tue, 20 Nov 2018 08:00:16 +0000 | |
changeset 606 | a50feaa0c4b3 |
parent 538 | 17acdd516ccd |
child 609 | e33545bb2eba |
permissions | -rw-r--r-- |
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
\documentclass[dvipsnames,14pt,t]{beamer} |
309
640e4a05cd9b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
2 |
\usepackage{../slides} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
207
diff
changeset
|
3 |
\usepackage{../langs} |
309
640e4a05cd9b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
4 |
\usepackage{../graphics} |
379
fa2589ec0fae
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
312
diff
changeset
|
5 |
\usepackage{../grammar} |
310
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
6 |
\usepackage{soul} |
538 | 7 |
\usepackage{mathpartir} |
310
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
8 |
|
538 | 9 |
% beamer stuff |
459 | 10 |
\renewcommand{\slidecaption}{CFL 09, King's College London} |
538 | 11 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
310
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
12 |
|
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
\begin{document} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
309
640e4a05cd9b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
15 |
\begin{frame}[t] |
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
\frametitle{% |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
\begin{tabular}{@ {}c@ {}} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
\\[-3mm] |
459 | 19 |
\LARGE Compilers and \\[-2mm] |
538 | 20 |
\LARGE Formal Languages (9)\\[3mm] |
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
\end{tabular}} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
|
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
\normalsize |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
\begin{center} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
\begin{tabular}{ll} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
Email: & christian.urban at kcl.ac.uk\\ |
500 | 27 |
Office: & N7.07 (North Wing, Bush House)\\ |
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
Slides: & KEATS (also home work is there)\\ |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
\end{tabular} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
\end{center} |
309
640e4a05cd9b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
31 |
\end{frame} |
77
49c0beef79a1
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
76
diff
changeset
|
32 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
34 |
|
538 | 35 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
36 |
\begin{frame}[c] |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
37 |
|
538 | 38 |
\begin{center} |
39 |
\includegraphics[scale=0.6]{../pics/bridge-limits.png} |
|
40 |
\end{center} |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
41 |
|
538 | 42 |
\end{frame} |
43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
44 |
|
538 | 45 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
46 |
\begin{frame}[c] |
|
47 |
\frametitle{Old-Fashioned Eng.~vs.~CS} |
|
48 |
||
49 |
\begin{center} |
|
50 |
\begin{tabular}{@{}cc@{}} |
|
51 |
\begin{tabular}{@{}p{5.2cm}} |
|
52 |
\includegraphics[scale=0.058]{../pics/towerbridge.jpg}\\ |
|
53 |
{\bf bridges}: \\ |
|
54 |
\raggedright\small |
|
55 |
engineers can ``look'' at a bridge and have a pretty good |
|
56 |
intuition about whether it will hold up or not\\ |
|
57 |
(redundancy; predictive theory) |
|
58 |
\end{tabular} & |
|
59 |
\begin{tabular}{p{5cm}} |
|
60 |
\includegraphics[scale=0.265]{../pics/code.jpg}\\ |
|
61 |
\raggedright |
|
62 |
{\bf code}: \\ |
|
63 |
\raggedright\small |
|
64 |
programmers have very little intuition about their code; |
|
65 |
often it is too expensive to have redundancy; |
|
66 |
not ``continuous'' |
|
67 |
\end{tabular} |
|
68 |
\end{tabular} |
|
69 |
\end{center} |
|
310
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
70 |
|
538 | 71 |
\end{frame} |
72 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
310
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
73 |
|
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
74 |
|
d384fe01d0e8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
309
diff
changeset
|
75 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
76 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
77 |
\begin{frame}[c] |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
78 |
\frametitle{Dijkstra on Testing} |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
79 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
80 |
\begin{bubble}[10cm] |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
81 |
``Program testing can be a very effective way to show the |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
82 |
presence of bugs, but it is hopelessly inadequate for showing |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
83 |
their absence.'' |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
84 |
\end{bubble}\bigskip |
538 | 85 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
86 |
\end{frame} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
87 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
88 |
|
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
89 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
90 |
\begin{frame}[c] |
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
91 |
\frametitle{\Large Proving Programs to be Correct} |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
92 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
93 |
\begin{bubble}[10cm] |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
94 |
\small |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
95 |
{\bf Theorem:} There are infinitely many prime |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
96 |
numbers.\medskip\\ |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
97 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
98 |
{\bf Proof} \ldots\\ |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
99 |
\end{bubble}\bigskip |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
100 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
101 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
102 |
similarly\bigskip |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
103 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
104 |
\begin{bubble}[10cm] |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
105 |
\small |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
106 |
{\bf Theorem:} The program is doing what |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
107 |
it is supposed to be doing.\medskip |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
108 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
109 |
{\bf Long, long proof} \ldots\\ |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
110 |
\end{bubble}\bigskip\medskip |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
111 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
112 |
\small This can be a gigantic proof. The only hope is to have |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
113 |
help from the computer. `Program' is here to be understood to be |
538 | 114 |
quite general (protocols, OS, \ldots). |
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
115 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
116 |
\end{frame} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
117 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
118 |
|
538 | 119 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
120 |
\begin{frame}[c] |
|
121 |
\frametitle{\Large{}Mars Pathfinder Mission 1997} |
|
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
122 |
|
538 | 123 |
\begin{center} |
124 |
\includegraphics[scale=0.15]{../pics/marspath1.png} |
|
125 |
\includegraphics[scale=0.16]{../pics/marspath3.png} |
|
126 |
\includegraphics[scale=0.3]{../pics/marsrover.png} |
|
127 |
\end{center} |
|
128 |
||
129 |
\begin{itemize} |
|
130 |
\item despite NASA's famous testing procedures, the lander crashed frequently on Mars |
|
131 |
\item a scheduling algorithm was not used in the OS |
|
132 |
\end{itemize} |
|
133 |
||
134 |
\end{frame} |
|
135 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
136 |
||
137 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
138 |
\begin{frame}[c] |
|
139 |
||
140 |
||
141 |
\begin{textblock}{11}(1,3) |
|
142 |
\begin{tabular}{@{\hspace{-10mm}}l} |
|
143 |
\begin{tikzpicture}[scale=1.1] |
|
144 |
\node at (-2.5,-1.5) {\textcolor{white}{a}}; |
|
145 |
\node at (8,4) {\textcolor{white}{a}}; |
|
146 |
||
147 |
||
148 |
||
149 |
\only<1>{ |
|
150 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
151 |
} |
|
152 |
\only<2>{ |
|
153 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
154 |
\draw[fill, blue!50] (3,0) rectangle (5,0.6); |
|
155 |
\draw[fill, blue!100] (2,3) rectangle (3,3.6); |
|
156 |
} |
|
157 |
\only<3>{ |
|
158 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
159 |
\draw[fill, blue!50] (3,0) rectangle (4.5,0.6); |
|
160 |
\draw[fill, blue!50] (5.5,0) rectangle (6,0.6); |
|
161 |
\draw[fill, blue!100] (2,3) rectangle (3,3.6); |
|
162 |
\draw[fill, blue!100] (4.5,3) rectangle (5.5,3.6); |
|
163 |
} |
|
164 |
\only<4>{ |
|
165 |
\node at (2.5,0.9) {\small locked a resource}; |
|
166 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
167 |
\draw[blue!50, very thick] (2,0) rectangle (4,0.6); |
|
168 |
\draw[blue!100, very thick] (2,3) rectangle (3, 3.6); |
|
169 |
\draw[red, <-, line width = 2mm] (2,-0.1) -- (2, -1); |
|
170 |
} |
|
171 |
\only<5>{ |
|
172 |
\node at (2.5,0.9) {\small locked a resource}; |
|
173 |
\draw[fill, blue!50] (1,0) rectangle (4,0.6); |
|
174 |
\draw[blue!100, fill] (4,3) rectangle (5, 3.6); |
|
175 |
} |
|
176 |
\only<6>{ |
|
177 |
\node at (2.5,0.9) {\small locked a resource}; |
|
178 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
179 |
\draw[blue!50, very thick] (2,0) rectangle (4,0.6); |
|
180 |
\draw[blue!100, very thick] (2,3) rectangle (3, 3.6); |
|
181 |
\draw[red, <-, line width = 2mm] (2,-0.1) -- (2, -1); |
|
182 |
} |
|
183 |
\only<7>{ |
|
184 |
\node at (2.5,0.9) {\small locked a resource}; |
|
185 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
186 |
\draw[blue!50, very thick] (2.5,0) rectangle (4,0.6); |
|
187 |
\draw[blue!100, very thick] (2.5,3) rectangle (3.5, 3.6); |
|
188 |
\draw[red, <-, line width = 2mm] (2.5,-0.1) -- (2.5, -1); |
|
189 |
} |
|
190 |
\only<8>{ |
|
191 |
\node at (2.5,0.9) {\small locked a resource}; |
|
192 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
193 |
\draw[blue!50, very thick] (2.5,0) rectangle (4,0.6); |
|
194 |
\draw[blue!100, very thick] (2.5,3) rectangle (3.5, 3.6); |
|
195 |
\draw[blue!100, very thick] (2.5,3) rectangle (3.5, 3.6); |
|
196 |
\draw[red, fill] (2.5,1.5) rectangle (3.5,2.1); |
|
197 |
\draw[red, <-, line width = 2mm] (2.5,-0.1) -- (2.5, -1); |
|
198 |
} |
|
199 |
\only<9>{ |
|
200 |
\node at (2.5,0.9) {\small locked a resource}; |
|
201 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
202 |
\draw[blue!50, very thick] (3.5,0) rectangle (5,0.6); |
|
203 |
\draw[blue!100, very thick] (3.5,3) rectangle (4.5, 3.6); |
|
204 |
\draw[red, fill] (2.5,1.5) rectangle (3.5,2.1); |
|
205 |
\draw[red, <-, line width = 2mm] (3.5,-0.1) -- (3.5, -1); |
|
206 |
} |
|
207 |
\only<10>{ |
|
208 |
\node at (2.5,0.9) {\small locked a resource}; |
|
209 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
210 |
\draw[blue!50, very thick] (3.5,0) rectangle (5,0.6); |
|
211 |
\draw[blue!100, very thick] (3.5,3) rectangle (4.5, 3.6); |
|
212 |
\draw[red, fill] (2.5,1.5) rectangle (3.5,2.1); |
|
213 |
\draw[red, fill] (3.55,1.5) rectangle (4.5,2.1); |
|
214 |
\draw[red, <-, line width = 2mm] (3.5,-0.1) -- (3.5, -1); |
|
215 |
} |
|
216 |
\only<11>{ |
|
217 |
\node at (2.5,0.9) {\small locked a resource}; |
|
218 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
219 |
\draw[blue!50, very thick] (4.5,0) rectangle (6,0.6); |
|
220 |
\draw[blue!100, very thick] (4.5,3) rectangle (5.5, 3.6); |
|
221 |
\draw[red, fill] (2.5,1.5) rectangle (3.5,2.1); |
|
222 |
\draw[red, fill] (3.55,1.5) rectangle (4.5,2.1); |
|
223 |
\draw[red, <-, line width = 2mm] (4.5,-0.1) -- (4.5, -1); |
|
224 |
} |
|
225 |
\only<12>{ |
|
226 |
\node at (2.5,0.9) {\small locked a resource}; |
|
227 |
\draw[fill, blue!50] (1,0) rectangle (2.5,0.6); |
|
228 |
\draw[blue!50, very thick] (5.5,0) rectangle (7,0.6); |
|
229 |
\draw[blue!100, very thick] (5.5,3) rectangle (6.5, 3.6); |
|
230 |
\draw[red, fill] (2.5,1.5) rectangle (3.5,2.1); |
|
231 |
\draw[red, fill] (3.55,1.5) rectangle (4.5,2.1); |
|
232 |
\draw[red, fill] (4.55,1.5) rectangle (5.5,2.1); |
|
233 |
\draw[red, <-, line width = 2mm] (5.5,-0.1) -- (5.5, -1); |
|
234 |
\node [anchor=base] at (6.3, 1.8) {\Large\ldots}; |
|
235 |
} |
|
236 |
\only<13>{ |
|
237 |
\node at (2.5,0.9) {\small locked a resource}; |
|
238 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
239 |
\draw[blue!50, very thick] (2,0) rectangle (4,0.6); |
|
240 |
\draw[blue!100, very thick] (2,3) rectangle (3, 3.6); |
|
241 |
\draw[red, <-, line width = 2mm] (2,-0.1) -- (2, -1); |
|
242 |
} |
|
243 |
\only<14>{ |
|
244 |
\node at (2.5,3.9) {\small locked a resource}; |
|
245 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
246 |
\draw[blue!50, fill] (2,3) rectangle (4,3.6); |
|
247 |
\draw[blue!100, very thick] (4,3) rectangle (5, 3.6); |
|
248 |
\draw[blue!50, ->, line width = 2mm] (2,1) -- (2, 2.5); |
|
249 |
\draw[red, <-, line width = 2mm] (2,-0.1) -- (2, -1); |
|
250 |
} |
|
251 |
\only<15>{ |
|
252 |
\node at (2.5,3.9) {\small locked a resource}; |
|
253 |
\draw[fill, blue!50] (1,0) rectangle (2,0.6); |
|
254 |
\draw[blue!50, fill] (2,3) rectangle (4,3.6); |
|
255 |
\draw[blue!100, very thick] (4,3) rectangle (5, 3.6); |
|
256 |
\draw[red, <-, line width = 2mm] (2.5,-0.1) -- (2.5, -1); |
|
257 |
\draw[red, very thick] (2.5,1.5) rectangle (3.5,2.1); |
|
258 |
} |
|
259 |
||
260 |
||
261 |
\draw[very thick,->](0,0) -- (8,0); |
|
262 |
\node [anchor=base] at (8, -0.3) {\scriptsize time}; |
|
263 |
\node [anchor=base] at (0, -0.3) {\scriptsize 0}; |
|
264 |
\node [anchor=base] at (-1.2, 0.2) {\small low priority}; |
|
265 |
\only<2->{\node [anchor=base] at (-1.2, 3.2) {\small high priority};} |
|
266 |
\only<8->{\node [anchor=base] at (-1.5, 1.7) {\small medium pr.};} |
|
267 |
||
268 |
\end{tikzpicture} |
|
269 |
\end{tabular} |
|
270 |
\end{textblock} |
|
271 |
||
272 |
\begin{textblock}{0}(2.5,13)% |
|
273 |
\small |
|
274 |
\onslide<3->{ |
|
275 |
\begin{bubble}[8cm]% |
|
276 |
Scheduling: You want to avoid that a high |
|
277 |
priority process is starved indefinitely. |
|
278 |
\end{bubble}} |
|
279 |
\end{textblock} |
|
280 |
||
281 |
\end{frame} |
|
282 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
283 |
||
284 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
285 |
\begin{frame}[c] |
|
286 |
\frametitle{\Large Priority Inheritance Scheduling} |
|
287 |
||
288 |
\begin{itemize} |
|
289 |
\item Let a low priority process $L$ temporarily inherit |
|
290 |
the high priority of $H$ until $L$ leaves the critical |
|
291 |
section unlocking the resource.\bigskip |
|
292 |
\item Once the resource is unlocked $L$ returns to its original |
|
293 |
priority level. |
|
294 |
\end{itemize} |
|
295 |
||
296 |
\end{frame} |
|
297 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
298 |
||
299 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
300 |
\begin{frame}[c] |
|
301 |
||
302 |
\begin{textblock}{11}(1,3) |
|
303 |
\begin{tabular}{@{\hspace{-10mm}}l} |
|
304 |
\begin{tikzpicture}[scale=1.1] |
|
305 |
\node at (-2.5,-1.5) {\textcolor{white}{a}}; |
|
306 |
\node at (8,4) {\textcolor{white}{a}}; |
|
307 |
||
308 |
\only<1>{ |
|
309 |
\draw[fill, blue!50] (1,0) rectangle (6,0.6); |
|
310 |
\node at (1.5,0.9) {\small $A_L$}; |
|
311 |
\node at (2.0,0.9) {\small $B_L$}; |
|
312 |
\node at (3.5,0.9) {\small $A_R$}; |
|
313 |
\node at (5.7,0.9) {\small $B_R$}; |
|
314 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
315 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
316 |
\draw[very thick,blue!100] (3.5,0) -- (3.5,0.6); |
|
317 |
\draw[very thick,blue!100] (5.7,0) -- (5.7,0.6); |
|
318 |
} |
|
319 |
\only<2>{ |
|
320 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
321 |
\draw[very thick, blue!50] (3,0) rectangle (6,0.6); |
|
322 |
\node at (1.5,0.9) {\small $A_L$}; |
|
323 |
\node at (2.0,0.9) {\small $B_L$}; |
|
324 |
\node at (3.5,0.9) {\small $A_R$}; |
|
325 |
\node at (5.7,0.9) {\small $B_R$}; |
|
326 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
327 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
328 |
\draw[very thick,blue!100] (3.5,0) -- (3.5,0.6); |
|
329 |
\draw[very thick,blue!100] (5.7,0) -- (5.7,0.6); |
|
330 |
} |
|
331 |
\only<3>{ |
|
332 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
333 |
\draw[very thick, blue!50] (3,0) rectangle (6,0.6); |
|
334 |
\node at (1.5,0.9) {\small $A_L$}; |
|
335 |
\node at (2.0,0.9) {\small $B_L$}; |
|
336 |
\node at (3.5,0.9) {\small $A_R$}; |
|
337 |
\node at (5.7,0.9) {\small $B_R$}; |
|
338 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
339 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
340 |
\draw[very thick,blue!100] (3.5,0) -- (3.5,0.6); |
|
341 |
\draw[very thick,blue!100] (5.7,0) -- (5.7,0.6); |
|
342 |
\draw[very thick,blue!100] (3,3) rectangle (4,3.6); |
|
343 |
\node at (3.5,3.3) {\small $A$}; |
|
344 |
} |
|
345 |
\only<4>{ |
|
346 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
347 |
\draw[very thick, blue!50] (3,0) rectangle (6,0.6); |
|
348 |
\node at (1.5,0.9) {\small $A_L$}; |
|
349 |
\node at (2.0,0.9) {\small $B_L$}; |
|
350 |
\node at (3.5,0.9) {\small $A_R$}; |
|
351 |
\node at (5.7,0.9) {\small $B_R$}; |
|
352 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
353 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
354 |
\draw[very thick,blue!100] (3.5,0) -- (3.5,0.6); |
|
355 |
\draw[very thick,blue!100] (5.7,0) -- (5.7,0.6); |
|
356 |
\draw[very thick,blue!100] (3,3) rectangle (4,3.6); |
|
357 |
\node at (3.5,3.3) {\small $A$}; |
|
358 |
\draw[very thick,blue!100] (4,3) rectangle (5,3.6); |
|
359 |
\node at (4.5,3.3) {\small $B$}; |
|
360 |
} |
|
361 |
\only<5>{ |
|
362 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
363 |
\draw[very thick, blue!50] (3,3) rectangle (6,3.6); |
|
364 |
\node at (1.5,0.9) {\small $A_L$}; |
|
365 |
\node at (2.0,0.9) {\small $B_L$}; |
|
366 |
\node at (3.5,3.9) {\small $A_R$}; |
|
367 |
\node at (5.7,3.9) {\small $B_R$}; |
|
368 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
369 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
370 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
371 |
\draw[very thick,blue!100] (5.7,3) -- (5.7,3.6); |
|
372 |
\draw[very thick,blue!100] (6,3) rectangle (7,3.6); |
|
373 |
\node at (6.5,3.3) {\small $A$}; |
|
374 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
375 |
\node at (7.5,3.3) {\small $B$}; |
|
376 |
\draw[blue!50, ->, line width = 2mm] (3,1) -- (3, 2.5); |
|
377 |
} |
|
378 |
\only<6>{ |
|
379 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
380 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
381 |
\draw[very thick, blue!50] (3.5,3) rectangle (6,3.6); |
|
382 |
\node at (1.5,0.9) {\small $A_L$}; |
|
383 |
\node at (2.0,0.9) {\small $B_L$}; |
|
384 |
\node at (3.5,3.9) {\small $A_R$}; |
|
385 |
\node at (5.7,3.9) {\small $B_R$}; |
|
386 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
387 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
388 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
389 |
\draw[very thick,blue!100] (5.7,3) -- (5.7,3.6); |
|
390 |
\draw[very thick,blue!100] (6,3) rectangle (7,3.6); |
|
391 |
\node at (6.5,3.3) {\small $A$}; |
|
392 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
393 |
\node at (7.5,3.3) {\small $B$}; |
|
394 |
} |
|
395 |
\only<7>{ |
|
396 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
397 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
398 |
\draw[very thick, blue!50] (3.5,0) rectangle (6,0.6); |
|
399 |
\node at (1.5,0.9) {\small $A_L$}; |
|
400 |
\node at (2.0,0.9) {\small $B_L$}; |
|
401 |
\node at (3.5,3.9) {\small $A_R$}; |
|
402 |
\node at (5.7,0.9) {\small $B_R$}; |
|
403 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
404 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
405 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
406 |
\draw[very thick,blue!100] (5.7,0) -- (5.7,0.6); |
|
407 |
\draw[very thick,blue!100] (6,3) rectangle (7,3.6); |
|
408 |
\node at (6.5,3.3) {\small $A$}; |
|
409 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
410 |
\node at (7.5,3.3) {\small $B$}; |
|
411 |
\draw[blue!50, <-, line width = 2mm] (3.5,1) -- (3.5, 2.5); |
|
412 |
\draw[blue!50, <-, line width = 2mm] (4,3.3) -- (5.5,3.3); |
|
413 |
} |
|
414 |
\only<8>{ |
|
415 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
416 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
417 |
\draw[very thick, blue!50] (4.5,0) rectangle (7,0.6); |
|
418 |
\node at (1.5,0.9) {\small $A_L$}; |
|
419 |
\node at (2.0,0.9) {\small $B_L$}; |
|
420 |
\node at (3.5,3.9) {\small $A_R$}; |
|
421 |
\node at (6.7,0.9) {\small $B_R$}; |
|
422 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
423 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
424 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
425 |
\draw[very thick,blue!100] (6.7,0) -- (6.7,0.6); |
|
426 |
\draw[fill,blue!100] (3.5,3) rectangle (4.5,3.6); |
|
427 |
\node at (4,3.3) {\small $A$}; |
|
428 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
429 |
\node at (7.5,3.3) {\small $B$}; |
|
430 |
} |
|
431 |
\only<9>{ |
|
432 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
433 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
434 |
\draw[fill, blue!50] (4.5,0) rectangle (5,0.6); |
|
435 |
\draw[very thick, blue!50] (5,0) rectangle (7,0.6); |
|
436 |
\node at (1.5,0.9) {\small $A_L$}; |
|
437 |
\node at (2.0,0.9) {\small $B_L$}; |
|
438 |
\node at (3.5,3.9) {\small $A_R$}; |
|
439 |
\node at (6.7,0.9) {\small $B_R$}; |
|
440 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
441 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
442 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
443 |
\draw[very thick,blue!100] (6.7,0) -- (6.7,0.6); |
|
444 |
\draw[fill,blue!100] (3.5,3) rectangle (4.5,3.6); |
|
445 |
\node at (4,3.3) {\small $A$}; |
|
446 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
447 |
\node at (7.5,3.3) {\small $B$}; |
|
448 |
} |
|
449 |
\only<10>{ |
|
450 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
451 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
452 |
\draw[fill, blue!50] (4.5,0) rectangle (5,0.6); |
|
453 |
\draw[very thick, blue!50] (5,0) rectangle (7,0.6); |
|
454 |
\node at (1.5,0.9) {\small $A_L$}; |
|
455 |
\node at (2.0,0.9) {\small $B_L$}; |
|
456 |
\node at (3.5,3.9) {\small $A_R$}; |
|
457 |
\node at (6.7,0.9) {\small $B_R$}; |
|
458 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
459 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
460 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
461 |
\draw[very thick,blue!100] (6.7,0) -- (6.7,0.6); |
|
462 |
\draw[fill,blue!100] (3.5,3) rectangle (4.5,3.6); |
|
463 |
\node at (4,3.3) {\small $A$}; |
|
464 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
465 |
\node at (7.5,3.3) {\small $B$}; |
|
466 |
\draw[red, fill] (5,1.5) rectangle (6,2.1); |
|
467 |
\draw[red, fill] (6.05,1.5) rectangle (7,2.1); |
|
468 |
} |
|
469 |
\only<11>{ |
|
470 |
\draw[fill, blue!50] (1,0) rectangle (3,0.6); |
|
471 |
\draw[fill, blue!50] (3,3) rectangle (3.5,3.6); |
|
472 |
\draw[fill, blue!50] (4.5,0) rectangle (5,0.6); |
|
473 |
\draw[very thick, blue!50] (5,0) rectangle (7,0.6); |
|
474 |
\node at (1.5,0.9) {\small $A_L$}; |
|
475 |
\node at (2.0,0.9) {\small $B_L$}; |
|
476 |
\node at (3.5,3.9) {\small $A_R$}; |
|
477 |
\node at (6.7,0.9) {\small $B_R$}; |
|
478 |
\draw[very thick,blue!100] (1.5,0) -- (1.5,0.6); |
|
479 |
\draw[very thick,blue!100] (2.0,0) -- (2.0,0.6); |
|
480 |
\draw[very thick,blue!100] (3.5,3) -- (3.5,3.6); |
|
481 |
\draw[very thick,blue!100] (6.7,0) -- (6.7,0.6); |
|
482 |
\draw[fill,blue!100] (3.5,3) rectangle (4.5,3.6); |
|
483 |
\node at (4,3.3) {\small $A$}; |
|
484 |
\draw[very thick,blue!100] (7,3) rectangle (8,3.6); |
|
485 |
\node at (7.5,3.3) {\small $B$}; |
|
486 |
\draw[red, fill] (5,1.5) rectangle (6,2.1); |
|
487 |
\draw[red, fill] (6.05,1.5) rectangle (7,2.1); |
|
488 |
\draw[blue!50, ->, line width = 2mm] (7.1,0.4) -- (8, 0.4); |
|
489 |
\draw[blue!50, ->, line width = 2mm] (7.1,4) -- (8,4); |
|
490 |
} |
|
491 |
||
492 |
\draw[very thick,->](0,0) -- (8,0); |
|
493 |
\node [anchor=base] at (8, -0.3) {\scriptsize time}; |
|
494 |
\node [anchor=base] at (0, -0.3) {\scriptsize 0}; |
|
495 |
\node [anchor=base] at (-1.2, 0.2) {\small low priority}; |
|
496 |
\only<2->{\node [anchor=base] at (-1.2, 3.2) {\small high priority};} |
|
497 |
\only<10->{\node [anchor=base] at (-1.5, 1.7) {\small medium pr.};} |
|
498 |
||
499 |
\end{tikzpicture} |
|
500 |
\end{tabular} |
|
501 |
\end{textblock} |
|
502 |
||
503 |
\begin{textblock}{0}(2.5,13)% |
|
504 |
\small |
|
505 |
\onslide<11>{ |
|
506 |
\begin{bubble}[8cm]% |
|
507 |
Scheduling: You want to avoid that a high |
|
508 |
priority process is staved indefinitely. |
|
509 |
\end{bubble}} |
|
510 |
\end{textblock} |
|
511 |
||
512 |
||
513 |
\end{frame} |
|
514 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
515 |
||
516 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
517 |
\begin{frame}[c] |
|
518 |
\frametitle{\Large Priority Inheritance Scheduling} |
|
519 |
||
520 |
\begin{itemize} |
|
521 |
\item Let a low priority process $L$ temporarily inherit |
|
522 |
the high priority of $H$ until $L$ leaves the critical |
|
523 |
section unlocking the resource.\bigskip |
|
524 |
\item Once the resource is unlocked $L$ returns to its original |
|
525 |
priority level. \alert{\bf BOGUS}\pause\bigskip |
|
526 |
\item \ldots $L$ needs to switch to the highest |
|
527 |
\alert{remaining} priority of the threads that it blocks. |
|
528 |
\end{itemize}\bigskip |
|
529 |
||
530 |
\small this error is already known since around 1999 |
|
531 |
||
532 |
\end{frame} |
|
533 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
534 |
||
535 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
536 |
\begin{frame}[c] |
|
537 |
||
538 |
\begin{center} |
|
539 |
\includegraphics[scale=0.25]{../pics/p3.jpg} |
|
540 |
\end{center} |
|
541 |
||
542 |
\begin{itemize} |
|
543 |
\item by Rajkumar, 1991 |
|
544 |
\item \it ``it resumes the priority it had at the point of entry into the critical |
|
545 |
section'' |
|
546 |
\end{itemize} |
|
547 |
||
548 |
\end{frame} |
|
549 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
550 |
||
551 |
||
552 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
553 |
\begin{frame}[c] |
|
554 |
||
555 |
\begin{center} |
|
556 |
\includegraphics[scale=0.25]{../pics/p2.jpg} |
|
557 |
\end{center} |
|
558 |
||
559 |
\begin{itemize} |
|
560 |
\item by Jane Liu, 2000 |
|
561 |
\item {\it ``The job $J_l$ executes at its inherited |
|
562 |
priority until it releases $R$; at that time, the |
|
563 |
priority of $J_l$ returns to its priority |
|
564 |
at the time when it acquires the resource $R$.''}\medskip |
|
565 |
\item \small gives pseudo code and totally bogus data structures |
|
566 |
\item \small interesting part ``{\it left as an exercise}'' |
|
567 |
\end{itemize} |
|
568 |
||
569 |
\end{frame} |
|
570 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
571 |
||
572 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
573 |
\begin{frame}[c] |
|
574 |
||
575 |
\begin{center} |
|
576 |
\includegraphics[scale=0.15]{../pics/p1.pdf} |
|
577 |
\end{center} |
|
578 |
||
579 |
\begin{itemize} |
|
580 |
\item by Laplante and Ovaska, 2011 (\$113.76) |
|
581 |
\item \it ``when $[$the task$]$ exits the critical section that |
|
582 |
caused the block, it reverts to the priority it had |
|
583 |
when it entered that section'' |
|
584 |
\end{itemize} |
|
585 |
||
586 |
\end{frame} |
|
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
588 |
||
589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
590 |
\begin{frame}[c] |
|
591 |
||
592 |
\begin{center} |
|
593 |
\includegraphics[scale=0.25]{../pics/p4.jpg} |
|
594 |
\end{center} |
|
595 |
||
596 |
\begin{itemize} |
|
597 |
\item by Silberschatz, Galvin, and Gagne, 2013 (OS-bible) |
|
598 |
\item \it ``Upon releasing the lock, the |
|
599 |
$[$low-priority$]$ thread will revert to |
|
600 |
its original priority.'' |
|
601 |
\end{itemize} |
|
602 |
||
603 |
\end{frame} |
|
604 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
605 |
||
606 |
||
607 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
608 |
\begin{frame}[c] |
|
609 |
\frametitle{Priority Scheduling} |
|
610 |
||
611 |
\begin{itemize} |
|
612 |
\item a scheduling algorithm that is widely used in real-time operating systems |
|
613 |
\item has been ``proved'' correct by hand in a paper in 1983 |
|
614 |
\item but this algorithm turned out to be incorrect, despite its ``proof''\bigskip\pause |
|
615 |
||
616 |
\item we used the corrected algorithm and then {\bf really} proved |
|
617 |
that it is correct |
|
618 |
||
619 |
\item we implemented this algorithm in a small OS called PINTOS |
|
620 |
(used for teaching at Stanford) |
|
621 |
||
622 |
\item our implementation was much more efficient than their |
|
623 |
reference implementation |
|
624 |
||
625 |
\end{itemize} |
|
626 |
||
627 |
\end{frame} |
|
628 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
629 |
||
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
630 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
631 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
632 |
\begin{frame}[c] |
538 | 633 |
\frametitle{Big Proofs in CS (1)} |
634 |
||
635 |
Formal proofs in CS sound like science fiction? |
|
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
636 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
637 |
\begin{itemize} |
538 | 638 |
\item in 2008, verification of a C-compiler |
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
639 |
\begin{itemize} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
640 |
\item ``if my input program has a certain behaviour, then the compiled machine code has the same behaviour'' |
538 | 641 |
\item is as good as \texttt{gcc -O1}, but much less buggy |
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
642 |
\end{itemize} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
643 |
\end{itemize} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
644 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
645 |
\begin{center} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
646 |
\includegraphics[scale=0.12]{../pics/compcert.png} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
647 |
\end{center} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
648 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
649 |
\end{frame} |
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
650 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
651 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
652 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
538 | 653 |
% \begin{frame}[c] |
654 |
% \frametitle{Fuzzy Testing C-Compilers} |
|
655 |
||
656 |
% \begin{itemize} |
|
657 |
% \item tested GCC, LLVM and others by randomly generating |
|
658 |
% C-programs |
|
659 |
% \item found more than 300 bugs in GCC and also |
|
660 |
% many in LLVM (some of them highest-level critical)\bigskip |
|
661 |
% \item about CompCert: |
|
662 |
||
663 |
% \begin{bubble}[10cm]\small ``The striking thing about our CompCert |
|
664 |
% results is that the middle-end bugs we found in all other |
|
665 |
% compilers are absent. As of early 2011, the under-development |
|
666 |
% version of CompCert is the only compiler we have tested for |
|
667 |
% which Csmith cannot find wrong-code errors. This is not for |
|
668 |
% lack of trying: we have devoted about six CPU-years to the |
|
669 |
% task.'' |
|
670 |
% \end{bubble} |
|
671 |
% \end{itemize} |
|
672 |
||
673 |
% \end{frame} |
|
674 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
675 |
||
676 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
677 |
\begin{frame}[c] |
538 | 678 |
\frametitle{Big Proofs in CS (2)} |
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
679 |
|
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
680 |
\begin{itemize} |
538 | 681 |
\item in 2010, verification of a micro-kernel operating system (approximately 8700 loc) |
682 |
\begin{itemize} |
|
683 |
\item used in helicopters and mobile phones |
|
684 |
\item 200k loc of proof |
|
685 |
\item 25 - 30 person years |
|
686 |
\item found 160 bugs in the C code (144 by the proof) |
|
687 |
\end{itemize} |
|
688 |
\end{itemize} |
|
689 |
||
690 |
\begin{bubble}[10cm]\small |
|
691 |
``Real-world operating-system kernel with an end-to-end proof |
|
692 |
of implementation correctness and security enforcement'' |
|
693 |
\end{bubble}\bigskip\pause |
|
694 |
||
695 |
unhackable kernel (New Scientists, September 2015) |
|
696 |
\end{frame} |
|
697 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
698 |
||
699 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
700 |
\begin{frame}[c] |
|
701 |
\frametitle{Big Proofs in CS (3)} |
|
702 |
||
703 |
\begin{itemize} |
|
704 |
\item verified TLS implementation\medskip |
|
705 |
\item verified compilers (CompCert, CakeML)\medskip |
|
706 |
\item verified distributed systems (Verdi)\medskip |
|
707 |
\item verified OSes or OS components\\ |
|
708 |
(seL4, CertiKOS, \ldots)\bigskip\pause |
|
709 |
\item Infer static analyser developed by Facebook |
|
710 |
\end{itemize} |
|
711 |
||
712 |
\end{frame} |
|
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
713 |
|
538 | 714 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
715 |
\begin{frame}[c] |
|
716 |
\frametitle{How Did This Happen?} |
|
717 |
||
718 |
Lots of ways! |
|
719 |
||
720 |
\begin{itemize} |
|
721 |
\item better programming languages |
|
722 |
\begin{itemize} |
|
723 |
\item basic safety guarantees built in \item powerful mechanisms for abstraction and modularity |
|
724 |
\end{itemize} |
|
725 |
\item better software development methodology |
|
726 |
\item stable platforms and frameworks |
|
727 |
\item better use of specifications\medskip\\ |
|
728 |
\small If you want to build software that works or is secure, |
|
729 |
it is helpful to know what you mean by ``works'' and by ``is secure''! |
|
730 |
\end{itemize} |
|
731 |
||
732 |
\end{frame} |
|
733 |
||
734 |
||
735 |
||
736 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
737 |
\begin{frame}[c] |
|
738 |
\frametitle{Goal} |
|
739 |
||
740 |
Remember the Bridges example? |
|
741 |
||
742 |
\begin{itemize} |
|
743 |
\item Can we look at our programs and somehow ensure |
|
744 |
they are bug free/correct?\pause\bigskip |
|
745 |
||
746 |
\item Very hard: Anything interesting about programs is equivalent |
|
747 |
to the Halting Problem, which is undecidable.\pause\bigskip |
|
748 |
||
749 |
\item \alert{Solution:} We avoid this ``minor'' obstacle by |
|
750 |
being as close as possible of deciding the halting |
|
751 |
problem, without actually deciding the halting problem. |
|
752 |
\small$\quad\Rightarrow$ yes, no, don't know (static analysis) |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
753 |
\end{itemize} |
206
85b961f1eee9
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
151
diff
changeset
|
754 |
|
383
a6a6bf32fade
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
381
diff
changeset
|
755 |
\end{frame} |
538 | 756 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
757 |
||
758 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
759 |
\begin{frame}[c] |
|
760 |
\frametitle{What is Static Analysis?} |
|
761 |
||
762 |
\begin{center} |
|
763 |
\includegraphics[scale=0.4]{../pics/state.png} |
|
764 |
\end{center} |
|
765 |
||
766 |
\begin{itemize} |
|
767 |
\item depending on some initial input, a program |
|
768 |
(behaviour) will ``develop'' over time. |
|
769 |
\end{itemize} |
|
770 |
||
771 |
\end{frame} |
|
772 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
773 |
||
774 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
775 |
\begin{frame}[c] |
|
776 |
\frametitle{What is Static Analysis?} |
|
777 |
||
778 |
\begin{center} |
|
779 |
\includegraphics[scale=0.4]{../pics/state2.png} |
|
780 |
\end{center} |
|
781 |
||
782 |
\end{frame} |
|
783 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
784 |
||
785 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
786 |
\begin{frame}[c] |
|
787 |
\frametitle{What is Static Analysis?} |
|
788 |
||
789 |
\begin{center} |
|
790 |
\includegraphics[scale=0.4]{../pics/state3.jpg} |
|
791 |
\end{center} |
|
792 |
||
793 |
\end{frame} |
|
794 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
795 |
||
796 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
797 |
\begin{frame}[c] |
|
798 |
\frametitle{What is Static Analysis?} |
|
799 |
||
800 |
\begin{center} |
|
801 |
\includegraphics[scale=0.4]{../pics/state4.jpg} |
|
802 |
\end{center} |
|
803 |
||
804 |
\begin{itemize} |
|
805 |
\item to be avoided |
|
806 |
\end{itemize} |
|
807 |
||
808 |
\end{frame} |
|
809 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
810 |
||
811 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
812 |
\begin{frame}[c] |
|
813 |
\frametitle{What is Static Analysis?} |
|
814 |
||
815 |
\begin{center} |
|
816 |
\includegraphics[scale=0.4]{../pics/state5.png} |
|
817 |
\end{center} |
|
818 |
||
819 |
\begin{itemize} |
|
820 |
\item this needs more work |
|
821 |
\end{itemize} |
|
822 |
||
823 |
\end{frame} |
|
824 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
825 |
||
826 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
827 |
\begin{frame}[c] |
|
828 |
\frametitle{What is Static Analysis?} |
|
829 |
||
830 |
\begin{center} |
|
831 |
\includegraphics[scale=0.4]{../pics/state6.png} |
|
832 |
\end{center} |
|
833 |
||
834 |
\end{frame} |
|
835 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
836 |
||
837 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
838 |
\begin{frame}[c,fragile] |
|
839 |
\frametitle{\Large\begin{tabular}{c}Concrete Example:\\[-1mm] |
|
840 |
Are Vars Definitely Initialised?\end{tabular}} |
|
841 |
||
842 |
Assuming \texttt{x} is initialised, what about \texttt{y}?\bigskip |
|
843 |
||
844 |
Prog.~1:\\ |
|
845 |
\begin{lstlisting}[numbers=none, |
|
846 |
basicstyle=\ttfamily, |
|
847 |
language=While,xleftmargin=3mm] |
|
848 |
if x < 1 then y := x else y := x + 1; |
|
849 |
y := y + 1 |
|
850 |
\end{lstlisting}\medskip |
|
851 |
||
852 |
Prog.~2:\\ |
|
853 |
\begin{lstlisting}[numbers=none, |
|
854 |
basicstyle=\ttfamily, |
|
855 |
language=While,xleftmargin=3mm] |
|
856 |
if x < x then y := y + 1 else y := x; |
|
857 |
y := y + 1 |
|
858 |
\end{lstlisting} |
|
859 |
||
860 |
\end{frame} |
|
861 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
862 |
||
863 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
864 |
\begin{frame}[c,fragile] |
|
865 |
\frametitle{\Large\begin{tabular}{c}Concrete Example:\\[-1mm] |
|
866 |
Are Vars Definitely Initialised?\end{tabular}} |
|
867 |
||
868 |
What should the rules be for deciding when a |
|
869 |
variable is initialised?\bigskip\pause |
|
870 |
||
871 |
\begin{itemize} |
|
872 |
\item variable \texttt{x} is definitely initialized after |
|
873 |
\texttt{skip}\\ |
|
874 |
iff \texttt{x} is definitely initialized before \texttt{skip}. |
|
875 |
\end{itemize} |
|
876 |
||
877 |
\end{frame} |
|
878 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
879 |
||
880 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
881 |
\begin{frame}[c,fragile] |
|
882 |
% \frametitle{\Large\begin{tabular}{c}Concrete Example:\\[-1mm] |
|
883 |
% Are Vars Definitely Initialised?\end{tabular}} |
|
884 |
||
885 |
$\bl{A}$ is the set of definitely defined variables: |
|
886 |
||
887 |
\begin{center} |
|
888 |
\begin{tabular}{c} |
|
889 |
\bl{\infer{\mbox{}}{A\;\texttt{skip}\;A}}\qquad |
|
890 |
\bl{\infer{vars(a) \subseteq A}{A\;\;(\texttt{x\,:=\,a})\;\;\{x\}\cup A}} |
|
891 |
\medskip\\\pause |
|
892 |
||
893 |
\bl{\infer{A_1\;s_1\;A_2\quad A_2\;s_2\;A_3}{A_1\;(s_1 ; s_2)\;A_3}} |
|
894 |
\medskip\\\pause |
|
895 |
||
896 |
\bl{\infer{vars(b)\subseteq A\quad A\;s_1\;A_1\quad A\;s_2\;A_2} |
|
897 |
{A\;(\texttt{if}\;b\;\texttt{then}\;s_1\;\texttt{else}\;s_2)\;A_1\cap A_2}} |
|
898 |
\medskip\\\pause |
|
899 |
||
900 |
\bl{\infer{vars(b)\subseteq A\quad A\;s\;A'} |
|
901 |
{A\;(\texttt{while}\;b\;\texttt{do}\;s)\;A}}\pause |
|
902 |
\end{tabular} |
|
903 |
\end{center} |
|
904 |
||
905 |
\hfill we start with $\bl{A = \{\}}$ |
|
906 |
\end{frame} |
|
907 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
908 |
||
909 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
910 |
\begin{frame}[fragile] |
|
911 |
\frametitle{\large Concrete Example: Sign-Analysis} |
|
912 |
\mbox{}\\[-20mm]\mbox{} |
|
913 |
||
914 |
\bl{\begin{plstx}[rhs style=,one per line] : \meta{Exp} ::= \meta{Exp} + \meta{Exp} |
|
915 |
| \meta{Exp} * \meta{Exp} |
|
916 |
| \meta{Exp} = \meta{Exp} |
|
917 |
| \meta{num} |
|
918 |
| \meta{var}\\ |
|
919 |
: \meta{Stmt} ::= \meta{label} : |
|
920 |
| \meta{var} := \meta{Exp} |
|
921 |
| \pcode{jmp?} \meta{Exp} \meta{label} |
|
922 |
| \pcode{goto} \meta{label}\\ |
|
923 |
: \meta{Prog} ::= \meta{Stmt} \ldots{} \meta{Stmt}\\ |
|
924 |
\end{plstx}} |
|
925 |
||
926 |
\begin{textblock}{0}(7.8,2.5) |
|
927 |
\small |
|
928 |
\begin{bubble}[5.6cm] |
|
929 |
\begin{lstlisting}[numbers=none, |
|
930 |
basicstyle=\ttfamily, |
|
931 |
language={},xleftmargin=3mm] |
|
932 |
a := 1 |
|
933 |
n := 5 |
|
934 |
top: jmp? n = 0 done |
|
935 |
a := a * n |
|
936 |
n := n + -1 |
|
937 |
goto top |
|
938 |
done: |
|
939 |
\end{lstlisting} |
|
940 |
\end{bubble} |
|
941 |
\end{textblock} |
|
942 |
||
943 |
\end{frame} |
|
944 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
945 |
||
946 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
947 |
\begin{frame}[fragile] |
|
948 |
\frametitle{\large Concrete Example: Sign-Analysis} |
|
949 |
\mbox{}\\[-20mm]\mbox{} |
|
950 |
||
951 |
\bl{\begin{plstx}[rhs style=,one per line] : \meta{Exp} ::= \meta{Exp} + \meta{Exp} |
|
952 |
| \meta{Exp} * \meta{Exp} |
|
953 |
| \meta{Exp} = \meta{Exp} |
|
954 |
| \meta{num} |
|
955 |
| \meta{var}\\ |
|
956 |
: \meta{Stmt} ::= \meta{label} : |
|
957 |
| \meta{var} := \meta{Exp} |
|
958 |
| \pcode{jmp?} \meta{Exp} \meta{label} |
|
959 |
| \pcode{goto} \meta{label}\\ |
|
960 |
: \meta{Prog} ::= \meta{Stmt} \ldots{} \meta{Stmt}\\ |
|
961 |
\end{plstx}} |
|
962 |
||
963 |
\begin{textblock}{0}(7.8,3.5) |
|
964 |
\small |
|
965 |
\begin{bubble}[5.6cm] |
|
966 |
\begin{lstlisting}[numbers=none, |
|
967 |
basicstyle=\ttfamily, |
|
968 |
language={},xleftmargin=3mm] |
|
969 |
n := 6 |
|
970 |
m1 := 0 |
|
971 |
m2 := 1 |
|
972 |
top: jmp? n = 0 done |
|
973 |
tmp := m2 |
|
974 |
m2 := m1 + m2 |
|
975 |
m1 := tmp |
|
976 |
n := n + -1 |
|
977 |
goto top |
|
978 |
done: |
|
979 |
\end{lstlisting} |
|
980 |
\end{bubble} |
|
981 |
\end{textblock} |
|
982 |
||
983 |
\end{frame} |
|
984 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
985 |
||
986 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
987 |
\begin{frame}[fragile] |
|
988 |
\frametitle{\large Concrete Example: Sign-Analysis} |
|
989 |
\mbox{}\\[-20mm]\mbox{} |
|
990 |
||
991 |
\bl{\begin{plstx}[rhs style=,one per line] : \meta{Exp} ::= \meta{Exp} + \meta{Exp} |
|
992 |
| \meta{Exp} * \meta{Exp} |
|
993 |
| \meta{Exp} = \meta{Exp} |
|
994 |
| \meta{num} |
|
995 |
| \meta{var}\\ |
|
996 |
: \meta{Stmt} ::= \meta{label} : |
|
997 |
| \meta{var} := \meta{Exp} |
|
998 |
| \pcode{jmp?} \meta{Exp} \meta{label} |
|
999 |
| \pcode{goto} \meta{label}\\ |
|
1000 |
: \meta{Prog} ::= \meta{Stmt} \ldots{} \meta{Stmt}\\ |
|
1001 |
\end{plstx}} |
|
1002 |
||
1003 |
\end{frame} |
|
1004 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1005 |
||
1006 |
||
1007 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1008 |
\begin{frame}[fragile] |
|
1009 |
\frametitle{Eval: An Interpreter} |
|
1010 |
\mbox{}\\[-14mm]\mbox{} |
|
1011 |
||
1012 |
\small |
|
1013 |
\begin{center} |
|
1014 |
\bl{\begin{tabular}{lcl} |
|
1015 |
$[n]_{env}$ & $\dn$ & $n$\\ |
|
1016 |
$[x]_{env}$ & $\dn$ & $env(x)$\\ |
|
1017 |
$[e_1 + e_2]_{env}$ & $\dn$ & $[e_1]_{env} + [e_2]_{env}$\\ |
|
1018 |
$[e_1 * e_2]_{env}$ & $\dn$ & $[e_1]_{env} * [e_2]_{env}$\\ |
|
1019 |
$[e_1 = e_2]_{env}$ & $\dn$ & |
|
1020 |
$\begin{cases} |
|
1021 |
1 & \text{if}\quad[e_1]_{env} = [e_2]_{env}\\ |
|
1022 |
0 & \text{otherwise} |
|
1023 |
\end{cases}$\\ |
|
1024 |
\end{tabular}} |
|
1025 |
\end{center} |
|
1026 |
||
1027 |
\footnotesize |
|
1028 |
\begin{lstlisting}[numbers=none,xleftmargin=-5mm] |
|
1029 |
def eval_exp(e: Exp, env: Env) : Int = e match { |
|
1030 |
case Num(n) => n |
|
1031 |
case Var(x) => env(x) |
|
1032 |
case Plus(e1, e2) => eval_exp(e1, env) + eval_exp(e2, env) |
|
1033 |
case Times(e1, e2) => eval_exp(e1, env) * eval_exp(e2, env) |
|
1034 |
case Equ(e1, e2) => |
|
1035 |
if (eval_exp(e1, env) == eval_exp(e2, env)) 1 else 0 |
|
1036 |
} |
|
1037 |
\end{lstlisting} |
|
1038 |
||
1039 |
\end{frame} |
|
1040 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1041 |
||
1042 |
||
1043 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1044 |
\begin{frame}[fragile] |
|
1045 |
\small |
|
1046 |
A program |
|
1047 |
\begin{bubble}[6cm]\footnotesize |
|
1048 |
\begin{lstlisting}[numbers=none, |
|
1049 |
language={}, |
|
1050 |
basicstyle=\ttfamily, |
|
1051 |
xleftmargin=1mm] |
|
1052 |
a := 1 |
|
1053 |
n := 5 |
|
1054 |
top: jmp? n = 0 done |
|
1055 |
a := a * n |
|
1056 |
n := n + -1 |
|
1057 |
goto top |
|
1058 |
done: |
|
1059 |
\end{lstlisting} |
|
1060 |
\end{bubble} |
|
1061 |
||
1062 |
The \emph{snippets} of the program: |
|
1063 |
||
1064 |
\footnotesize |
|
1065 |
\begin{columns} |
|
1066 |
\begin{column}[t]{5cm} |
|
1067 |
\begin{bubble}[4.5cm] |
|
1068 |
\begin{lstlisting}[numbers=none, |
|
1069 |
basicstyle=\ttfamily, |
|
1070 |
language={},xleftmargin=1mm] |
|
1071 |
"" a := 1 |
|
1072 |
n := 5 |
|
1073 |
top: jmp? n = 0 done |
|
1074 |
a := a * n |
|
1075 |
n := n + -1 |
|
1076 |
goto top |
|
1077 |
done: |
|
1078 |
\end{lstlisting} |
|
1079 |
\end{bubble} |
|
1080 |
\end{column} |
|
1081 |
\begin{column}[t]{5cm} |
|
1082 |
\begin{bubble}[4.5cm] |
|
1083 |
\begin{lstlisting}[numbers=none, |
|
1084 |
basicstyle=\ttfamily, |
|
1085 |
language={},xleftmargin=1mm] |
|
1086 |
top: jmp? n = 0 done |
|
1087 |
a := a * n |
|
1088 |
n := n + -1 |
|
1089 |
goto top |
|
1090 |
done: |
|
1091 |
\end{lstlisting} |
|
1092 |
\end{bubble} |
|
1093 |
\end{column} |
|
1094 |
\begin{column}[t]{2cm} |
|
1095 |
\begin{bubble}[1.1cm] |
|
1096 |
\begin{lstlisting}[numbers=none, |
|
1097 |
basicstyle=\ttfamily, |
|
1098 |
language={},xleftmargin=1mm] |
|
1099 |
done: |
|
1100 |
\end{lstlisting} |
|
1101 |
\end{bubble} |
|
1102 |
\end{column} |
|
1103 |
\end{columns} |
|
1104 |
||
1105 |
\end{frame} |
|
1106 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1107 |
||
1108 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1109 |
\begin{frame}[fragile] |
|
1110 |
\frametitle{Eval for Stmts} |
|
1111 |
\mbox{}\\[-12mm]\mbox{} |
|
1112 |
||
1113 |
Let \bl{$sn$} be the snippets of a program |
|
1114 |
||
1115 |
\small |
|
1116 |
\begin{center} |
|
1117 |
\bl{\begin{tabular}{lcl} |
|
1118 |
$[\texttt{nil}]_{env}$ & $\dn$ & $env$\medskip\\ |
|
1119 |
$[\texttt{Label}(l:)::rest]_{env}$ & $\dn$ & $[rest]_{env}$\medskip\\ |
|
1120 |
$[x \,\texttt{:=}\, a::rest]_{env}$ & $\dn$ & |
|
1121 |
$[rest]_{(env[x:= [a]_{env}])}$\medskip\\ |
|
1122 |
$[\texttt{jmp?}\;b\;l::rest]_{env}$ & $\dn$ & |
|
1123 |
$\begin{cases} |
|
1124 |
[sn(l)]_{env} & \text{if}\quad[b]_{env} = true\\ |
|
1125 |
[rest]_{env} & \text{otherwise} |
|
1126 |
\end{cases}$\medskip\\ |
|
1127 |
$[\texttt{goto}\;l::rest]_{env}$ & $\dn$ & $[sn(l)]_{env}$\\ |
|
1128 |
\end{tabular}} |
|
1129 |
\end{center}\bigskip |
|
1130 |
||
1131 |
Start with \bl{$[sn(\mbox{\code{""}})]_{\varnothing}$} |
|
1132 |
||
1133 |
\end{frame} |
|
1134 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1135 |
||
1136 |
||
1137 |
||
1138 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1139 |
\begin{frame}[fragile] |
|
1140 |
\frametitle{Eval in Code} |
|
1141 |
||
1142 |
\footnotesize |
|
1143 |
\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-5mm] |
|
1144 |
def eval(sn: Snips) : Env = { |
|
1145 |
def eval_stmts(sts: Stmts, env: Env) : Env = sts match { |
|
1146 |
case Nil => env |
|
1147 |
||
1148 |
case Label(l)::rest => eval_stmts(rest, env) |
|
1149 |
||
1150 |
case Assign(x, e)::rest => |
|
1151 |
eval_stmts(rest, env + (x -> eval_exp(e, env))) |
|
1152 |
||
1153 |
case Jmp(b, l)::rest => |
|
1154 |
if (eval_exp(b, env) == 1) eval_stmts(sn(l), env) |
|
1155 |
else eval_stmts(rest, env) |
|
1156 |
||
1157 |
case Goto(l)::rest => eval_stmts(sn(l), env) |
|
1158 |
} |
|
1159 |
||
1160 |
eval_stmts(sn(""), Map()) |
|
1161 |
} |
|
1162 |
\end{lstlisting} |
|
1163 |
||
1164 |
\end{frame} |
|
1165 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1166 |
||
1167 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1168 |
\begin{frame}[fragile] |
|
1169 |
\frametitle{The Idea of Static Analysis} |
|
1170 |
\small |
|
1171 |
\mbox{}\bigskip\\ |
|
1172 |
||
1173 |
\begin{columns} |
|
1174 |
\begin{column}{5cm} |
|
1175 |
\begin{bubble}[4.5cm]\footnotesize |
|
1176 |
\begin{lstlisting}[numbers=none, |
|
1177 |
language={}, |
|
1178 |
basicstyle=\ttfamily, |
|
1179 |
xleftmargin=1mm] |
|
1180 |
a := 1 |
|
1181 |
n := 5 |
|
1182 |
top: jmp? n = 0 done |
|
1183 |
a := a * n |
|
1184 |
n := n + -1 |
|
1185 |
goto top |
|
1186 |
done: |
|
1187 |
\end{lstlisting} |
|
1188 |
\end{bubble} |
|
1189 |
\end{column} |
|
1190 |
||
1191 |
\begin{column}{1cm} |
|
1192 |
\raisebox{-20mm}{\LARGE\bf$\Rightarrow$} |
|
1193 |
\end{column} |
|
1194 |
\begin{column}{6cm} |
|
1195 |
\begin{bubble}[4.7cm]\footnotesize |
|
1196 |
\begin{lstlisting}[numbers=none, |
|
1197 |
language={}, |
|
1198 |
basicstyle=\ttfamily, |
|
1199 |
xleftmargin=1mm, |
|
1200 |
escapeinside={(*}{*)}] |
|
1201 |
a := (*\hl{'+'}*) |
|
1202 |
n := (*\hl{'+'}*) |
|
1203 |
top: jmp? n = (*\hl{'0'}*) done |
|
1204 |
a := a * n |
|
1205 |
n := n + (*\hl{'-'}*) |
|
1206 |
goto top |
|
1207 |
done: |
|
1208 |
\end{lstlisting} |
|
1209 |
\end{bubble} |
|
1210 |
\end{column} |
|
1211 |
\end{columns}\bigskip\bigskip |
|
1212 |
||
1213 |
Replace all constants and variables by either |
|
1214 |
\pcode{+}, \pcode{-} or \pcode{0}. What we want to find out |
|
1215 |
is what the sign of \texttt{a} and \texttt{n} is (they should |
|
1216 |
always positive). |
|
1217 |
||
1218 |
\end{frame} |
|
1219 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1220 |
||
1221 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1222 |
\begin{frame}[c] |
|
1223 |
\frametitle{Sign Analysis?} |
|
1224 |
||
1225 |
||
1226 |
\begin{columns} |
|
1227 |
\begin{column}{3cm} |
|
1228 |
\begin{tabular}{cc|l} |
|
1229 |
$e_1$ & $e_2$ & $e_1 + e_2$\\\hline{} |
|
1230 |
- & - & -\\ |
|
1231 |
- & 0 & -\\ |
|
1232 |
- & + & -, 0, +\\ |
|
1233 |
0 & $x$ & $x$\\ |
|
1234 |
+ & - & -, 0, +\\ |
|
1235 |
+ & 0 & +\\ |
|
1236 |
+ & + & +\\ |
|
1237 |
\end{tabular} |
|
1238 |
\end{column} |
|
1239 |
||
1240 |
\begin{column}{3cm} |
|
1241 |
\begin{tabular}{cc|l} |
|
1242 |
$e_1$ & $e_2$ & $e_1 * e_2$\\\hline{} |
|
1243 |
- & - & +\\ |
|
1244 |
- & 0 & 0\\ |
|
1245 |
- & + & -\\ |
|
1246 |
0 & $x$ & 0\\ |
|
1247 |
+ & - & -\\ |
|
1248 |
+ & 0 & 0\\ |
|
1249 |
+ & + & +\\ |
|
1250 |
\end{tabular} |
|
1251 |
\end{column} |
|
1252 |
\end{columns} |
|
1253 |
||
1254 |
\end{frame} |
|
1255 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1256 |
||
1257 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1258 |
\begin{frame}[fragile] |
|
1259 |
\mbox{}\\[-13mm]\mbox{} |
|
1260 |
||
1261 |
\small |
|
1262 |
\begin{center} |
|
1263 |
\bl{\begin{tabular}{lcl} |
|
1264 |
$[n]_{aenv}$ & $\dn$ & |
|
1265 |
$\begin{cases} |
|
1266 |
\{+\} & \text{if}\; n > 0\\ |
|
1267 |
\{-\} & \text{if}\; n < 0\\ |
|
1268 |
\{0\} & \text{if}\; n = 0 |
|
1269 |
\end{cases}$\\ |
|
1270 |
$[x]_{aenv}$ & $\dn$ & $aenv(x)$\\ |
|
1271 |
$[e_1 + e_2]_{aenv}$ & $\dn$ & $[e_1]_{aenv} \oplus [e_2]_{aenv}$\\ |
|
1272 |
$[e_1 * e_2]_{aenv}$ & $\dn$ & $[e_1]_{aenv} \otimes [e_2]_{aenv}$\\ |
|
1273 |
$[e_1 = e_2]_{aenv}$ & $\dn$ & $\{0, +\}$\\ |
|
1274 |
\end{tabular}} |
|
1275 |
\end{center} |
|
1276 |
||
1277 |
\scriptsize |
|
1278 |
\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-5mm] |
|
1279 |
def aeval_exp(e: Exp, aenv: AEnv) : Set[Abst] = e match { |
|
1280 |
case Num(0) => Set(Zero) |
|
1281 |
case Num(n) if (n < 0) => Set(Neg) |
|
1282 |
case Num(n) if (n > 0) => Set(Pos) |
|
1283 |
case Var(x) => aenv(x) |
|
1284 |
case Plus(e1, e2) => |
|
1285 |
aplus(aeval_exp(e1, aenv), aeval_exp(e2, aenv)) |
|
1286 |
case Times(e1, e2) => |
|
1287 |
atimes(aeval_exp(e1, aenv), aeval_exp(e2, aenv)) |
|
1288 |
case Equ(e1, e2) => Set(Zero, Pos) |
|
1289 |
} |
|
1290 |
\end{lstlisting} |
|
1291 |
||
1292 |
\end{frame} |
|
1293 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1294 |
||
1295 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1296 |
\begin{frame}[fragile] |
|
1297 |
\frametitle{AEval for Stmts} |
|
1298 |
\mbox{}\\[-12mm]\mbox{} |
|
1299 |
||
1300 |
Let \bl{$sn$} be the snippets of a program |
|
1301 |
||
1302 |
\small |
|
1303 |
\begin{center} |
|
1304 |
\bl{\begin{tabular}{lcl} |
|
1305 |
$[\texttt{nil}]_{aenv}$ & $\to$ & $(\texttt{nil},aenv)$\medskip\\ |
|
1306 |
$[\texttt{Label}(l:)::rest]_{aenv}$ & $\to$ & $(rest, aenv)$\medskip\\ |
|
1307 |
$[x \,\texttt{:=}\, e::rest]_{aenv}$ & $\to$ & |
|
1308 |
$(rest, aenv[x:= [e]_{aenv}])$\medskip\\ |
|
1309 |
$[\texttt{jmp?}\;e\;l::rest]_{aenv}$ & $\to$ & |
|
1310 |
$(sn(l),aenv)$ \textcolor{black}{and} $(rest, aenv)$\medskip\\ |
|
1311 |
$[\texttt{goto}\;l::rest]_{aenv}$ & $\to$ & $(sn(l), aenv)$\\ |
|
1312 |
\end{tabular}} |
|
1313 |
\end{center}\bigskip |
|
1314 |
||
1315 |
Start with \bl{$[sn(\mbox{\code{""}})]_{\varnothing}$}, try to |
|
1316 |
reach all \emph{states} you can find (until a fix point is reached). |
|
1317 |
||
1318 |
Check whether there are only $aenv$ in the final states that have |
|
1319 |
your property. |
|
1320 |
\end{frame} |
|
1321 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1322 |
||
1323 |
||
1324 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1325 |
\begin{frame}[c] |
|
1326 |
\frametitle{Sign Analysis} |
|
1327 |
||
1328 |
\begin{itemize} |
|
1329 |
\item We want to find out whether \texttt{a} and \texttt{n} |
|
1330 |
are always positive?\medskip |
|
1331 |
\item After a few optimisations, we can indeed find this out. |
|
1332 |
\begin{itemize} |
|
1333 |
\item equal signs return only \texttt{+} or \texttt{0} |
|
1334 |
\item branch into only one direction if you know |
|
1335 |
\item if $x$ is \texttt{+}, then $x + \texttt{-1}$ |
|
1336 |
cannot be negative |
|
1337 |
\end{itemize}\bigskip |
|
1338 |
||
1339 |
\item What is this good for? Well, you do not need |
|
1340 |
underflow checks (in order to prevent buffer-overflow |
|
1341 |
attacks). In general this technique is used to make sure |
|
1342 |
keys stay secret. |
|
1343 |
\end{itemize} |
|
1344 |
||
1345 |
\end{frame} |
|
1346 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1347 |
||
1348 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1349 |
\begin{frame}[c] |
|
1350 |
\frametitle{Take Home Points} |
|
1351 |
||
1352 |
\begin{itemize} |
|
1353 |
\item While testing is important, it does not show the |
|
1354 |
absence of bugs/vulnerabilities.\medskip |
|
1355 |
\item More and more we need (formal) proofs that show |
|
1356 |
a program is bug free.\medskip |
|
1357 |
||
1358 |
\item Static analysis is more and more employed nowadays |
|
1359 |
in order to automatically hunt for bugs. |
|
1360 |
\end{itemize} |
|
1361 |
||
1362 |
\end{frame} |
|
1363 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1364 |
||
1365 |
||
82
06c3ec0b452e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
81
diff
changeset
|
1366 |
|
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1367 |
\end{document} |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1368 |
|
538 | 1369 |
|
65
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1370 |
%%% Local Variables: |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1371 |
%%% mode: latex |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1372 |
%%% TeX-master: t |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1373 |
%%% End: |
ade6af51402c
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1374 |