Laboratorio di Calcolo II - PowerPoint PPT Presentation

About This Presentation
Title:

Laboratorio di Calcolo II

Description:

examples: Intel Pentium, AMD K6, Motorola PowerPC, Sun SPARC, Calvin College. Hardware: RAM ... Windows-98, Windows-NT, UNIX, Linux, Solaris, ... Calvin College ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 32
Provided by: Bian1
Category:

less

Transcript and Presenter's Notes

Title: Laboratorio di Calcolo II


1
Laboratorio di Calcolo II
  • Obbiettivo insegnarvi a scrivere programmi in
    c
  • 2 ore/settimana di lezione in aula
  • 4 ore/settimana di esercitazioni personali al
    computer
  • Esercitazioni per studenti lavoratori il sabato
    mattina
  • Fondamentale la partecipazione alle esercitazioni
  • Lesame consiste nello scrivere un programma e
    nel discuterlo con il docente

2
Docente
  • Fabrizio Bianchi
  • Tel. 011/6707331
  • E-mail bianchi_at_to.infn.it
  • URL www.to.infn.it/bianchi

3
Testo e Materiale
  • Testo consigliato C, How to Program, Deitel
    Deitel, 4E, Prentice Hall
  • Esiste la traduzione italiana della terza
    edizione
  • Trasparenze www.to.infn.it/bianchi/LaboratorioCa
    lcoloII/ lezxy.ppt formato
    powerpoint
    lezxy.pdf formato pdf (consigliato per la
    stampa)
  • Raccomando di partecipare a lezioni ed
    esercitazioni con copia delle trasparenze

4
What is Programming?
  • A sequence of statements that instruct a computer
    in how to solve a problem is called a program.
  • The act of designing, writing and maintaining a
    program is called programming.
  • People who write programs are called programmers.

5
What kinds of statementsdo computers understand?
  • A computer only understands machine
    language statements.
  • A machine language statement is a sequence of
    ones and zeros that cause the computer to perform
    a particular action, such as add, subtract,
    multiply, ...

6
Machine Language (ML)
  • ML statements are stored in a computers memory,
    which is a sequence of switches.
  • For convenience of representation, an
    on switch is represented by 1, and an
    off switch is represented by 0.
  • ML thus appears to be binary (base-2)
  • 0010111010110101

7
Early Computers
  • ... required a programmer to write in ML...
  • Easy to make mistakes!
  • Such mistakes are hard to find!
  • Not portable -- only runs on one kind of machine!
  • Programming was very difficult!

8
A Bright Idea
  • Devise a set of abbreviations (mnemonics)
    corresponding to the ML statements, plus a
    program to translate them into ML.
  • The abbreviations are an assembly language, and
    the program is called an assembler.

9
Assembly Languages
  • Allowed a programmer to use mnemonics, which were
    more natural than binary.
  • Much easier to read programs
  • Much easier to find and fix mistakes
  • Still not portable to different machines

10
High Level Languages
  • Devise a set of statements that are close to
    human language (if, while, do, ...), plus a
    program to translate them into ML.
  • The set of statements is called a high level
    language (HLL) and the program is called a
    compiler.

11
HLL Compilers
  • Where an assembler translates one mnemonic into
    one ML statement, a
    HLL compiler translates one HLL statement into
    multiple ML statements.

12
HLLs
  • High level languages (like C) are
  • Much easier to read programs
  • Much easier to find and fix mistakes
  • Portable from one machine to another
    (so long as they keep to the language standard).

13
Objectives in Programming
  • A program should solve a problem
  • correctly (it actually solves the problem)
  • efficiently (without wasting time or space)
  • readably (understandable by another person)
  • in a user-friendly fashion
    (in a way that is easy for its user to use).

14
Summary
  • There are levels to computer languages
  • ML consists of low level binary statements,
    that is hard to read, write, and not portable.
  • Assembly uses medium level mnemonics easier to
    read/write, but not portable.
  • C is a high level language that is even
    easier to read/write, and portable.

