Anda di halaman 1dari 59

Operating

Systems:
Internals Chapter 1
and
Design Computer System
Principles Overview
Eighth Edition
By William Stallings
Operating System
 Memanfaatkan sumber daya hardware dari satu
atau lebih prosesor
 Menyediakan suatu set layanan bagi pengguna
sistem
 Mengatur memori sekunder dan perangkat I / O
Basic Elements

I/O
Processor Modules

System
Main
Bus
Memory
Processor
Melakukan
Mengontrol
fungsi
operasi2 dalam
pemrosesan
komputer
data

Dikenal sebagai
Central
Processing Unit
(CPU)
Main Memory
 Volatile

 Isi
memori akan hilang jika
komputer mati
 Dikenal sbg memori utama
I/O Modules
penyimpanan
(mis: hard
drive)
Memindahkan
data antara
Peralatan
komputer dan komunikasi
linkungan
eksternal, spt:
terminal2
System Bus

Menyediakan jalur
komunikasi antara
processors, memori
utama, and I/O modules
CPU Main Memory
0
System 1
2
PC MAR Bus
Instruction
Instruction
Instruction
IR MBR

I/O AR
Data
Execution
unit Data
I/O BR Data
Data

I/O Module n-2


n-1

PC = Program counter
Buffers IR = Instruction register
MAR = Memory address register
MBR = Memory buffer register
I/O AR = Input/output address register
I/O BR = Input/output buffer register

Figure 1.1 Computer Components: Top-Level View


Microprocessor
 Cikal
bakal penemuan tentang desktop
dan komputasi genggam
 Prosesor pada satu chip
 general purpose processor yang tercepat
 Multiprocessor

 Setiap
chip (socket) berisi beberapa
prosesor (core)
Graphical Processing
Units (GPU’s)
 Memberikan perhitungan yang efisien
pada larik data menggunakan teknik
Single-Instruction Multiple Data (SIMD)
 Digunakan untuk pemrosesan numerik
scr umum
 Simulasi fisik untuk game
 Komputasi pada large spreadsheet
Digital Signal Processors
(DSPs)
 Berurusan dengan sinyal streaming
seperti audio atau video
 Digunakan untuk disematkan di
perangkat seperti modem
 Encoding / decoding pada speech dan
video (codecs)
 Dukungan untuk enkripsi dan
keamanan
System on a Chip
(SoC)
 Untukmemenuhi persyaratan
perangkat genggam, mikroprosesor
menawarkan fitur SoC
 Komponenseperti DSP, GPU, codec
dan memori utama, selain CPU
dan cache, berada pada chip
yang sama
Instruction Execution

 Suatu program yang terdiri dari satu set


instruksi yang disimpan dalam memori

processor membaca processor


(fetches) instruksi mengeksekusi
dari memori masing2 instruksi

Dua langkah
Fetch Stage Execute Stage

Fetch Next Execute


START HALT
Instruction Instruction

Figure 1.2 Basic Instruction Cycle


 processor mengambil/ membaca instruksi dari
memory
 Program counter (PC) menahan (menyimpan
sementara) alamat instruksi yang akan diambil
berikutnya
 PC bertambah setelah setiap pengambilan
Instruction Register (IR)

Instruksi yang diambil  Prosesor menafsirkan


dimuat ke Instruction instruksi dan
Register (IR) melakukan tindakan
yang diperlukan:
 Processor-memory
 Processor-I/O
 Pengolahan data
 Kontrol
