Fundamentals of Computer Science, 2nd part

Post on 12-Sep-2021

6 views 0 download

transcript

Lecture 01 1

Fundamentals of Computer Science, 2nd part

Lecture 10review

Lecture 01 2

Module Aim (SYLLABUS PAGE):

• …

• Introduce the main hardware components of a computer and their function.

• Explain the role of an operating system and system software.

• …

Lecture 01 3

A high level view of topics(not in order):

• Computer Architecture• I/O devices and network• Digital Logic• Microarchitecture• Machine Code• Operating Systems• Compilers and interpreters • ….

Lecture 01 4

Multilevel machines

Digital logic

Assembly

Operating System

ISA

Microarchitecture

problem oriented lang.

Hardware

Interpretation

Interpretation

translation(assembler)

translation(compiler)

Human friendly

Lecture 01 5

A Simple 1 CPU computer

control unit

ALU

Registers

main memory I/O device: printer, Disk

Bus

Bus: parallel wires for transmitting data, address and control signals

CPU

Lecture 01 6

Main Memory (continue)

• All cells in the memory the same numbers of bits

• addresses also are in binary

3 ways of organising a 96-bits memory

Lecture 01 7

Idea behind caching

• heavily used memory should be kept in the cache

• When CPU needs a word, it first looks at the cache. ONLY if the word is not there goes to the main memory

Lecture 01 8

Logical Architecture, a 2nd look

and various other devices mouse, printer, camera,….

Lecture 01 9

Gates

• Digital Logic layer is made of GatesCreating 0,1

� 0 denotes voltage between 0 ,1

� 1 denotes voltage between 2 and 5

� voltage outside not permitted

Gates are electronic devices that compute various functions of two-valued signals

Function?

� mapping INPUT to OUTPUT

Lecture 01 10

examples of gates

input output

What do tables resemble? NOT for negation (inverter), AND for conjunction, OR for disjunction, NAND output 0 iff both input 1, NOR …

Lecture 01 11

Example of Arithmetic circuit

011

101

110

000

XORBA

Lecture 01 12

Memory circuitidea: remember previous value

Solution: the output independent of the input

Example: SR latches

Lecture 01 13

Adder

INPUT via bus 1, 2 OUTPUT via bus 3

Lecture 01 14

Instruction Set Architecture (ISA)• Historically, the first (only) layer

• ISA is the interface between the software and hardware (language that both of have to understand)

Lecture 01 15

ISA level contains the following views of the hardwre:

• Memory model: 8bits cells (bytes)

• Registers:visible at the ISA level, control execution of program, hold temporary results, …

• Instructions: to control what machine does.LOAD, STORE for moving data between register and

memory,…MOVE copy data among the registersArithmetic and Boolean structures

Lecture 01 16

Language translators

Low-level languagesAssembly: each instruction directly translates into

machine code instruction Example: ADD 234 (notice it is not storing anything)High-levelFortran, C, C++, JAVA,…:One instruction corresponds to several machine code

instructions Translate from a high-level language into the machine

language (low-level)� Interpreter� Compiler

Lecture 01 17

Interpretation & Compilation

Interpretation:

translate and execute a high level program statement-by-statement, execution of each statement preceding the translation of the next.

Compilation:

separate translation and execution. First translate all the program then execute.

Notice: if a program statements executes 10 times, it must be translated 10 times by the interpreter.

Lecture 01 18

How to express syntax?

The basic idea is to explain how syntactic categories are formed. This is done by specifying production rules, each of which defines how a particular syntactic category be made from

• terminal symbols

• members of other nonterminal symbols

Lecture 01 19

Example of BNF:

��������������� � ����������������� ������

��� � ������� � � � � ��� � ������������������� ���������

��������� ���� ���� ���� �� ��� � ����������� ����������

��� ��������������������� ������������� ������� ��

������� �����������������������

����������������

��� � ��������������� ����������

����� ���������≠≠≠≠

Lecture 01 20

Compiler

Lexical Analysis

Syntax Analysis

Code Generation

Compiler

source program

object program

Optimization

Lecture 01 21

translation to tokens

�� X ≠ 1 �������X ��X –Y

the lexical analyser translate to tokens:

�� name(X) ≠ num(1) ���� ���

name(X) �� name(X) – name(Y)

TokenType Value

Lecture 01 22

parse tree �� name(X)≠ num(1) �������name(X) �� name(X) – num(1)

conditional

�� condition ���� statement

assignmentrelationname(X)

num(1)≠

���

��

name(X)

expression

operator

name(X) name(Y)–

Lecture 01 23

compiling Java to IJVM

i = j +k;

if (i ==3 )

k = 0;

else

j--;

….

Hex assembly …

j

j

k

j+k

Lecture 01 24

Central issues of OS design

Three main subject

� virtual memory

� File I/O

� parallel processing

Happy Christmas