CS计算机代考程序代写 compiler concurrency mips data structure Java assembly cache CPSC 213 Introduction to Computer Systems

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
size 5 79 list 0 0
assuming list[] was initialized to store 10 elements:
list = new Integer[10];
‣ Data structures
• lets dig a little deeper
class SortedList {
static SortedList aList; int size;
int list[];
• 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
a SortedList Object
size 5 list
1 3
57 9 0
0 0 0
(sort of – clearer in C)
Dynamic:
* SortedList object
* size and list variables
* value of aList, size and list * list of 10 integers
1
0 0 0
7
void insert (int aValue) { inti=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
8

‣ Execution of insert
• how would you describe this execution? • carefully, step by step?
Sequence of Instructions
* program order
* changed by control-flow structures
i = 0+1 (1) goto end-while i = 1+1 (2) goto end-while i = 2+1 (3) goto end-while
end-while: j = size-1 (4)
goto end-if list[i+1] = j = 5-1 (3) goto end-if list[i+1] = j = 4-1 (2) goto end-if
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
save location of SortedList.aList.insert(6) aValue = 6
i=0
goto end-while
if jaValue (1>6) if list[i]>aValue (3>6) if list[i]>aValue (5>6) if list[i]>aValue (7>6) j