Fetch Stage Execute Stage
Memory CPU Registers Memory CPU Registers
300 1 9 4 0 3 0 0 PC 300 1 9 4 0 3 0 1 PC
301 5 9 4 1 AC 301 5 9 4 1 0 0 0 3 AC
302 2 9 4 1 1 9 4 0 IR 302 2 9 4 1 1 9 4 0 IR
• •
• •
940 0 0 0 3 940 0 0 0 3
941 0 0 0 2 941 0 0 0 2
Step 1 Step 2
Memory CPU Registers Memory CPU Registers
300 1 9 4 0 3 0 1 PC 300 1 9 4 0 3 0 2 PC
301 5 9 4 1 0 0 0 3 AC 301 5 9 4 1 0 0 0 5 AC
302 2 9 4 1 5 9 4 1 IR 302 2 9 4 1 5 9 4 1 IR
• •
• •
940 0 0 0 3 940 0 0 0 3 3+2=5
941 0 0 0 2 941 0 0 0 2
Step 3 Step 4
Memory CPU Registers Memory CPU Registers
300 1 9 4 0 3 0 2 PC 300 1 9 4 0 3 0 3 PC
301 5 9 4 1 0 0 0 5 AC 301 5 9 4 1 0 0 0 5 AC
302 2 9 4 1 2 9 4 1 IR 302 2 9 4 1 2 9 4 1 IR
• •
• •
940 0 0 0 3 940 0 0 0 3
941 0 0 0 2 941 0 0 0 5
Step 5 Step 6

Figure 1.4 Example of Program Execution


(contents of memory and registers in hexadecimal)
Interrupts
 Menginterupsi urutan normal dari prosesor
 Disediakan untuk meningkatkan utilisasi
prosesor
 Kebanyakan I/O devices lebih lambat dari processor
 processor harus jeda (pause) untuk menunggu
kesiapan device
 Menyia-nyiakan kegunaan processor
Table 1.1 Classes of Interrupts
Program
Dihasilkan oleh beberapa kondisi yang terjadi sebagai hasil dari eksekusi
instruksi, seperti overflow aritmatika, pembagian dengan nol, upaya untuk
mengeksekusi instruksi mesin ilegal, dan referensi di luar ruang memori
yang diizinkan pengguna space.

Timer
Dihasilkan oleh timer dalam prosesor. Ini memungkinkan sistem operasi
untuk melakukan fungsi-fungsi tertentu secara teratur.

I/O
Dihasilkan oleh pengontrol I/O, untuk menandai penyelesaian normal suatu
operasi atau untuk menandai berbagai kondisi kesalahan.

Hardware failure
Dihasilkan oleh kegagalan, seperti kegagalan daya atau kesalahan paritas
memori.
User I/O User
Program Program Program

1 4 1

I/O
Command
WRITE WRITE
5
2a

Figure 1.5a 2
END

2b

WRITE WRITE

Aliran Kontrol 3a

Tanpa Interupsi 3

3b

WRITE WRITE

(a) No interrupts (b) Inter


User I/O User I/O User
Program Program Program Program Program

1 4 1 4 1

I/O I/O
Command Command
WRITE WRITE WRITE
5
2a
END

Figure 1.5b
2

Interrupt
2

2b Handler

WRITE WRITE 5 WRITE

Short I/O Wait 3a


END

3 3

3b

WRITE WRITE WRITE

(a) No interrupts (b) Interrupts; short I/O wait (c) In


I/O User I/O User I/O
Program Program Program Program Program

4 1 4 1 4

I/O I/O I/O


Command Command Command
WRITE WRITE
5
2a
Figure 1.5c
END
2

Interrupt Interrupt
2b Handler Handler

WRITE 5 WRITE 5
Long I/O Wait END END
3a

3b

WRITE WRITE

No interrupts (b) Interrupts; short I/O wait (c) Interrupts; long I/O wait
User Program Interrupt Handler

i
Interrupt
occurs here i+1

Figure 1.6 Transfer of Control via Interrupts


Fetch Stage Execute Stage Interrupt Stage

Interrupts
Disabled
Check for
Fetch next Execute interrupt;
START instruction instruction initiate interrupt
Interrupts
handler
Enabled

HALT

Figure 1.7 Instruction Cycle with Interrupts


Time

1 1

4 4
I/O operation
I/O operation;
processor waits 2a concurrent with
processor executing

5 5

2b
2
4
I/O operation
4 3a concurrent with
processor executing
I/O operation;
processor waits 5

