CSE 3430 Overview of Computer Systems For NonMajors

  • Slides: 23
Download presentation
CSE 3430 Overview of Computer Systems For Non-Majors Neelam Soundarajan Computer Sc. & Eng.

CSE 3430 Overview of Computer Systems For Non-Majors Neelam Soundarajan Computer Sc. & Eng. Dreese Labs 579 e-mail: neelam@cse

***Important Note*** n n n This course is NOT intended for BS-CSE and BS-CIS

***Important Note*** n n n This course is NOT intended for BS-CSE and BS-CIS majors. If you are a BS-CSE or BS-CIS major or pre-major, drop the course and take CSE 2421, followed by CSE 2431. You will NOT be able to use CSE 3430 as part of your major program. This course is meant for students pursuing a Computer Science minor, for Data Analytics majors, and possibly others. CSE 3430; Part 1 2

Goals of the Course n n n 1. Discuss key “machine-level” ideas, i. e.

Goals of the Course n n n 1. Discuss key “machine-level” ideas, i. e. , how computers are organized internally and how they function 2. Develop a feel for “low-level” programming using C 3. Discuss some key ideas and concepts underlying operating systems that serve as an interface between the (application) programmer and the computer (Operating systems are implemented mostly in C) CSE 3430; Part 1 3

Background and Course Materials n n n 1. This is a brand new course

Background and Course Materials n n n 1. This is a brand new course and very much a work-in-progress 2. There are many books on computer architecture and on operating systems but they are much too detailed 3. Useful references: n n Hamacher, Vranesic, Zaky, Computer Organization (5 th ed ok) Mc. Cabe, Computer Systems (kind of old but I like it) Stallings, Operating Systems (6 th or 7 th ed ok) 4. Important: *Don’t* miss classes! CSE 3430; Part 1 4

Course Materials Notes: n *You* are responsible for creating your own class notes n

Course Materials Notes: n *You* are responsible for creating your own class notes n n The slides will usually just list the bullet points to guide class discussion. You have to create your own detailed notes based on the class discussion What we say in class overrides what you may find online; so when you do your homework assignments and answer questions in the exams etc. , they should be based mainly on the class discussion, not what you may have seen elsewhere CSE 3430; Part 1 5

Topics and *Tentative*Schedule n Computer architecture (6 weeks? ) n (Low-level) programming in C

Topics and *Tentative*Schedule n Computer architecture (6 weeks? ) n (Low-level) programming in C (2? 3? weeks) n Operating systems (5 weeks? ) n Exams/review (1 week) CSE 3430; Part 1 6

Main components of a computer n Memory n n Processor n n Arithmetic/logic circuits

Main components of a computer n Memory n n Processor n n Arithmetic/logic circuits Timing/control circuits Registers, and cache memory Input n n Main memory Secondary memory (disks, flash memory etc. ) Cache memory Keyboard, mouse, touchpad, cameras, … Output units n printers, speakers, … CSE 3430; Part 1 7

Main components of a computer Internet?

Main components of a computer Internet?

Fundamental Concept #1 n Smallest unit of memory: Bit (binary digit) n n Computer’s

Fundamental Concept #1 n Smallest unit of memory: Bit (binary digit) n n Computer’s memory: Collection of a huge number of bits n n n A bit may be 0 or 1 There are hardware devices that can store a bit (these devices are also called bits) You can write a new value (only 0 or 1!) into a bit or read the value currently stored in the bit An ordered sequence of bits: a bit string (or string of bits) *Everything* in the computer is stored as a bit string That is everything; NO exceptions! Names, numbers, songs, pictures, emojis, everything! Even programs! *Everything* in the computer is stored as a bit string! CSE 3430; Part 1 9

But … how? n n By encoding everything as a bit string … A

But … how? n n By encoding everything as a bit string … A bit string with a single bit can encode two possible values: Represent the state of a light bulb on (1) or off (0); or whether a particular student passed (1) or failed (0) the first midterm; or anything else that has exactly two possible values. A bit string with two bits can encode four possible values (00, 01, 10, 11) Represent state of two bulbs in room (off, off / off, on/ on, off/ on, on); or whether a particular student failed/passed each of two midterms; or whether two students failed/passed the first midterm; or anything else that has exactly four possible values. *Major Problem*: Does “ 01” represent a particular student’s fail/pass in two midterms? or fail/pass of two students in the first midterm … or even whether the two light bulbs are off, on respectively? Answer: There is no way to tell! We just have to know! … but we will see more on this later CSE 3430; Part 1 10

Storing Information … n n n Memory is organized into a sequence of words

Storing Information … n n n Memory is organized into a sequence of words where a word typically is a string of 32 bits (but could be 8, 16, 32, …) Often we talk of bytes where a “byte” is (always) a string of 8 bits; Thus a word (typically) consists of 4 bytes How do we represent a number? n n n First, why does, say, “ 265” denote two-hundred-and-sixty-five? Because we are using the positional notation; so the “ 5”, because it is in the “units” position, denotes 5; the “ 6”, in the “tens” position, denotes *60*; the “ 2”, in the “hundreds” position, denotes 200; giving us a total of two-hundred-and-sixty-five We apply the same idea to binary numbers; i. e. , in a “binary number”, say, 11001, the rightmost digit is in the units position; the digit to its left is in the 2 1 position; the digit to its left is in the 22 position; the next one on the left is in the 23 position; etc. So “ 11001” denotes 1*20 + 0*21 + 0*22 + 1*23 + 1*24, i. e. , 25 What does “ 1001” denote? What does “ 1201” denote? What is the largest number we can denote with 5 bits? Smallest? CSE 3430; Part 1 11

