computer architecture and operating systems · cosc 243 (computer architecture) lecture 1 -...

39
COSC 243 Computer Architecture And Operating Systems COSC 243 (Computer Architecture) Lecture 1 - Introduction and Data Representation 1 1

Upload: others

Post on 04-Apr-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

COSC 243

Computer Architecture And

Operating Systems

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

1

Instructors & Support People• Dr. Andrew Trotman

– Office: 123A, Owheo– Email: [email protected]

• Dr. Zhiyi Huang (course coordinator)– Office: 126, Owheo– Email: [email protected]

• Tutors:– Raymond Scurr– Kieran Elmes

• Department Kaiāwhina (Māori and Pacific Support):– Steven Mills (Office: 245, Owheo)

• Department Disability Support– Contact the main office.

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

2

Learning Outcomes• Understand how a computer system is organized• Understand data representation and computing logic• Be familiar with computer architectures and

instruction sets• Understand how an operating system is structured

and works• Understand fundamental concepts and principles of

operating systems• Be familiar with basic OS algorithms like process

scheduling algorithms and resource allocation algorithms

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

3

Textbooks• Textbook for architecture (Recommended)

– Stallings, W., Computer Organization and Architecture (10th

edition), Prentice Hall 2016 (Recommended).

• Textbook for operating systems (Required)– Silberschatz, A., Galvin, P., Gagne, G., Operating System

Concepts with Java (8th edition), Addison-Wesley 2009 (Encouraged).

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

4

On Reserve in Library• Greeg, J.R., Ones and Zeros - Understanding

Boolean Algebra, Digital Circuits, and the Logic of Sets, IEEE Press 1998

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

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”

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

6

Class Details (cont)• Linux Introduction

– If not doing COSC 241, go to a 241 lab this week• 18 point paper

– “As a guide, based on an 18-point paper, this usually works out to a minimum of 14 hours work per paper per week. Work is made up of formal contact time (lectures, tutorials, laboratories, etc) and independent study (studying, revision, assignments, reading, etc).” https://www.otago.ac.nz/study/planning/workload.html

– 6 contact hours/week * 13 weeks = 78 hours of 180 total– How many non-contact hours should you put in at home?

• Check email regularly• Lecture notes are online (normally on Monday)

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

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%

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

8

Academic Integrity and Academic Misconduct

• Academic integrity means being honest in your studying and assessments. It is the basis for ethical decision-making and behaviour in an academic context. Academic integrity is informed by the values of honesty, trust, responsibility, fairness, respect and courage. Students are expected to be aware of, and act in accordance with, the University’s Academic Integrity Policy.

• Academic Misconduct, such as plagiarism or cheating, is a breach of Academic Integrity and is taken very seriously by the University. Types of misconduct include plagiarism, copying, unauthorised collaboration, taking unauthorised material into a test or exam, impersonation, and assisting someone else’s misconduct. A more extensive list of the types of academic misconduct and associated processes and penalties is available in the University’s Student Academic Misconduct Procedures.

COSC 243 (Architecture) Lecture 1 - Introduction and Data Representation 1 9

Academic Integrity and Academic Misconduct

• It is your responsibility to be aware of and use acceptable academic practices when completing your assessments. To access the information in the Academic Integrity Policy and learn more, please visit the University’s Academic Integrity website at www.otago.ac.nz/study/academicintegrity or ask at the Student Learning Centre or Library. If you have any questions, ask your lecturer.

• Academic Integrity Policy www.otago.ac.nz/administration/policies/otago116838.html

• Student Academic Misconduct Procedures http://www.otago.ac.nz/administration/policies/otago116850.html

COSC 243 (Architecture) Lecture 1 - Introduction and Data Representation 1 10

What is Computer Architecture?

• The study of computer hardware• We often ignore architecture when doing high-level

programming (in Java, C, etc.)• 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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

11

Desktop Computing Minority

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

12

https://www.macrumors.com/2020/01/28/apple-1q-2020-results/

Desktop Computing Minority

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

13

https://www.macrumors.com/2020/01/28/apple-1q-2020-results/

What is a Computer

?COSC 243 (Architecture) Lecture 1 - Introduction and

Data Representation 114

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

15

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

16

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

17

What is Data (cont)?• But, values are abstract, they are interpretations of data

– Examples: February. 56. Blue

• The same value may be represented (written or stored) in many ways. For example:

12 twelve XII 1100• ••• - - - - • • - - -

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

18

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)

– in some chips its a fuse that is “open” or “blown”• An instance of a state is called a bit (binary digit)

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

19

or

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?

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

20

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

21

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 locationsCOSC 243 (Computer Architecture) Lecture 1 - Introduction and

Data Representation 122

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 nybbles)

• 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).

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

23

Obsolete and Unusual Units(For Amusement Only)

https://en.wikipedia.org/wiki/Units_of_information

• 1 bit: sniff• 2 bits: crumb, taste, tayste, tidbit, tydbit, lick, lyck• 3 bits: tribble• 5 bits: nickel, nyckle• 10 bits: deckle, dyme• 12 bits: slab• 16 bits: wyde, parcel, plate, playte• 32 bits: dinner, dynner, gawble• 96 bits: bentobox (in ITRON OS)• 16 bytes: paragraph (you might see this)

COSC 243 (Architecture) Lecture 1 - Introduction and Data Representation 1 24

Bits, Nybbles, Bytes

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

25

1 bit = 1 switch

1 nybble = 4 switches

1 byte = 8 switches

Computer memory is a switchbox

123

07 6 5 4 3 2 1 0

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

26

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

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

27

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.

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

28

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.

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

29

ASCII Character Code0001000000101000010001001000001010000010111111101000001010000010

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

30

00010000 01000100 10000010 11111110 10000010 1000001000101000 10000010

xx x

x xx xx xxxxxxxxx xx 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

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 remaining ASCII codes are non-printing and have other meaning (such as line feed, form feed, tab, etc.).

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

31

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

32

ASCII Character Code (cont)

ASCII Character Code (cont)• ASCII characters are represented by a 7-bit code.

• There are, therefore, 128 (27) possible characters. They are usually stored in memory as a byte with the 8th bit (the high 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’!

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

33

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

34

Other Character CodesEBCDIC Extended Binary Coded Decimal Interchange

Code. Used with large (old) IBM computers.

BAUDOT An old paper tape code

BCD Binary coded decimal.6-bits + check bit.Used on some magnetic tapes.

80 column 12-bit code used on punch-cards.

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 143,859 characters from 154 scripts– Some (many) are reserved

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

35

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

36

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.

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

37

Unicode (cont)• Version 13.0.0 (due 10/3/2020) includes new

characters for: Yezidi, Chorasmian, Dives Akuru, some script additions, 55 new emoji

• Now a 21-bit code (1,114,111 allowable codepoints) with 143,859 characters from 154 scripts• Some (codepoints) are reserved

• Handles composite characters such as those with accent marks, dots, double dots, etc.

Unicode (cont)

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

38http://www.unicode.org/charts/PDF/U11D00.pdf

Character Strings• Homework….

– How are character strings (e.g. “hello world”) stored in a computer?

COSC 243 (Computer Architecture) Lecture 1 - Introduction andData Representation 1

39