5 3b

(b) With interrupts


3

(a) Without interrupts

Figure 1.8 Program Timing: Short I/O Wait


Time

1 1

4 4

I/O operation; 2 I/O operation


processor waits concurrent with
processor executing;
then processor
waits
5

5
2
4
4
3 I/O operation
concurrent with
I/O operation; processor executing;
processor waits then processor
waits

5
5

3 (b) With interrupts

(a) Without interrupts

Figure 1.9 Program Timing: Long I/O Wait


Hardware Software

Device controller or
other system hardware
issues an interrupt
Save remainder of
process state
information
Processor finishes
execution of current
instruction

Process interrupt
Processor signals
acknowledgment
of interrupt
Restore process state
information
Processor pushes PSW
and PC onto control
stack
Restore old PSW
and PC
Processor loads new
PC value based on
interrupt

Figure 1.10 Simple Interrupt Processing


T–M T–M
Y N+1
Control Control
Stack Stack
T T
N+1 Y+L+1
Program Program
Counter Counter

Y Start Y Start
Interrupt General Interrupt General
Service Registers Service Registers
Y + L Return Routine T Y + L Return Routine T–M
Stack Stack
Pointer Pointer

Processor Processor

T–M T

N User's N User's
N+1 N+1
Program Program

Main Main
Memory Memory

(a) Interrupt occurs after instruction


(b) Return from interrupt
at location N

Figure 1.11 Changes in Memory and Registers for an Interrupt


Multiple Interrupts

Interupsi terjadi
saat interupsi lain Dua pendekatan:
sedang diproses
• misalnya menerima • nonaktifkan interupsi
data dari saluran sementara interupsi
komunikasi dan sedang diproses
mencetak hasil pada • menggunakan skema
saat yang bersamaan prioritas
Interrupt
User Program Handler X

Interrupt
Handler Y

(a) Sequential interrupt processing

Interrupt
User Program Handler X

Interrupt
Handler Y

(b) Nested interrupt processing

Figure 1.12 Transfer of Control with Multiple Interrupts


Printer Communication
User Program
interrupt service routine interrupt service routine
t=0

15
0 t=
t =1

t = 25

t= t = 25 Disk
40 interrupt service routine

t=
35

Figure 1.13 Example Time Sequence of Multiple Interrupts


Memory Hierarchy

 Kendala utama dalam memori


 jumlah
 kecepatan
 biaya
 Memori harus dapat mengikuti kec. prosesor
 Harga memori haruslah masuk akal dalam
hubungannya dengan komponen lain
Memory Relationships

Kapasistas lebih
Waktu akses besar = biaya per bit
lebih cepat = lebih murah
biaya per bit Kapasistas lebih
lebih mahal besar = kecepatan
aksesnya lebih
lambat
The Memory Hierarchy
 Hirarki menurun: Inb
g-
Re r s
i st
e
e
ch
Me o a r d Ca
mo in
ry M a or y
m
Me

 menurunkan biaya per bit Ou Di


sk
t tic
Sto boar gne OM
M a D- R W
 meningkatkan kapasitas ra g d
e C D -R W
C
D-
R M
D V D- R A y
a
DV lu-R

 meningkatkan waktu B

akses Of
S t o f - li n e
rag ag
ne
tic
Ta
p e

e M

 mengurangi frekuensi
akses ke memori oleh
prosesor
Figure 1.14 The Memory Hierarchy
T1 + T2

T2

Average access time

T1

0 1
Fraction of accesses involving only Level 1 (Hit ratio)

Figure 1.15 Performance of a Simple Two-Level Memory


 Referensi
memori oleh prosesor cenderung
mengelompok
 Data diatur sedemikian rupa sehingga
persentase akses ke setiap tingkat yang
lebih rendah secara berturut-turut jauh lebih
rendah daripada tingkat di atasnya
 Dapat
diterapkan di lebih dari dua tingkat
memori
Secondary
Memory