Storing Information (contd. ) n n What if we want to denote a number

Storing Information (contd. ) n n What if we want to denote a number that is bigger than 31? … use more bits! What is the largest number we can store in a word of memory? 111… 11 (a string of 32 bits, each being 1) n What value does it denote? n But what if we want still larger numbers? n What if we want to also deal with negative numbers? n n Natural approach: Use the first bit as the “sign bit” and the remaining bits for the value. So “ 0101” denotes +5 and “ 1101” denotes -5 How do we perform addition of two numbers? Subtraction? CSE 3430; Part 1 12

2’s complement: A different approach n n Suppose our word size is 3 bits.

2’s complement: A different approach n n Suppose our word size is 3 bits. So 8 possible combinations We want to have: n Roughly equal number of positive and negative nos. n Have as many numbers as possible n Easy comparison for equality of numbers And for positive/negative So 000, 001, 010, 011 should be positive; 100, …, 111 negative Q: Which negative nos. should each of 100, …, 111 represent? CSE 3430; Part 1 13

2’s complement (contd) n n n What happens if you subtract 1 from 000?

2’s complement (contd) n n n What happens if you subtract 1 from 000? So 111 should be – 1; similarly, 110 should be – 2; 101 should be – 3 And 100 should be – 4 In effect, we can see what –k should be by subtracting k from 0; or, rather, from 2^3 Turns out to be equivalent to finding 1’s complement and adding 1; why? n n 1’s complement is equivalent to subtracting from 111 so do that then add 1 to be equivalent to subtracting from 2^3 CSE 3430; Part 1 14

Advantages of 2’s complement n Arithmetic is easy and uniform for positive and negative

Advantages of 2’s complement n Arithmetic is easy and uniform for positive and negative nos. n Testing for equality or for positive/negative are easy n n Going from 3 -bit to 4 -bit is easy: just extend the sign bit; works for any no. of bits: this is important because we often want to change the no. of bits used for storing some info Almost all computers use 2’s complement representation because of these advantages CSE 3430; Part 1 16

Storing Information (contd. ) n CSE 3430; Part 1 17

Storing Information (contd. ) n CSE 3430; Part 1 17

Error Detection/correction n Information stored in the computer usually remains unchanged … but n

Error Detection/correction n Information stored in the computer usually remains unchanged … but n During transmission, errors can creep in. n n Simple error detection method: parity; for ASCII, use eight bits instead of 7 (the value of 8 th bit being chosen to get even number of 1’s) An error detection/correction scheme: (VPB: Vertical parity bit; HPB: horizontal parity bit; top right: “corner bit” H el l o , w o r l d HPB VPB 0 0 0 1 1 bit 6 1 1 1 0 0 1 1 1 0 bit 5 0 1 1 1 bit 4 0 0 0 0 1 0 0 0 bit 3 1 0 1 1 0 0 1 0 1 bit 2 0 1 1 1 bit 1 0 0 1 1 1 0 0 0 bit 0 0 1 1 0 0 CSE 3430; Part 1 18

Storing Information (contd. ) n n n What about other values? Say, I want

Storing Information (contd. ) n n n What about other values? Say, I want to store the grades that a given student obtains in all the homeworks, exams, etc. ? Just use the appropriate number of words or bytes: Let us say there are ten graded activities each worth a max of 100 pts We could store each of these in a single byte (why? ) but it is more common to use a whole word; And use two words to store the name of the student (why? ) for a total of 12 words What if I want to store the grades of all the students in the class? Just use N * 12 words (if there are N students in the class) *But*: If I look at the actual contents of these words in memory, it will just be a sequence of 0’s and 1’s! I have to know what each byte represents For example, suppose I thought there were 12 (instead of 10) graded activities, what will happen? CSE 3430; Part 1 19

Storing Information (contd. ) n n n What about other values? Say a song

Storing Information (contd. ) n n n What about other values? Say a song that you downloaded (legally: -)? or a photo? or video? For each type of data, standard coding schemes have been defined so that each such “value” can be stored as a (looo…ng!) sequence of bits In each case, if you don’t know the coding scheme, there is no way for you to know what song or photo or video a given string of bits is … n In fact, you can’t even be sure whether it is a song or a photo or video n … or the grade roster of a course! n Essential point: Everything in the computer is stored as bit strings. You have to know which value is stored where in memory and what the coding scheme used to store that value is. CSE 3430; Part 1 20

Memory Structure n Memory consists of a huge number of bytes (of 8 bits

Memory Structure n Memory consists of a huge number of bytes (of 8 bits each) n Each byte in memory has a unique address n If the memory has 10 bytes, their addresses will be 0, 1, 2, …, 9 n n … represented as bit strings (0000, 0001, 0010, …, 0111, 1001, 1010) … because everything is represented as a bit string! In a typical machine, the address is represented as a 32 -bit string (or 8 hexadecimal digits) n So we can have a maximum of 4, 294, 967, 296 bytes (why? ) n Numbers are usually stored in words of 4 bytes each CSE 3430; Part 1 21

8 bits byte

8 bits byte

In big-endian, the address of the word is that of most significant byte In

In big-endian, the address of the word is that of most significant byte In little-endian, the address of the word is that of least significant byte In most machines, words have aligned addresses; so bytes at addresses 2, 3, 4, 5 do not constitute a legal word though they do form a string of four bytes