FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su...
Transcript of FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su...
![Page 2: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/2.jpg)
IL PROGRAMMA
• Sistemi operativi • Introduzione all’utilizzo di Linux
• Concetti teorici base informatica
• Programmazione C
• Le basi del linguaggio • Strutture dati • Algoritmi (base) • Varie
![Page 3: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/3.jpg)
MATERIALE Libro di testo: Deitel & Deitel: “Il linguaggio C” slides: http://tinyurl.com/fondinf2016
LEZIONE TIPICA ¾ h Teoria ¾ h Pratica (portare sempre il computer) Ricevimento: giovedì dopo lezione
MAILING LIST [email protected] Iscrizione tramite: http://lists.uniroma2.it
rfc1855
![Page 4: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/4.jpg)
INSTALLARE LINUX • Scaricare linux
• Distribuzione consigliata: xubuntu > 14.04.3 • Installarlo
• Partizione nativa • Un bootloader vi farà scegliere all’avvio quale sistema
operativo usare • Macchina virtuale
• VirtualBox (free software, multipiattaforma, www.virtualbox.org)
• VMWare (commerciale, Windows/OSX) • Live CD/DVD
• Basta inserire il cd/dvd e riavviare il computer • Attenzione! ogni riavvio tutti i dati saranno persi (se non
salvati ad es. su una chiavetta esterna)
![Page 5: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/5.jpg)
IL LINGUAGGIO C Ideato e realizzato ~1970 Prestazioni elevate
• Sistemi Operativi, Embedded, Sistemi Real Time o per le TLC Standard
• ANSI e ISO • Nostro standard di riferimento: INCITS/ISO/IEC 9899-1999,
chiamato C99 • Ultimo standard: C11
Portabile • Il C non dipende dall’hardware (standard internazionale)
• ma alcune funzioni implementate possono dipendere dal sistema operativo e/o dall’hardware
• Con una progettazione adeguata è possibile realizzare programmi portabili
![Page 6: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/6.jpg)
PERCHÈ IL C
http://iel.ucdavis.edu/publication/WhyC.html
• Il C è vicino al linguaggio macchina per capire come “ragiona” • …ma abbastanza astratto da permettere programmi anche molto complessi • Usato molto per progetti hardware e device con risorse limitate (embedded)
Popolare (src: http://www.langpop.com/)
![Page 7: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/7.jpg)
THE MARCH OF PROGRESS
266 pages 274 pages 911 pages
1536 pages
src: E. Roberts : The Dream of a Common Language: The Search for Simplicity and Stability in Computer Science Education
![Page 8: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/8.jpg)
“NON VOGLIO FARE IL PROGRAMMATORE!”
![Page 9: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/9.jpg)
LA RIVOLUZIONE INDUSTIALE
Popolazione del mondo (miliardi)
![Page 10: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/10.jpg)
LA RIVOLUZIONE INDUSTRIALE
![Page 11: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/11.jpg)
LA RIVOLUZIONE DIGITALE
Charlie chaplin: tempi moderni Amazon warehouse: kiva system robot
![Page 12: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/12.jpg)
LA RIVOLUZIONE DIGITALE: LAVORI
“there’s never been a worse time to be a worker with only ‘ordinary’ skills and abilities to offer, because computers, robots, and other digital technologies are acquiring these skills and abilities at an extraordinary rate.”
The Second Machine Age: Work, Progress, and Prosperity in a Time of Brilliant Technologies."
![Page 13: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/13.jpg)
SETTORI RIVOLUZIONATI: KODAK VS INSTAGRAM
140 000 impiegati Bancarotta nel Febbraio 2012
13 impiegati nel 2012 Comprata da facebook a 1 mld di dollari
![Page 14: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/14.jpg)
SETTORI SPARITI:
![Page 15: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/15.jpg)
IL LAVORO The probability of computerization for the U.S. Bureau of Labor Statistics 2010 occupational categories, along with the share in low, medium and high probability categories. The probability axis can also be seen as a rough timeline, where high-probability occupations are likely to be substituted by computer capital relatively soon. Note that the total area under all curves is equal to total U.S. employment. Credit: Carl Benedikt Frey and Michael A. Osborne
![Page 16: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/16.jpg)
LA LEGGE DI MOORE “The complexity for minimum component costs has increased at a rate of roughly a factor of two per year. Certainly over the short term this rate can be expected to continue, if not to increase. Over the longer term, the rate of increase is a bit more uncertain, although there is no reason to believe it will remain nearly constant for at least 10 years.”
(G. Moore 1965)
![Page 18: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/18.jpg)
CHE COS’E’ L’INFORMATICA?
• Scienza che studia • Fondamenti teorici dell’informazione • Computazione • Implementazione su elaboratori elettronici
• Due anime:
• Tecnologica: computer e sistemi • Metodologica: gestione e processamento dell’informazione
“L'informatica non riguarda i computer più di quanto l'astronomia riguardi i telescopi”
E. Dijkstra
![Page 19: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/19.jpg)
IL COMPUTER • Macchina programmabile per la rappresentazione, la
memorizzazione, l’elaborazione e la trasmissione delle informazioni
• Distinzione tra: • Hardware: parte fisica (elettronica, meccanica etc) • Software: parte logica (programmi)
• Definizione cambiata nel tempo, attualmente macchina che: • Riceve degli input • Produce degli output • Processa l’informazione • Puo’ memorizzare dell’informazione • Ha dei meccanismo di controllo
• Un cellulare, un modem wifi, un laptop
![Page 20: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/20.jpg)
BREVE STORIA DEI COMPUTER • 1823: Charles Babbage inventò la
macchina differenziale; • In 1936 Alan Turing definì la Macchina
di Turing, una macchina ideale che manipola i dati contenuti su un nastro di lunghezza infinita, secondo un insieme prefissato di regole ben definite (strumento teorico)
• Nella seconda guerra mondiale, venne inventato Colossus, il primo computer elettronico programmabile
• 1948: il “manchester baby”: primo computer basato sull’architettura di John Von Neumann (more later) che memorizza programmi e dati nella stessa memoria.
![Page 21: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/21.jpg)
BREVE STORIA DEI COMPUTER • 1947 : Invenzione del transistor • 1958 : Invenzione del circuito integrato • 1965 : Primo personal computer –
Programma 101 (prodotto da Olivetti inventato da P.G. Perotto)
• 1971 : Una giovane società chiamata Intel produceva il primo microprocessore • L’intel 4004 conteneva circa 2300
transistor su un singolo chip • oggi circa un miliardo per chip
• 1981 : Inizio diffusione personal computer su larga scala
![Page 22: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/22.jpg)
1983
![Page 23: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/23.jpg)
PROGRAMMA
Programma: Sequenza di istruzioni che il computer esegue e di decisioni che il computer prende per svolgere una certa attivita Programmazione: L’attività di progettare o realizzare un programma
![Page 24: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/24.jpg)
ALGORITMO • Si dice algoritmo la descrizione di un metodo di soluzione
di un problema che • sia eseguibile • sia priva di ambiguita arrivi ad una conclusione in un
tempo finito
• Un computer può risolvere soltanto quei problemi per i quali sia noto un algoritmo
• Dato un algorimo, si puo’ realizzarlo (implementarlo) attraverso un programma
![Page 25: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/25.jpg)
ESEMPIO DI ALGORITMO Problema: dato un numero, scoprire se è un multiplo di 11 (senza usare divisioni e moltiplicazioni) Algorimo 1:
1. Definiscono una variabile X che è il numero immesso 2. Valuta una condizione:
Se X=11 allora restitutisci VERO Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna al passo 2
Algorimo 2: Somma le cifre pari del numero e confrontale con la somma delle cifre dispari
1782 à 1+8 = 7+2 Se sono uguali, restituisci VERO, altrimento FALSO
Diversi algoritmi che risolvono lo stesso problema
Cosa cambia?
![Page 26: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/26.jpg)
EFFICIENZA • Gli algoritmi sono parametrici
• Dati degli input, ci restituiscono degli output • Risolvono instanze diverse dello stesso problema
• Esempio precedente: l’algoritmo accetta qualunque numero intero
• Alcuni algoritmi risolvono lo stesso problema in modo più efficiente di altri • consumano meno risorse (memoria, capacità di calcolo)
• E’ particolarmente importante valutare la scalabilità dell’algoritmo con i dati di ingresso, misurata con la complessità • Notazione “big o” (nasconde fattori costanti e potenze di
ordine minore) • Esempio: eliminazione di Gauss : O(n3) • Alcuni problemi hanno complessità O(2n)…
![Page 27: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/27.jpg)
ALTRI ALGORITMI… (IBM) Deep Blue vs Kasparov: 1996
![Page 28: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/28.jpg)
ALTRI ALGORITMI… Capcha
![Page 29: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/29.jpg)
ALTRI ALGORITMI… IBM Watson : 2011 Jeopardy!
Sistema per rispondere a domande formulate in linguaggio naturale
![Page 30: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/30.jpg)
MODELLO DI VON NEUMANN Architettura di riferimento usata nella maggior parte dei computer in uso oggi
• ma concepita 70 anni fa! 5 componenti fondamentali:
1. CPU 2. Unità di memoria (RAM) 3. Unità di input (ad es. tastiera,
HardDisk, CDRom) 4. Unità di output (ad ed. monitor,
HardDisk) 5. Bus
EDVAC 1951 – computer per il quale è stata progettata inizialmente l’architettura
![Page 31: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/31.jpg)
CPU • Central Processing Unit
• Quando fatto su un solo chip di silicio (circuito integrato): microprocessore
• Obiettivo: eseguire una sequenza di istruzioni memorizzate chiamata programma
• Ciclo di Esecuzione 1. Prelievo Istruzione dalla Memoria (fetch) 2. Decodifica Istruzione (decode) 3. Esecuzione Istruzione (execute) 4. Scrittura risultato (writeback)
• Ogni Processore e’ caratterizzato da un proprio linguaggio macchina
![Page 32: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/32.jpg)
PER COSTRUIRE UN PROCESSORE… • Abbiamo bisogno almeno di:
• Qualche registro: aree di memoria dove possiamo immagazzinare alcuni dati
• Una ALU (Arithmetic Logic Unit): esegue i calcoli, ha dei registri al suo interno
• Un unita’ di controllo: coordina i componenti, • “Il cervello nel cervello” • fornisce segnali di controllo e di sincronizzazione • Dirige il flusso dati da/verso la CPU
• Qualche bus per muovere i dati da un componente all’altro
![Page 33: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/33.jpg)
REGISTRI • PC (Program Counter): registro contatore delle istruzioni,
contiene l’indirizzo della prossima istruzione da eseguire • IR (Instruction Register): registro delle istruzioni, contiene
l’istruzione che deve essere eseguita (codificata) • MAR (Memory Address Register): registro di indirizzamento
della memoria, contiene l’indirizzo della cella di memoria che deve essere acceduta o memorizzata
• MDR (Memory Data Register): registro dati di memoria, dato che è stato prelevato dalla memoria o che deve essere memorizzato
• PSW (Processor Status Word): parola di stato del processore; contiene informazioni, opportunamente codificate, circa l’esito dell’ultima istruzione che è stata eseguita
![Page 34: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/34.jpg)
![Page 35: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/35.jpg)
DISPOSITIVI DI INPUT • Tastiera • Mouse • Hard Disk
• DVD-ROM
• Microfono
• etc
![Page 36: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/36.jpg)
DISPOSITIVI DI OUTPUT • Monitor • Stampante • Hard Disk
• Casse acustiche
• etc
![Page 37: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/37.jpg)
BUS • La struttura di interconnessione piu
comune (hw e sw) • percorsi di comunicazione tra due o
piu dispositivi • Diversi tipi:
• Il bus dati (bidirezionale) consente di leggere/scrivere informazioni sulla memoria o sulle unità periferiche
• Il bus indirizzi va dalla CPU alla memoria o alle periferiche consentendo di scegliere dove scrivere o leggere i dati.
• Il bus di controllo (bidirezionale) serve per coordinare e controllare il traffico di informazioni che viaggiano sugli altri due bus.
![Page 38: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/38.jpg)
MEMORIA • Memoria Primaria: Memoria Centrale
• Contiene istruzioni/dati dei programmi in esecuzione • ...in formato binario
• Volatile • RAM – Random Access Memory
• E’ possibile accedere a diversi elementi non in ordine (random access) • Un CD/Musicassetta/HardDisk ad esempio non lo permette
• Tempo di accesso costante • SRAM, DRAM, etc.
• Veloce (~10-100ns) e relativamente costosa • Dimensioni contenute (fino a qualche Gigabyte)
• Memoria Secondaria: Dischi, CD, etc.. • Memoria di lungo periodo - non volatile • Tempo di accesso maggiori (~ms e piu’), economica
![Page 39: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/39.jpg)
VELOCITÀ DELLE MEMORIE • Per velocizzare l’esecuzione dei programmi, tra
processore e RAM viene inserita una memoria particolarmente veloce dove tenere i dati usati piu spesso (MEMORIA CACHE) • I livello: presente nel microprocessore • II livello: esterna
• La presenza di più memorie con caratteristiche diverse nasce da un compromesso tra costo ed efficienza
Dispositivo Temp di accesso RAM ~10 – 100 ns Hard Disk ~10ms Registri processore ~1ns Memoria Cache ~10ns
![Page 40: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/40.jpg)
LA MEMORIA CENTRALE • Composta di celle, o locazioni, a loro volta composte da un numero
fisso di bit • Cella elementare di memoria puo memorizzare solo due valori: 0 o 1,
cifra binaria (binary digit -> bit) • Tipicamente cella=1 byte (8 bit)
• Ogni locazione e’ associata ad un indirizzo nell’intervallo [0,1,...,M-1] • M dimensione della memoria • La memoria e’ vista come un vettore di byte
• La CPU (ma non solo) accede alle informazioni in scrittura/lettura tramite indirizzo della cella • Indirizzi a m bit: spazio di indirizzamento 2m • Non necessariamente M=2m
• Operazioni: Lettura/Scrittura • Lettura: Prelevare il contenuto di una cella di memoria • Scrittura: Sostituire il contenuto di ina cella di memoria
![Page 41: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/41.jpg)
LA MEMORIA VIRTUALE • Astrae le memorie presenti
• Alcuni accessi sulla memoria fisica • Altri su hard disk
• “swap” • Processore e programmi si
riferiscono ad indirizzi virtuali • Tradotti in indirizzi reali da MMU
(memory management unit) • componente hardware • se non trova l’indirizzo, solleva
un “page fault” ed il sistema operativo cerca l’indirizzo sull’hard disk
• Memoria organizzata in “pagine” • molte pagine piccole: problemi
lookup • poche pagine grandi:
frammentazione (pagine parzialmente vuote)
![Page 42: FONDAMENTI DI INFORMATICAstud.netgroup.uniroma2.it/~lorenzo/fondinf2016/intro.pdf · transistor su un singolo chip ... Se X < 11 restituisci FALSO SE X > 11, sottrai 11 e torna](https://reader033.fdocument.pub/reader033/viewer/2022042214/5eb9cb6e92d946010d7bb881/html5/thumbnails/42.jpg)
FILM CONSIGLIATI