living on zoom living on zoom

Living on Zoom Living on Zoom CS 105 Tour of the Black Holes of - PowerPoint PPT Presentation

Living on Zoom Living on Zoom CS 105 Tour of the Black Holes of Computing! Were getting to be old hands at thisnot? I try to keep the


  1. ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Living on Zoom Living on Zoom CS 105 “Tour of the Black Holes of Computing!” We’re getting to be old hands at this…not? I try to keep the sessions as free as possible Computer Systems Computer Systems No waiting rooms so you can join early and talk to each other Introduction Introduction PowerPoint and PDF versions of slides will be pre-posted Use them to take notes if you wish Geoff Kuenning See calendar page on class site: https://www.cs.hmc.edu/~geoff/cs105 Fall 2020 Remind me at beginning of class if I forget (sometimes I do) Please be visible and interactive! Topics: Sign in with your actual name Class Introduction Zoom discourages questions and chatting � Please fight that tendency Data Representation � Avoid all those tempting distractions Seeing you helps me teach better � I know some of you have bandwidth problems, but… CS 105 CS 105 – 1 – – 2 – Course Theme Course Theme Textbooks Textbooks Abstraction is good, but don’t forget reality! Randal E. Bryant and David R. O’Hallaron, “Computer Systems: A Programmer’s Perspective”, 3 rd Edition, Prentice Hall, 2015. Many CS Courses emphasize abstraction Abstract data types Brian Kernighan and Dennis Ritchie, Asymptotic analysis “The C Programming Language, Second Edition”, Prentice Hall, 1988 These abstractions have limits Larry Miller and Alex Quilici Especially in the presence of bugs The Joy of C, Wiley, 1997 Need to understand underlying implementations Useful outcomes Become more effective programmers � Able to find and eliminate bugs efficiently � Able to tune program performance Prepare for later “systems” classes in CS � Compilers, Operating Systems, File Systems, Computer Architecture, Robotics, etc. CS 105 CS 105 – 3 – – 4 –

  2. ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Syllabus Syllabus Notes: Notes: Work groups You must work in pairs on all labs Syllabus on Web: https://www.cs.hmc.edu/~geoff/cs105 Honor-code violation to work without your partner! Calendar defines due dates Corollary: showing up late doesn’t harm only you � Also has links to slides and labs Labs: cs105submit for some, others have specific directions Handins Check calendar for due dates Electronic submissions only Grading Characteristics Lab scores tend to be high � Serious handicap if you don’t hand a lab in Tests & quizzes typically have a wider range of scores � I.e., they’re have major effect on your grade » …but not the ONLY one Do your share of lab work and reading, or bomb tests Do practice problems in book CS 105 CS 105 – 5 – – 6 – CS 105 Facilities Facilities “Tour of the Black Holes of Computing” Bits, Bytes, Integers Bits, Bytes, Integers Assignments will use Intel computer systems � Not all machines are created alike � Performance varies (and matters sometimes in 105) Topics � Security settings vary and can matter Representing information as bits � Wilkes: x86/Linux specifically set up for this class Bit-level manipulations � Log in on a Mac, then ssh to Wilkes Integers � If you want fancy programs, start X11 first � Representation, unsigned and signed � Directories are cross-mounted, so you can edit on Knuth or your Mac, and � Conversion, Casting Wilkes will see your files � Expanding, truncating � …or ssh into Wilkes from wherever you are � Addition, negation, multiplication, shifting � All programs must run on Wilkes: we grade there Representations in memory, pointers, strings � Have lecture slides (and textbook) available when working on labs! CS 105 – 7 – CS 105

  3. ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Everything is bits Everything is bits Encoding Byte Values Encoding Byte Values Each bit is 0 or 1 Byte = 8 bits Binary 00000000 2 to 11111111 2 By encoding/interpreting sets of bits in various ways 0 0 0000 Decimal: 0 10 to 255 10 1 1 0001 Computers determine what to do (instructions) 2 2 0010 Hexadecimal 00 16 to FF 16 3 3 0011 … and represent and manipulate numbers, sets, strings, etc… � Base 16 number representation 4 4 0100 5 5 0101 � Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’ Why bits? Electronic implementation 6 6 0110 � Write FA1D37B 16 in C as 7 7 0111 Easy to store with bistable elements 8 8 1000 » 0xFA1D37B Reliably transmitted on noisy and inaccurate wires 9 9 1001 » 0xfa1d37b A 10 1010 B 11 1011 0 1 0 C 12 1100 D 13 1101 1.1V E 14 1110 0.9V F 15 1111 0.2V 0.0V CS 105 CS 105 – 9 – – 10 – Example Data Sizes Example Data Sizes Boolean Algebra Boolean Algebra Developed by George Boole in 19th century ����������� �������������� �������������� ������ Algebraic representation of logic � Encode “True” as 1 and “False” as 0 char � � � ��� �� short � � � ����������������������������� ������������������������������ int A B A&B A B A|B � � � 0 0 0 0 0 0 long � � � 0 1 0 0 1 1 float 1 0 0 1 0 1 � � � 1 1 1 1 1 1 double � � � ��� ������������������ long double � � ����� ��������������� �������������������������������������������� A ~A A B A^B ������� � � � 0 1 0 0 0 1 0 0 1 1 1 0 1 CS 105 CS 105 – 11 – – 12 – 1 1 0

  4. ✁ ✁ ✁ ✁ � ✁ ✁ ✁ ✁ ✁ ✁ ✁ � ✁ ✁ � ✁ ✁ � � ✁ ✁ � � � � � ✁ ✁ ✁ ✁ General Boolean Algebras General Boolean Algebras Example: Representing & Manipulating Sets Example: Representing & Manipulating Sets Operate on bit vectors Representation Operations applied bitwise Width w bit vector represents subsets of {0, …, w–1} a j = 1 if j � A 01101001 01101001 01101001 & 01010101 | 01010101 ^ 01010101 ~ 01010101 � 01101001 { 0, 3, 5, 6 } 01000001 01111101 00111100 10101010 01000001 01111101 00111100 10101010 � 76543210 � 01010101 { 0, 2, 4, 6 } All of the properties of Boolean algebra apply � 76543210 Operations & Intersection 01000001 { 0, 6 } | Union 01111101 { 0, 2, 3, 4, 5, 6 } ^ Symmetric difference 00111100 { 2, 3, 4, 5 } ~ Complement 10101010 { 1, 3, 5, 7 } CS 105 CS 105 – 13 – – 14 – Bit-Level Operations in C Bit-Level Operations in C Contrast: Logic Operations in C Contrast: Logic Operations in C Operations � , � , � , � available in C Contrast to Logical Operators Apply to any “integral” data type ��������� � View 0 as “False” � �������������������������������� � Anything nonzero seen as “True” View arguments as bit vectors � Always return 0 or 1 Operations applied bit-wise � Early termination Examples (char data type) Examples (char data type) ������ → → ���� → → ������ → → → → ���� → �������� → → → � ��������� ������ → → → → ���� ������ → → → ���� → ������� → → → ���� → → �������� → → → � ��������� ������������ → → ���� → → ������������� → → → → ���� → �������� → → → � �������� ���������� ������������� → → ���� → → ������������ → → ���� → → ������������� (unreadably avoids null pointer access) → → → → �������� � �������� ���������� CS 105 CS 105 – 15 – – 16 –

Recommend


More recommend