Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to CS – Honors I Introduction GEORGIOS PORTOKALIDIS

Similar presentations


Presentation on theme: "Intro to CS – Honors I Introduction GEORGIOS PORTOKALIDIS"— Presentation transcript:

1 Intro to CS – Honors I Introduction GEORGIOS PORTOKALIDIS GPORTOKA@STEVENS.EDU

2 Today’s Lecture Logistics ◦Course information ◦Grading Introduction to computer architecture ◦Software and hardware ◦How do programs run Programming languages ◦From high-level languages to programs machines understand ◦Java programs 8/26/2013CS181 - INTRO TO CS - HONORS I 2

3 Logistics Information about the course can be found in: ◦The website http://www.cs.stevens.edu/~gportoka/cs181.htmlhttp://www.cs.stevens.edu/~gportoka/cs181.html ◦Moodle Schedule ◦Lectures are on Monday and Wednesday 12:00-12:50pm (E229) ◦Lab is on Thursday 12:00-1:40pm (B430) ◦Teaching assistant Sadia Akhter ◦Office hours are on Monday 1:00-2:00pm (L213) Books ◦Java: An Introduction to Problem Solving and Programming, 6/E W.Savitch Addison-Wesley, 2012 ISBN 0132162709 (ISBN-13: 9780132162708)Java: An Introduction to Problem Solving and Programming, 6/E ◦More in the course’s website 8/26/2013CS181 - INTRO TO CS - HONORS I 3

4 Grading Your grade will be determined by: ◦2 midterm exams (15% each) ◦The final exam (30%) ◦Assignments given approximately biweekly (40%) ◦Solutions to the assignments will be discussed in the lab ◦No late submissions No cheating ◦Stevens honor system "The Honor System at Stevens [..] insures that work submitted by students can be trusted as their own and was performed in an atmosphere of honesty and fair play." 8/26/2013CS181 - INTRO TO CS - HONORS I 4

5 Questions Before emailing anyone search online Use the mailing list: cs181@lists.stevens.educs181@lists.stevens.edu Then ask the teaching assistant or the instructor 8/26/2013CS181 - INTRO TO CS - HONORS I 5

6 A Short Survey How many of you have done any programming in any language? How many of you have programmed in Java? 8/26/2013CS181 - INTRO TO CS - HONORS I 6

7 Picking the Right Course CS 105 ◦If you were never exposed to programming ◦Basic programming and problem solving concepts ◦Very little coding CS 115 ◦You have a bit of experience ◦Learn the basic of programming using Python CS 181 ◦You have done a little programming ◦Learn the fundamentals using Java ◦Learn object-oriented programming ◦Learn data structures and simple algorithms 8/26/2013CS181 - INTRO TO CS - HONORS I 7

8 Do you Like Hacking Learn how things work Break and fix software and hardware Participate in capture the flag competitions Join the hacking club next semester ◦You can also get course credit for your trouble ◦Take the CS 397 ◦Equal to one course if taken for 3 semesters ◦Informal meeting focusing on solving hacking challenges 8/26/2013CS181 - INTRO TO CS - HONORS I 8

9 Intro to Computer Architecture SoftwareHardware Computer Systems Physical Programs 8/26/2013CS181 - INTRO TO CS - HONORS I 9

10 Hardware CPU Memory Peripherals I/O Bus Executes simple instructions Stores data and instructions Input and output devices 8/26/2013CS181 - INTRO TO CS - HONORS I 10

11 Software Software consists of instructions and data Instructions define how a program operates ◦Example: the mathematical operations that need to be performed to calculate the circumference of a circle Data can be… ◦your documents, pictures, videos, etc. ◦but also intrinsic to the program, e.g., the pi (π) constant 8/26/2013CS181 - INTRO TO CS - HONORS I 11

12 Computer Representation of Data The smallest piece of information a computer can store and understand a bit ◦A bit has only two states: 0 or 1 ◦Why only two states? Bits are grouped into bytes ◦1 byte = 8 bits Bytes can also be grouped ◦word = 2 bytes ◦double word = 4 bytes ◦quad word = 8 bytes 8/26/2013CS181 - INTRO TO CS - HONORS I 12 double word (or 32-bit word) word (or 16-bit word)

13 Memory Almost all modern computers follow the Von Neumann architecture ◦Data and instructions share the same memory ◦Memory is RAM (Random Access Memory) Target data RAM Memory access instruction Target data Sequential Access Memory Memory access instruction RAM is also volatile, unlike ROM that is read only! 8/26/2013CS181 - INTRO TO CS - HONORS I 13