Juga disebut
sebagai memori
tambahan
• external
• nonvolatile
• digunakan untuk
menyimpan file
program dan data
 Tidak terlihat oleh OS
 Berinteraksi dengan perangkat manajemen memori lainnya
 Prosesor harus mengakses memori setidaknya satu kali
per siklus instruksi
 eksekusi prosesor dibatasi oleh waktu siklus memori
 Eksploitasi prinsip lokalitas dengan memori yang kecil dan
cepat
Block Transfer
Word Transfer

CPU Cache Main Memory


Fast Slow

(a) Single cache

Level 1 Level 2 Level 3 Main


CPU
(L1) cache (L2) cache (L3) cache Memory

Fastest Fast
Less Slow
fast

(b) Three-level cache organization

Figure 1.16 Cache and Main Memory


Line Memory
Number Tag Block address
0 0
1 1
2 2 Block 0
3 (K words)

C-1
Block Length
(K Words)

(a) Cache

Block M – 1

2n - 1
Word
Length
(b) Main memory

Figure 1.17 Cache/Main-Memory Structure


START

RA - read address
Receive address
RA from CPU

Is block No Access main


containing RA memory for block
in cache? containing RA
Yes

Fetch RA word Allocate cache


and deliver slot for main
to CPU memory block

Load main
Deliver RA word
memory block
to CPU
into cache slot

DONE

Figure 1.18 Cache Read Operation


ukuran
cache

jumlah
ukuran
tingkat
blok
cache

Kategori
utama:

Kebijakan fungsi
penulisan pemetaan

algoritma
penggantia
n
Cache and Block Size

ukuran ukuran
cache blok
cache kecil unit data yang
memiliki dampak dipertukarkan
signifikan antara cache dan
terhadap kinerja memori utama
Mapping Function
∗Menentukan lokasi cache
mana yang akan ditempati
oleh blok ketika satu blok dibaca,
yang lain mungkin harus
diganti
Dua kendala yang
mempengaruhi desain:
semakin fleksibel fungsi
pemetaan, semakin
kompleks sirkuit yang
diperlukan untuk mencari
cache
Replacement Algorithm
 Algoritma Least Last Used (LRU)
 strategi yang efektif adalah mengganti blok yang
telah lama di cache tanpa adanya referensi ke blok
tersebut
 mekanisme perangkat keras diperlukan untuk
mengidentifikasi blok yang paling baru digunakan
 memilih blok mana yang akan digantikan/ditindih
ketika blok baru akan dimuat ke cache
Write Policy

Mendikte ketika operasi penulisan memori


berlangsung

• dapat terjadi setiap kali blok diperbarui


• dapat terjadi ketika blok diganti
• meminimalkan operasi tulis
• meninggalkan memori utama dalam keadaan
usang
I/O Techniques
∗ Ketika prosesor bertemu dengan instruksi yang
berkaitan dengan I / O, ia mengeksekusi instruksi itu
dengan mengeluarkan sebuah perintah ke modul I / O
yang sesuai.
Three techniques are possible for I/O
operations:

Programmed Interrupt- Direct Memory


I/O Driven I/O Access (DMA)
Programmed I/O
 ModulI / O melakukan tindakan yang diminta
kemudian menetapkan (set) bit yang sesuai
dalam daftar status I / O
 Prosesor secara berkala memeriksa status
modul I / O sampai menentukan instruksi selesai
 Dengan I / O terprogram, tingkat kinerja seluruh
sistem sangat terdegradasi
Interrupt-Driven I/O
Prosesor Prosesor
mengeluarkan menjalanka
perintah I / O ke n transfer
modul dan kemudian data dan
melanjutkan untuk kemudian
melakukan beberapa melanjutkan
pekerjaan pemrosesan
bermanfaat lainnya sebelumnya

Modul I / O Lebih efisien daripada


kemudian akan Programmed I / O
mengganggu tetapi masih
prosesor untuk memerlukan
meminta layanan intervensi aktif dari
ketika siap untuk prosesor untuk
bertukar data mentransfer data
dengan prosesor antara memori dan
modul I / O
Interrupt-Driven I/O
Drawbacks
 Kecepatan transfer dibatasi oleh kecepatan
