CPSC 213 Introduction to Computer Systems
Unit 0
Introduction
1
About the Course
‣ its all on the web page …
• http://www.cs.ubc.ca/~feeley/cs213
• Lecture Notes Companion • Piazza
‣ marks
• in-class clicker questions (you will need a clicker) • labs
• quizzes
• midterm
• final
‣ work together! but don’t cheat!
• never present anyone else’s work as your own
– it is your responsibility to provide proper attribution
• anything you hand in in this course should follow this rule anything • but, don’t let this stop you from helping each other learn …
2
Overview of the course
‣ Hardware context of a single executing program • hardware context is CPU and Main Memory
• develop CPU architecture to implement C and Java
• differentiate compiler (static) and runtime (dynamic) computation
‣ System context of multiple executing programs with IO • extend context to add IO, concurrency and system software
• thread abstraction to hide IO asynchrony and to express concurrency • synchronization to manage concurrency
• virtual memory to provide multi-program, single-system model
• hardware protection to encapsulate operating system
• message-passing to communicate between processes and machines
GOAL: To develop a model of computation that is rooted in what really happens when programs execute.
3
What you will get out of this …
‣ Become a better programmer by
• deepening your understand of how programs execute • learning to build concurrent and distributed programs
‣ Learn to design real systems by
• evaluating design trade-offs through examples
• distinguish static and dynamic system components and techniques
‣ Impress your friends and family by • telling them what a program really is
4
What do you know now?
5
What happens what a program runs
‣ Here’s a program
class SortedList {
static SortedList aList;
int size;
int list[];
void insert (int aValue) {
int i = 0;
while (list[i] <= aValue)
i++;
for (int j=size-1; j>=i; j–)
list[j+1] = list[j];
list[i] = aValue;
size++;
} }
‣ What do you understand about the execution of insert?
6
‣ Example
• list stores { 1, 3, 5, 7, 9 }
• SortedList.aList.insert(6) is called
‣ Data structures
• draw a diagram of the data structures
• as they exist just before insert is called
class SortedList {
static SortedList aList;
int size;
int list[];
void insert (int aValue) {
int i = 0;
while (list[i] <= aValue)
i++;
for (int j=size-1; j>=i; j–)
list[j+1] = list[j];
list[i] = aValue;
size++;
} }
SortList Class
aList
3 a SortedList Object 5
assuming list[] was initialized to store 10 elements:
size 5 7
list 9 0
1
0 0 0 0
list = new Integer[10];
7
‣ Data structures
• lets dig a little deeper
• which of these existed before program started? – these are the static features of the program
• which were created by execution of program? – these are the dynamic features of the program
SortList Class
aList
class SortedList {
static SortedList aList;
int size;
int list[];
void insert (int aValue) {
int i = 0;
while (list[i] <= aValue)
i++;
for (int j=size-1; j>=i; j–)
list[j+1] = list[j];
list[i] = aValue;
size++;
} }
Static:
* class and aList variable (sort of – clearer in C)
Dynamic:
* SortedList object
* size and list variables
* value of aList, size and list * list of 10 integers
3 a SortedList Object 5
size 5 7
list 9 0
1
0 0 0 0
8
‣ Execution of insert
• how would you describe this execution? • carefully, step by step?
Sequence of Instructions
* program order
* changed by control-flow structures
save location of SortedList.aList.insert(6) aValue = 6
i=0
goto end-while if list[i]>aValue (1>6)
class SortedList {
static SortedList aList;
int size;
int list[];
void insert (int aValue) {
int i = 0;
while (list[i] <= aValue)
i++;
for (int j=size-1; j>=i; j–)
list[j+1] = list[j];
list[i] = aValue;
size++;
} }
Instruction Types?
* read/write variable * arithmetic
* conditional goto
i = 0+1 (1)
goto end-while
i = 1+1 (2)
goto end-while
i = 2+1 (3)
goto end-while
if list[i]>aValue (3>6)
if list[i]>aValue (5>6)
if list[i]>aValue (7>6)
end-while: j = size-1 (4)
goto end-if if j