14 Memory Addressing Memory is split into “slots” ◦How big is each slot? ◦Typical sizes are 1, 2, 4, and 8 bytes ◦The smallest slot that can be accessed is 1 byte Each slot has its own numeric address ◦How big can the address space be? ◦Most systems can currently address up to 2 64 different memory locations Aligned memory access ◦When reading 2, 4, or 8 bytes some architectures require that the address is aligned ◦An access is aligned if the address is exactly divisible by the size of the access RAM Instructions Data Instructions Data 8/26/2013CS181 - INTRO TO CS - HONORS I 14

15 How Do Programs Run? Instruction 1 Instruction 2 Instruction 3 … Instruction N Data CPU RAM Our program Registers ALU FPU Arithmetic Logic Unit The brain! The CPU’s own very fast memory Floating Point Unit Other extensions PC Program Counter 8/26/2013CS181 - INTRO TO CS - HONORS I 15

16 How Do Programs Run? Instruction 1 Instruction 2 Instruction 3 … Instruction N Data CPU RAM Our program Registers ALU FPU PC The CPU is continuously performing (looping) the following steps: 1. Fetch instruction pointed to by PC 2. Execute the instruction 3. Increment PC 4. Go back to 1 In a sense, the CPU includes its own program! 8/26/2013CS181 - INTRO TO CS - HONORS I 16

17 Program Instructions What kind of instructions do you think the CPU executes? What type of instructions are required for a computer to be useful? Instructions are very simple Alan Turing showed that all calculations require only a few instructions Examples: ◦Load/store data from/to memory to/from registers ◦Perform an arithmetic or logical operation between registers Simple instructions can be made to execute really fast ◦RISC - Reduced Instruction Set Computer (ARM, SPARC) ◦Operations can only be performed with data in registers 8/26/2013CS181 - INTRO TO CS - HONORS I 17

18 Other Instruction Sets CISC – Complex Instruction Set Computer Do you know any models using this architecture? Intel CPUs are CISC ◦These days they are built as RISC, supporting CISC instruction sets ◦Operations using data in memory are also supported 8/26/2013CS181 - INTRO TO CS - HONORS I 18

19 Memory Hierarchies CPU RAM Registers ALU FPU PC Cache Cache enables fast access of frequently accessed RAM 8/26/2013CS181 - INTRO TO CS - HONORS I 19

20 Multi-level Caches CPU RAM Registers ALU FPU PC Cache 8/26/2013CS181 - INTRO TO CS - HONORS I 20 Level 2 Cache Can be placed in various ways

21 From Languages to Instructions Machine Language Basically structured numbers High-level languages Easily understandable by humans. Java, C, C++, Python, Ruby, etc. Assembly Language Symbolic form of machine language. Low-level programming language What the hardware understands What we want to use How do we make the transition? Source codeBinary code 8/26/2013CS181 - INTRO TO CS - HONORS I 21

22 Compilers and Interpreters Compilers “A compiler is a program that translates a program written in a high-level language, such as Java, into a program in a simpler language that the computer can more or less directly understand.” ◦Compile once, execute often ◦Program only runs on the particular architecture it was compiled for Interpreter “An interpreter is a program that alternates the translation and execution of statements in a program written in a high-level language.” ◦Program is re-translated every time it is run ◦It can run on any system with a working interpreter 8/26/2013CS181 - INTRO TO CS - HONORS I 22

23 Compiling Java Programs The Java compiler does not translate your program to machine language It translates it to a lower-level language called bytecode What is bytecode? “Bytecode is the machine language for a hypothetical computer known as a virtual machine.” The machine that understands bytecode is the Java Virtual Machine (JVM) ◦Essentially an interpreter for bytecode Java programs can run in any computer with a JVM The JVM needs to be ported to new architectures ◦The JVM is simpler than the compiler ◦Need to only write the compiler once 8/26/2013CS181 - INTRO TO CS - HONORS I 23

24 Compiling and Running a Java Program Java program Data for program Java compiler Bytecode program JVM Machine- language instructions Execution Program output Syntax errors Run-time errors 8/26/2013CS181 - INTRO TO CS - HONORS I 24

25 Summary Computer systems are comprised of software and hardware ◦Hardware is the physical machine ◦Software refers to all programs on system, including any applications and the operating system Programs and data are all stored in random access memory The smallest piece of information addressable in memory is a byte Each CPU can execute machine-language instructions written in its language Data need to be frequently moved to CPU registers before operating on them ◦Always on CISC architectures Compilers are the programs that transform higher-level language programs to lower-level and, eventually, machine instructions The Java compiler generates bytecode which is understood and executed by the JVM 8/26/2013CS181 - INTRO TO CS - HONORS I 25


Download ppt "Intro to CS – Honors I Introduction GEORGIOS PORTOKALIDIS"

Similar presentations


Ads by Google