15
Computer Organization
Hardware and Software
16
Computing Systems
  • Computers have two kinds of components
  • Hardware, consisting of its physical devices
    (CPU, memory, bus, storage devices, ...)
  • Software, consisting of the programs it has
    (Operating system, applications, utilities, ...)

17
Hardware CPU
  • Central Processing Unit (CPU)
  • the brain of the machine
  • location of circuitry that performs arithmetic
    and logical ML statements
  • measurement speed (roughly) in megahertz
    (millions of clock-ticks per second)
  • examples Intel Pentium, AMD K6, Motorola
    PowerPC, Sun SPARC,

18
Hardware RAM
  • Random Access Memory (RAM)
  • main memory, which is fast, but volatile...
  • analogous to a persons short-term memory.
  • many tiny on-off switches for convenience
  • on is represented by 1, off by 0.
  • each switch is called a binary digit, or bit.
  • 8 bits is called a byte.
  • 210 bytes 1024 bytes is called a kilobyte (1K)
  • 220 bytes is called a megabyte (1M).

19
Hardware (Disk)
  • Secondary Memory (Disk)
  • Stable storage using magnetic or optical media.
  • Analogous to a persons long-term memory.
  • Slower to access than RAM.
  • Examples
  • floppy disk (measured in kilobytes)
  • hard disk (measured in gigabytes (230 bytes))
  • CD-ROM (measured in megabytes), ...

20
Hardware the Bus
  • The Bus
  • Connects CPU to other hardware devices.
  • Analogous to a persons spinal cord.
  • Speed measured in megahertz (like the CPU), but
    typically much slower than the CPU...
  • The bottleneck in most of todays PCs.

21
Hardware Cache
  • While accessing RAM is faster than accessing
    secondary memory, it is still quite slow,
    relative to the rate at which the CPU runs.
  • To circumvent this problem, most systems add a
    fast cache memory to the CPU, to store recently
    used instructions and data.
  • (Assumption Since such instructions/data were
    needed recently, they will be needed again in the
    near future.)

22
Hardware Summary
  • Putting the pieces together

Programs are stored (long-term) in secondary
memory, and loaded into main memory to run, from
which the CPU retrieves and executes their
statements.
23
Software OS
  • The operating system (OS) is loaded from
    secondary memory into main memory when the
    computer is turned on, and remains in memory
    until the computer is turned off.

24
Software OS
  • The OS acts as the manager of the system,
    making sure that each hardware device interacts
    smoothly with the others.
  • It also provides the interface by which the user
    interacts with the computer, and awaits user
    input if no application is running.
  • Examples MacOS, Windows-98, Windows-NT, UNIX,
    Linux, Solaris, ...

25
Software Applications
  • Applications are non-OS programs that perform
    some useful task, including word
    processors, spreadsheets, databases, web
    browsers, C compilers, ...
  • Example C compilers/environments
  • CodeWarrior (MacOS, Win95, WinNT, Solaris)
  • GNU C (UNIX, Linux)
  • Turbo/Borland C (Win95, WinNT)
  • Visual C (Win95, WinNT)

26
Software User Programs
  • Programs that are neither OS programs nor
    applications are called user programs.
  • User programs are what youll be writing in this
    course.

27
Putting it all together
  • Programs and applications that are not running
    are stored on disk.

28
Putting it all together
  • When you launch a program, the OS controls the
    CPU and loads the program from disk to RAM.

29
Putting it all together
  • The OS then relinquishes the CPU to the program,
    which begins to run.

30
The Fetch-Execute Cycle
  • As the program runs, it repeatedly fetches the
    next instruction (from memory/cache), executes
    it, and stores any results back to memory.

Disk
RAM
CPU
Cache
OS
App
App
App
Bus
Thats all a computer does fetch-execute-store,
millions of times each second!
31
Summary
  • A computer has two kinds of components
  • Hardware its CPU, RAM, Disk(s), ...
  • Software, its OS, Applications, and User Programs.
Write a Comment
User Comments (0)
About PowerShow.com