COSC 243 Computer Architecture And Operating Systems 1
Dr. Andrew Trotman Instructors Office: 123A, Owheo Phone: 479-7842 Email: andrew@cs.otago.ac.nz Dr. Zhiyi Huang (course coordinator) Office: 126, Owheo Phone: 479-5680 Email: hzy@cs.otago.ac.nz Tutors: Raymond Scurr Reuben Crimp Toby Heitland 2
Course Goals Understand the fundamentals of computer hardware and architecture Understand the fundamentals of operating systems 3
Textbooks Textbook for architecture (Recommended) Stallings, W., Computer Organization and Architecture (8 th or 10th edition), Prentice Hall 2009 (Recommended). Textbook for operating systems (Required) Silberschatz, A., Galvin, P., Gagne, G., Operating System Concepts with Java (8th edition), Addison-Wesley 2009 (Essential). 4
On Reserve in Library Greeg, J.R., Ones and Zeros - Understanding Boolean Algebra, Digital Circuits, and the Logic of Sets, IEEE Press 1998 5
Class Details Two tutorials per week An integral part of the course Internal assessment marks for active participation Home page for the course http://www.cs.otago.ac.nz/cosc243 Lecture notes Tutorial sheets Other resources Consultation times Just drop in 6
Class Details (cont) Linux Introduction If not doing COSC 241, go to a 241 lab this week 18 point paper Means 180 hours of work during 13 weeks 6 contact hours/week * 13 weeks = 78 hours How many non-contact hours are you supposed to put in (at home)? Check email regularly It may contain important notices Lecture notes are online Each week s notes will (normally) be put online on Monday 7
Assessment Internal Assessment Computer architecture: 10% test on data representation in tutorial time (week 3) Sample test is (already) online Operating systems: 10% tutorial time test (in week ~10) Active participation in tutorials - 10% Exam - 70% 8
What is Computer Architecture? The study of the computer hardware We often ignore architecture when doing high-level programming (Java, C) Why study computer architecture? We must know architecture for: Assembly language programming Writing system software such as device drivers To understand what our programs mean 9
Desktop Computing Minority https://www.macrumors.com/2018/02/01/apple-q1-2018-results/ 10
Outline for Computer Architecture Data representation Introduction to digital logic Combinatorial & sequential logic design Overview of a computer and CPU Instruction sets and addressing modes Assembly language programming Primary and secondary storage Control unit and microprogramming More computer architecture Input-Output 11
Overview of Data Representation What is data? Bits, bytes, words Characters Integers Positional notation Binary, octal, hexdecimal notation Conversions between binary, octal, hex, decimal Representation of negative numbers Binary addition and subtraction Representation of real numbers 12
What is Data? Data a fact (information) Data corresponds to discrete facts about phenomena from which we gain information about the world The concept of value is fundamental to data Example values: 25, $256.50, April, This is a sentence, colours and composition in images, tones in music 13
What is Data (cont)? But, values are abstract, they are the interpretations Examples: February. 56. Blue The same value may be represented (written or stored) in many ways. For example: 12 twelve XII 1100 - - - - - - - 14
How is Data Represented In a Computer? The digital computer is binary Everything is stored in one of two states: true, or false which can be thought of as 1 and 0 or a switch which is on or off (voltage, no voltage) or in some chips its a fuse that is OK or blown An instance of a state is called a bit (binary digit) 15
How is Data Represented In a Computer? Values are represented as sequences bits: 1000001 What does this particular sequence mean? How does the computer know what any particular sequence of bits means? 16
How is Data Represented in a Computer? It depends on how you interpret it: 65 (in decimal) A (in ASCII) Or anything else you want it to mean! The computer doesn t know you know 17
Computer Memory The data currently being worked on is (normally) stored in the computer's memory Memory is just like the switchboard in your home, each switch has a number. They re all there all the time and each has a state (on or off). You change the state by flipping the switch. In the computer each data item has: an address or location (the switch number) a value (the state) In high level languages we name some of the locations 18
Bits, Nybbles, Bytes The smallest unit of storage is the bit (1 or 0) For convenience bits are grouped together into larger units. A nybble (nibble, or nyble) is 4 consecutive bits. Its just like a box drawn on the switchboard A byte is 8 consecutive bits (2 nybles) For convenience it is bytes that are given addresses in the (modern) computer (bits and nybbles are too small to work with most of the time). 19
Bits, Nybbles, Bytes 1 bit = 1 switch 1 nybble = 4 switches 1 byte = 8 switches 7 6 5 4 3 2 1 0 0 1 2 3 Computer memory is a switchbox 20
A Word of Memory The word is the number of bits the CPU uses internally. It varies from manufacturer to manufacturer and from CPU to CPU. These days it is usually 32 or 64 bits. Bits Computer 8 Atari 800, Commodore 64, Apple ][ 16 IBM PC XT, Macintosh, DEC VAX 18 DEC PDP 15 32 IBM 370, early Android and ios phones 36 Honeywell, UNIVAC 64 Cray-1, imac, PC, and modern smartphones 21
Characters A character is a written symbol. They are (for English) represented as a single byte. In other languages they can be represented as 2 bytes (or more). Characters include: UPPER CASE LETTERS A C X... lower case letters b g k... Single digits 3 1 9... Special characters! < =... We can join these together in sequences to make (human readable) numbers and words 22
Characters char ch; ch is the variable name (an identifier). It is used to label a particular part of the computer's memory where a byte value is stored. The byte is a sequence of 8 bits, an 8-bit integer [0..255]. During compilation, the name is assigned an address in the computer s memory. That is the location where the data is stored. The meaning of that data depends on how a human interprets it. It might be a small integer, or a character, or a colour, etc. 23
ASCII Character Code How does the computer know that ch is an 'A' and not 'a' or '3' or anything else? It doesn t! 1.The computer uses ch as an integer index into a pre-existing table, e.g. 0001000000101000010001001000001010000010111111101000001010000010 Or, for clarity, an array of bytes like this: unsigned char bits[65] = {16, 40, 68, 130, 130, 254, 130, 130} 2. The computer screen is made up of thousands of little dots called pixels. They are in a rectangular grid, like a table. 24
ASCII Character Code 0001000000101000010001001000001010000010111111101000001010000010 00010000 00101000 01000100 10000010 10000010 11111110 10000010 10000010 x x x x x x x x x xxxxxxx x x x x When the computer is asked to print a character it turns on and off some of those pixels. We then interpret the drawing. We have imposed meaning: We have given it a value 25
ASCII Character Code There are several standard tables that describe what to draw, and fonts that describe how to draw them. ASCII (the American Standard Code for Information Interchange) describes what should be drawn for Roman (English-like) alphabets. For example: A 1000001 (65) a 1100001 (97) 9 0111001 (57) But there are only a few letters, numbers, and punctuation marks. The remanning ASCII codes are non-printing and have other meaning (such as line feed, form feed, tab, etc.). 26
ASCII Character Code (cont) 27
ASCII Character Code (cont) ASCII characters are represented by a 7-bit code. There are, therefore, 128 (2 7 ) possible characters. They are usually stored in memory as a byte with the 8 th bit set to 0. For sorting purposes characters are compared on their numeric value (called the collating sequence). A is before Z but a is after Z! 28
Other Character Codes EBCDIC BAUDOT BCD Extended Binary Coded Decimal Interchange Code. Used with large (old) IBM computers. An old paper tape code Binary coded decimal. 6-bits + check bit. Used on some magnetic tapes. 80 column 12-bit code used on punch-cards. 29
Unicode What about all the non-roman characters? Greek, Arabic, Chinese, Hebrew, Japanese, Thai, etc. Astrology symbols etc. What about characters that represent ideas, concepts, phrases? Emoji, etc. Unicode Developed by The Unicode Consortium Coordinated with ISO/IEC 10646 Originally a 16-bit code (compatible with ASCII) Mapped 16-bit values into glyphs (characters) 65,536 characters were possible Now a 21-bit code with 136,690 characters from 139 scripts Some (many) are reserved 30
Unicode (cont) Defines codes for characters used in the major languages written today. Codes include Latin, Greek, Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Thai, Lao, Georgian, Tibetan, Japanese Kana, The complete set of modern Korean Hangal, and a unified set of Chinese / Japanese / Korean (CJK) ideographs. 31
Unicode (cont) Version 10.0.0 (most recent) includes new characters for: Masaram Gondi, Nushu, Soyombo, Zanabazar Square, Bitcoin, and others. Now a 21-bit code (1,114,111 allowable codepoints) with 136,690 characters from 139 scripts Some (codepoints) are reserved Can handle composite characters such as those with accent marks, dots, double dots,... 32
Unicode (cont) http://www.unicode.org/charts/pdf/u11d00.pdf 33
Character Strings Homework. How are character strings (e.g. hello world ) stored in a computer? 34