Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Sistema Operativo
giovedì 31 ottobre 13
Il Software
Non accettabile!
3
giovedì 31 ottobre 13
Il Software
Occorre fornire all’utente un meccanismo per:
–astrarre dall’organizzazione fisica per:
•usare nello stesso modo (o in modo simile)
macchine (hardware) diverse
•avere un semplice linguaggio di interazione
–avere un insieme di programmi applicativi per
svolgere diversi compiti: elaborare testi,
navigare in Internet, ecc.
4
giovedì 31 ottobre 13
Il Software
• I computer moderni raggiungono questi obiettivi mediante la definizione di
macchine virtuali realizzate al di sopra della macchina hardware
reale
Utente
HW
macchina virtuale
giovedì 31 ottobre 13
Macchine virtuali
• La macchina virtuale:
giovedì 31 ottobre 13
Macchine virtuali
• L'utente interagisce con la macchina virtuale con un
linguaggio ad alto livello (interfaccia grafica/testuale)
• La macchina virtuale traduce ogni comando
ad alto livello nell'opportuna serie di
comandi per l’hardware: astrazione
Utente
linguaggio ad
alto livello
linguaggio
HW macchina
macchina virtuale
giovedì 31 ottobre 13
Il sistema operativo
giovedì 31 ottobre 13
Il sistema operativo
print Documento
giovedì 31 ottobre 13
Il sistema operativo
medesimo
Utente linguaggio ad Utente
alto livello
diversi
linguaggi
HW1 HW2
macchina
macchina virtuale 1 macchina virtuale 2
giovedì 31 ottobre 13
Struttura a livelli del s.o.
• Il s.o. ha una struttura a cipolla, ogni livello:
– “astrae” il livello inferiore, nascondendone la complessità e
12
giovedì 31 ottobre 13
Struttura a livelli del s.o.
• Il s.o. ha una struttura a cipolla, ogni livello:
– “astrae” il livello inferiore, nascondendone la complessità e
hardware
…
12
giovedì 31 ottobre 13
S.O. e dispositivi di I/O
• Ogni dispositivo di I/O collegato al computer è gestito da un modulo del s.o. chiamato
driver
• Ogni volta che si aggiunge un nuovo dispositivo, si deve installare il driver
corrispondente all’interno del s.o.
• Nota:
Plug&Play
kernel
13
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
14
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (2)
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
16
giovedì 31 ottobre 13
Il bootstrap
Primo problema:
Come fare?
Prima soluzione:
17
giovedì 31 ottobre 13
Il bootstrap
Secondo problema:
Come fare?
Seconda soluzione:
18
giovedì 31 ottobre 13
Il bootstrap
Terzo problema:
Come fare?
Terza soluzione:
Memorizziamo il BIOS in una parte della memoria principale non volatile: la ROM
19
giovedì 31 ottobre 13
Il bootstrap
Dubbio:
Risposta:
20
giovedì 31 ottobre 13
Il bootstrap
Riassumendo:
21
giovedì 31 ottobre 13
Il bootstrap
1. Floppy disk
2. CD/DVD
3. Hard Disk
• Questo ordine è utile per installare un s.o. o per live cd (un live cd contiene
un s.o. che non necessita di installazione su hard disk)
22
giovedì 31 ottobre 13
Avvio dell’elaboratore
In seguito, viene caricata la prima parte del s.o.
23
giovedì 31 ottobre 13
Avvio dell’elaboratore
• La prima parte del s.o. che viene caricata comprende (in generale):
24
giovedì 31 ottobre 13
Avvio dell’elaboratore
• Parte dei programmi del s.o. devono essere mantenuti sempre in RAM per
essere sempre pronti per l’esecuzione
25
giovedì 31 ottobre 13
Avvio dell’elaboratore: l’I/O
• Alcuni sistemi verificano anche lo stato delle risorse hardware, per esempio
lo stato dei dischi (presenza di errori nel file system?)
26
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
27
giovedì 31 ottobre 13
Multitasking
• I moderni s.o. sono multitasking, cioè è possibile eseguire
più programmi allo stesso tempo (ad es. scaricare un file
mentre si scrive un documento)
• Problema: spesso gli elaboratori hanno una unica CPU.
Come possono eseguire più programmi
contemporaneamente?
giovedì 31 ottobre 13
Processi (esercizio)
Windows XP è multitasking:
per visualizzare i processi
premere contemporaneamente i
tasti Ctrl+Alt+Canc e andare su
Task Manager
(o Gestione attività)
/Processi
processo = programma in
esecuzione
29
giovedì 31 ottobre 13
Processi
• Soluzione: multitasking
Il S.O. assegna la CPU a un altro processo e la restituisce al primo quando
l’I/O è terminato
30
giovedì 31 ottobre 13
Processi
• Un processo può trovarsi in uno dei tre stati:
pronto in esecuzione
interrotto per lasciare la CPU a
un altro processo richiesta I/O o risorsa
I/O terminato o risorsa
disponibile in attesa
31
giovedì 31 ottobre 13
Processi
32
giovedì 31 ottobre 13
Processi (esercizio)
Task Manager (o Gestione
attività)
(Ctrl+Alt+Canc) frazione di tempo che un
processo trascorre in
esecuzione nella CPU
33
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
34
giovedì 31 ottobre 13
Memoria virtuale
Problema:
35
giovedì 31 ottobre 13
Memoria virtuale
•Tecnica di gestione della memoria utilizzata
da tutti i sistemi operativi moderni
36
giovedì 31 ottobre 13
Memoria virtuale
• Le parti (pagine) dei programmi usate meno spesso vengono “spostate” su hard disk
37
giovedì 31 ottobre 13
Memoria virtuale
Le pagine vengono riportate
in memoria quando servono
nuovamente, eventualmente
spostandone altre
su disco
38
giovedì 31 ottobre 13
Memoria virtuale
Il s.o. traduce automaticamente gli indirizzi virtuali (usati dalle
applicazioni) in indirizzi fisici
altri
programmi
hard disk
39
giovedì 31 ottobre 13
Memoria virtuale (esercizio)
1. Start / Risorse del computer
2. C:
file di paging: la
parte dell’hard
disk dedicata alla
memoria virtuale
40
giovedì 31 ottobre 13
Memoria virtuale (esercizio)
Task Manager (Ctrl+Alt+Canc) / Prestazioni
RAM
(512 MB)
41
giovedì 31 ottobre 13
Memoria virtuale
• Cosa succede se si utilizza frequentemente una quantità
di memoria virtuale molto più grande della memoria fisica?
• Thrashing (con la ‘h’, to thrash = dimenarsi):
il s.o. impiega più tempo a trasferire le pagine da e su disco che
a effettuare lavoro utile
42
giovedì 31 ottobre 13
Memoria virtuale
• Dato che la RAM è molto più veloce dell’hard disk, aumentare la quantità di RAM
può migliorare le prestazioni del computer, perché il s.o. dovrà fare ricorso
meno frequentemente all’hard disk per implementare la memoria virtuale
43
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
44
giovedì 31 ottobre 13
Il sistema operativo
– interazione grafica
• Mac OS X, Linux
• Windows
45
giovedì 31 ottobre 13
Interazione testuale
46
giovedì 31 ottobre 13
Interazione testuale (esercizio)
Start/Programmi/Accessori/Prompt dei comandi
47
giovedì 31 ottobre 13
Interazione grafica
– tecnologia WYSIWYG
(What You See Is What You Get)
– comandi uniformi:
es. Cancellare “oggetto” ⇒ taglia,
Copiare “oggetto” ⇒ copia
l’“oggetto” può essere testo, file, immagini, …
48
giovedì 31 ottobre 13
Interazione grafica
•Concetti principali
–finestra
–icona
–menu
–menu item
–button (pulsante)
49
giovedì 31 ottobre 13
Funzioni svolte dal sistema
operativo (1)
50
giovedì 31 ottobre 13
Il File System
• File System:
parte del S.O. che si occupa di gestire e strutturare le informazioni
memorizzate su supporti di memoria secondaria
(ad es. su hard disk, CD, DVD…)
• Operazioni di base supportate dal File System sui dati memorizzati: lettura/
scrittura, cancellazione, modifica, copia
51
giovedì 31 ottobre 13
Il File System
52
giovedì 31 ottobre 13
Il File System
• Si può immaginare il disco fisso
come un quaderno con tante pagine su cui l’utente scrive
varie relazioni (file)
Si noti che:
giovedì 31 ottobre 13
Il File System
Vantaggi:
54
giovedì 31 ottobre 13
Il File System
55
giovedì 31 ottobre 13
Il File System
• Esempio: indice
disco fisso
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
Nota: anche
l’indice è su
disco fisso
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
56
giovedì 31 ottobre 13
VUOTA VUOTA
giovedì 31 ottobre 13
VUOTA VUOTA
• Esempio:
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
Il File System
1. crea file 1
57
VUOTA file 1
giovedì 31 ottobre 13
VUOTA file 1
• Esempio:
VUOTA file 1
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
• file 1: cluster 0, 1, 2
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
Il File System
1. crea file 1
58
VUOTA file 1
giovedì 31 ottobre 13
VUOTA file 1
• Esempio:
VUOTA file 1
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
• file 1: cluster 0, 1, 2
VUOTA VUOTA
VUOTA VUOTA
VUOTA VUOTA
Il File System
2. crea file 2
59
Il File System
• Esempio:
• file 1: cluster 0, 1, 2
• Esempio: 2. crea file 2
• file 2: cluster 3
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
60
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2
• Esempio: 3. modifica file 1
• file 2: cluster 3 (più lungo)
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
61
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 3. modifica file 1
• file 2: cluster 3 (più lungo)
VUOTA
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
file 1
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
62
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 4. modifica file 2
• file 2: cluster 3 (più lungo)
VUOTA
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
file 1
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
63
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 4. modifica file 2
• file 2: cluster 3, 5 (più lungo)
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
file 1
file 2
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
64
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 5. crea file 3
• file 2: cluster 3, 5
VUOTA
VUOTA
VUOTA
file 1
file 1
file 1
file 2
file 1
file 2
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
65
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 5. crea file 3
• file 2: cluster 3, 5
• file 3: cluster 6, 7
VUOTA
file 1
file 1
file 1
file 2
file 1
file 2
file 3
file 3
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
66
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 6. crea file 4
• file 2: cluster 3, 5
• file 3: cluster 6, 7
VUOTA
file 1
file 1
file 1
file 2
file 1
file 2
file 3
file 3
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
67
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 6. crea file 4
• file 2: cluster 3, 5
• file 3: cluster 6, 7
• file 4: cluster 8, 9
file 1
file 1
file 1
file 2
file 1
file 2
file 3
file 3
file 4
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 4
68
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 7. cancella file 3
• file 2: cluster 3, 5
• file 3: cluster 6, 7
• file 4: cluster 8, 9
file 1
file 1
file 1
file 2
file 1
file 2
file 3
file 3
file 4
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 4
69
giovedì 31 ottobre 13
Il File System
• Esempio:
• file 1: cluster 0, 1, 2, 4
• Esempio: 7. cancella file 3
• file 2: cluster 3, 5 il file 3 viene eliminato
solo dall’indice; i cluster 6
• file 3: cluster 6, 7 e 7 verranno sovrascritti
alla prima occasione
• file 4: cluster 8, 9
file 1
file 1
file 1
file 2
file 1
file 2
file 4
file 3
file 3
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 4
70
giovedì 31 ottobre 13
Il File System
• Esempio:
file 1
file 1
file 2
file 1
file 2
file 4
file 3
file 3
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
VUOTA
file 4
71
giovedì 31 ottobre 13
Il File System: esercizio
Per deframmentare:
Start / Programmi / Accessori / Utilità di sistema /
Utilità di deframmentazione dischi
72
giovedì 31 ottobre 13
Il File System
Il file system deve fornire una visione astratta dei file,
consentendo all’utente di:
• dare un nome ai file (filename)
giovedì 31 ottobre 13
Il File System
• Tutti i sistemi operativi forniscono i seguenti comandi per
operare sui file:
– creazione
– cancellazione
– copia
– visualizzazione
– stampa
– lettura e modifica
– rinomina 74
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
– per la creazione di un nuovo file (non si possono avere due file con lo stesso
nome)
• Il s.o. deve fornire all’utente la possibilità di dare una struttura organizzata ai file
75
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
• directory (o cartella): gruppo di file (e di altre directory)
il s.o. mette a disposizione comandi per creare
directory
76
giovedì 31 ottobre 13
Come chiamare file e
giovedì 31 ottobre 13
Come chiamare file e
• Quando si rinomina un file, bisogna prestare attenzione
all’estensione, per non perdere l’associazione all’applicativo
78
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
79
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Struttura ad albero Corsi
Inglese Appunti.txt
Dispense.pdf
(rovesciato, come Francese
Elab_imm coreldrw.exe
Disco rimovibile Applicazioni
(E:) Elab_suoni photopnt.exe
Elab_testi Winword.exe
radice libro1
Francese libro2
libro1
Libri
Inglese libro2
libro3
libro1
Appunti.txt Italiano libro2
libro3 80
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Naming dei file:
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Esempi :
E:\Libri\Italiano\libro1
E:\Corsi\Inglese
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
83
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Inglese Appunti.txt
Corsi Dispense.pdf
Francese
Tedesco
Spagnolo
Elab_imm coreldrw.exe
Disco rimovibile Applicazioni
(E:) Elab_suoni photopnt.exe
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Esempi :
Italiano\libro1
85
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Inglese Appunti.txt
Corsi Dispense.pdf
Francese
Tedesco
posizione Spagnolo
corrente
Elab_imm coreldrw.exe
Disco rimovibile Applicazioni
(E:) Elab_suoni photopnt.exe
Elab_testi Winword.exe
libro1
Francese libro2
libro1
Libri
Inglese libro2
libro3
libro1
Appunti.txt Italiano libro2
libro3 86
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
Esempi :
Dispense.pdf
87
giovedì 31 ottobre 13
Organizzazione gerarchica dei file
– copiare il contenuto
88
giovedì 31 ottobre 13