yang dapat diuji prosesor dan melayani
suatu perangkat
 Prosesor terikat dalam mengelola transfer
I/O
 sejumlah instruksi harus dijalankan
untuk setiap transfer I/O
Direct Memory Access
(DMA)
∗ Dilakukan oleh modul terpisah pada system bus atau
dimasukkan ke dalam modul I / O

Ketika prosesor ingin membaca atau menulis data, ia


mengeluarkan perintah ke modul DMA yang berisi:
• apakah pembacaan atau penulisan sedang diminta
• alamat perangkat I/O yang terlibat
• lokasi awal dalam memori untuk membaca/menulis
• jumlah kata yang harus dibaca/ditulis
 Mentransfer
seluruh blok data langsung ke
dan dari memori tanpa melalui prosesor
 Prosesor hanya terlibat di awal dan akhir transfer
 Prosesor mengeksekusi lebih lambat selama transfer
ketika akses prosesor ke bus diperlukan

 Lebihefisien daripada I/O yang dipicu oleh


interupsi (interrupt-driven I/O) atau
terprogram (programmed I/O)
Symmetric Multiprocessors
(SMP)
 Sistem komputer yang berdiri sendiri
dengan karakteristik sebagai berikut:
 dua atau lebih prosesor serupa dengan kemampuan yang
sebanding
 prosesor berbagi memori utama yang sama dan saling
terhubung dengan bus atau skema koneksi internal lainnya
 prosesor berbagi akses ke perangkat I / O
 semua prosesor dapat melakukan fungsi yang sama
 sistem dikontrol oleh sistem operasi terintegrasi yang
menyediakan interaksi antara prosesor dan programnya di
tingkat elemen pekerjaan, tugas, file, dan data
Performance Scaling
• sistem dengan banyak • vendor dapat menawarkan
prosesor akan menghasilkan berbagai produk dengan
kinerja yang lebih baik jika harga dan karakteristik
pekerjaan dapat dilakukan kinerja yang berbeda
secara paralel

Availability Incremental Growth


• kegagalan prosesor tunggal • prosesor tambahan dapat
tidak menghentikan mesin ditambahkan untuk
meningkatkan kinerja
Processor Processor Processor
L1 Cache L1 Cache L1 Cache

L2 Cache L2 Cache L2 Cache

System Bus

Main I/O
Memory I/O Adapter
Subsystem

I/O
Adapter

I/O
Adapter

Figure 1.19 Symmetric Multiprocessor Organization


Multicore Computer
 Dikenal jg dengan chip multiprocessor
 Menggabungkan dua atau lebih prosesor
(inti) pada satu bagian silikon
 setiap inti terdiri dari semua komponen2 dari
prosesor independen
 Selain
itu, chip multicore juga menyertakan
cache L2, bahkan dalam beberapa kasus jg
menyertakan L3 cache
Core 0 Core 1 Core 2 Core 3 Core 4 Core 5

32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB 32 kB
L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D L1-I L1-D

256 kB 256 kB 256 kB 256 kB 256 kB 256 kB


L2 Cache L2 Cache L2 Cache L2 Cache L2 Cache L2 Cache

12 MB
L3 Cache

DDR3 Memory QuickPath


Controllers Interconnect

3 8B @ 1.33 GT/s 4 20b @ 6.4 GT/s

Figure 1.20 Intel Core i7-990X Block Diagram


Summary
 Basic Elements  Cache memory
 Motivation
 Evolution of the
microprocessor  Cache principles
 Cache design
 Instruction execution
 Direct memory access
 Interrupts
 Interrupts and the  Multiprocessor and
instruction cycle multicore organization
 Interrupt processing  Symmetric
multiprocessors
 Multiple interrupts
 Multicore computers
 The memory hierarchy

Anda mungkin juga menyukai