Sistem Operasi
Sistem Operasi
2
2
“Sistem operasi”
“Sistem operasi”
Antonius Rachmat C S Kom
Antonius Rachmat C S Kom
Antonius Rachmat C, S.Kom,
Antonius Rachmat C, S.Kom,
M.Cs
M.Cs
D fi i i SO
D fi i i SO
Definisi SO
Definisi SO
D i d t d
• Dari sudut pandang user
– Sistem Operasi sebagai alat untuk mempermudah penggunaan Komputer
p gg p
– Sistem Operasi sebagai alat untuk memaksimalkan penggunaan sumber daya komputer (dalam lingkungan multi-user))
• Dari sudut pandang sistem
– Sistem Operasi sebagai alat yang menempatkan sumber da a se a a efisien (Reso ce Allocato )
daya secara efisien (Resource Allocator)
– Sistem Operasi sebagai alat yang mangatur eksekusi aplikasi dan operasi dari alat I/O (Control Program) – Sistem Operasi sebagai sebuah program yang selalu
L
SO
L
SO
Layanan SO
Layanan SO
User interface hampir semua SO ada GUI nya • User interface – hampir semua SO ada GUI-nya
– Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch
• Program execution – SO harus bisa meload program ke memory dan mengeksekusinya, menghentikan eksekusi program, baik normal menghentikan eksekusi program, baik normal maupun tidak normal (abnormal exit)
• I/O operations - Program yang sedang
berjalan butuh I/O baik mengakses file ataupun berjalan butuh I/O, baik mengakses file ataupun I/O device
• File-system manipulation - Programs butuh d d it b ik fil t di t i t read dan write baik file atau directories, create dan delete, search file/dir, list file information, dan permission management.
L
SO
L
SO
Layanan SO
Layanan SO
• Communications
proses harus
• Communications – proses harus
berkomunikasi antar proses dalam
komputer yang sama atau antar komputer
dalam jaringan
dalam jaringan
– Menggunakan shared memory atau menggunakan message passing
d
i
h
• Error detection – harus mampu
menangani error
– Dalam terjadi pada CPU, memory hardware, Dalam terjadi pada CPU, memory hardware, dalam I/O devices, dan dalam user program – Untuk setiap error, OS harus menanganinya
dengan aksi yang sesuai, benar, dan konsisten dengan aksi yang sesuai, benar, dan konsisten – Harus adanya fasilitas debugging
Layanan SO
Layanan SO
• Resource allocation – ketika multiple
t
lti l j b b j l
users atau multiple jobs berjalan
bersama-sama (concurent), resources
harus dialokasikan
harus dialokasikan
• Accounting – menentukan berapa
banyak dan berapa lama users
k
b
d
menggunakan sumber daya sistem
• Protection and security
P t ti ki k h k k
– Protection menyakinkan hak akses yang diperbolehkan
– Security sistem, baik program atau I/O y , p g / dari pihak luar menggunakan autentikasi.
A View of Operating System
A View of Operating System
Se ices
Se ices
Services
Services
C
d Li
I
C
d Li
I
Command Line Interpreter
Command Line Interpreter
Si tem Ope
i men ngg in t k i d i
• Sistem Operasi menunggu instruksi dari
pengguna (command driven).
– Sometimes commands built-in sometimes just Sometimes commands built in, sometimes just names of programs
• If the latter, adding new features doesn’t require shell modification
shell modification
• CLI: Program yang membaca instruksi
dan mengartikan control statements
g
(keinginan user) umumnya disebut:
– control-card interpreter command line inte p ete – command-line interpreter – UNIX shell.
User Operating System Interface
User Operating System Interface -- GUI
GUI
• User-friendly desktop metaphor interface
M k k b d d it
– Menggunakan mouse, keyboard, and monitor
– Icons merepresentasikan files, programs, actions, dll – Menggunakan directory = foldergg y
– Invented at Xerox PARC
• SO sekarang menggunakan antara CLI dan GUI inte faces
interfaces
– Microsoft Windows is GUI with CLI “command” shell – Apple Mac OS X as “Aqua” GUI interface with UNIX pp q
kernel underneath and shells available
– Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
Command Interpreter
Command Interpreter
p
p
The Mac OS X GUI
The Mac OS X GUI
The Mac OS X GUI
The Mac OS X GUI
Si
C ll
Si
C ll
Sistem Calls
Sistem Calls
S t ll di k i t f t
• System calls menyediakan interface antara proses (program yang sedang dijalankan) dan sistem operasi.
s ste ope as
• Biasanya dibuat menggunakan bahasa tingkat
tinggi (C or C++)
• Diakses menggunakan Application Program
Interface (API) daripada pemanggilan langsung • 3 API yang umum adalah:
• 3 API yang umum adalah:
– Win32 API for Windows,
– POSIX API for POSIX-based systems (including virtually y ( g y all versions of UNIX, Linux, and Mac OS X),
Example of System Calls
Example of System Calls
p
p
y
y
• System call sequence to copy the contents of fil t th fil
Example of Standard API
Example of Standard API
Example of Standard API
Example of Standard API
• Consider the ReadFile() function in the
Win32 API a function for reading from a file • Win32 API—a function for reading from a file
A desc iption of the pa amete s passed to ReadFile() • A description of the parameters passed to ReadFile()
– HANDLE file—the file to be read
– LPVOID buffer—a buffer where the data will be read into and written from
– DWORD bytesToRead—the number of bytes to be read into the buffer – LPDWORD bytesRead—the number of bytes read during the last read – LPOVERLAPPED ovl—indicates if overlapped I/O is being used
S
C ll i
l
i
S
C ll i
l
i
System Call implementation
System Call implementation
Th ll d k
thi
• The caller need know nothing
about how the system call is
l
d
implemented
– Just needs to obey API and understand
y
what OS will do as a result call
– Most details of OS interface hidden
from programmer by API
• Managed by run-time support library (set f f ti b ilt i t lib i i l d d ith of functions built into libraries included with compiler)
API
Standard C Library Example
Standard C Library Example
• C program invoking printf() library call,
which calls write() system call
S
C ll
S
C ll
System Calls
System Calls
Tig metode m m ng dig n k n d l m
• Tiga metode umum yang digunakan dalam
memberikan parameter kepada sistem
operasi
operasi
– Melalui registers
• In some cases, may be more parameters than registers
registers
– Menyimpan parameter dalam block / tabel
pada memori dan alamat block tsb
dib ik b i t d i t
diberikan sebagai parameter pada register
• This approach taken by Linux and Solaris
– Menyimpan parameter (push) ke dalam stacke y pa pa a ete (pus ) e da a stac
(oleh program), dan melakukan pop off pada stack (oleh sistem operasi)
• Sifatnya dinamis • Sifatnya dinamis
P
P
i
i T bl
P
P
i
i T bl
Parameter Passing via Table
Parameter Passing via Table
Jenis System Calls
Jenis System Calls –
– System
System
PPProgram
Program
• Process Control
• Manajemen file
j
• Manajemen Device
• Information Maintenance
• Information Maintenance
• Komunikasi
• Proteksi
• Biasanya digunakan pada system
program
program
Examples of Windows and
Examples of Windows and
Unix System Calls
Unix System Calls
yy
P
C
l
P
C
l
Process Control
Process Control
S l
i b
• Selesai, abort
• Load, eksekusi
,
• Membuat dan men-terminate proses
• Mengambil dan men set process
• Mengambil dan men-set process
attributes
f
• Wait for time
• Wait event, signal event
, g
• Allocate and free memory
MS
MS DOS i
DOS i
MS
MS--DOS execution
DOS execution
FreeBSD Running Multiple Programs
FreeBSD Running Multiple Programs
M
j
Fil
M
j
Fil
Manajemen File
Manajemen File
• Membuat dan menghapus file
• Membuka dan menutup file
• Membuka dan menutup file
• Read, write, reposition
• Mengambil dan men-set file
attributes
M
j
D i
M
j
D i
Manajemen Device
Manajemen Device
• Meminta device, melepaskan device
• Read write reposition
• Read, write, reposition
• Mengambil dan men-set device
tt ib t
attributes
• Logically attach or detach device
Logically attach or detach device
(mount / umount)
I f
i
M i
I f
i
M i
Information Maintenance
Information Maintenance
• Mengambil dan men-set waktu dan
tanggal
gg
• Men-set proses, file, or device
attributes
K
ik i
K
ik i
Komunikasi
Komunikasi
• Menciptakan, menghapus hubungan
komunikasi
• Mengirim dan menerima pesan
M
t
f
t t i f
i
• Mentransfer status informasi
• Attach atau detach remote device
Attach atau detach remote device
• Komunikasi dapat dilakukan melalui
message passing ata shared
message passing atau shared
memory
S
k
Si
O
i
S
k
Si
O
i
Struktur Sistem Operasi
Struktur Sistem Operasi
St kt S d h
• Struktur Sederhana
– Tidak dibagi dalam modul-modul – Contoh : Struktur sistem MS-DOS:Contoh : Struktur sistem MS DOS:
• disusun untuk mendukung fungsi yang banyak pada space yang kecil
• Metode pendekatan Layer / Level • Metode pendekatan Layer / Level
– Contoh: UNIX, terdiri dari kernel (berisi device driver dan interface) dan program
• Mikrokernel
– Menyusun sistem operasi dengan menghapus semua komponen yang tidak esensial dari kernel, dan
komponen yang tidak esensial dari kernel, dan
mengimplementasikannya sebagai sistem program pada user-level
• Modular • Modular
MS
MS DOS L
DOS L
S
S
MS
Traditional UNIX System Structure
Traditional UNIX System Structure
Layered Operating System
Layered Operating System
y
y
p
p
g y
g y
•
Layer adalah implementasi•
Layer adalah implementasi dari object abstrak yangmerupakan enkapsulasi darip p data dan operasi yang bisa memanipulasi data tersebut
•
Layer paling bawah : hardwareL li t
•
Layer paling atas : user interfaceL
d OS
L
d OS
Layered OS
Layered OS
K
• Keuntungan:
– modularitas
– mempermudah debug dan verifikasi
sistem
– layer pertama bisa didebug tanpa
mengganggu sistem yang lain
• Kesulitan:
– hanya bisa menggunakan layer
hanya bisa menggunakan layer
dibawahnya
Mik k
l
Mik k
l
Mikrokernel
Mikrokernel
F i t d k f ilit k ik i • Fungsi utama: mendukung fasilitas komunikasi
antara program user dan bermacam-macam layanan yang juga berjalan di user-spaceaya a ya g juga be ja a d use space
• Kernel menjadi lebih kecil
• Komunikasi melalui message passingg p g • Keuntungan:
– ketika layanan baru akan ditambahkan ke user-space, kernel tidak perlu di modif
kernel tidak perlu di modif
– mendukung keamanan reliabilitas lebih, karena sebagian besar pada level pengguna, SO jadi terjaga
• Contoh sistem operasi :
M
li hi
Mi
k
l
M
li hi
Mi
k
l
Monolithic vs Microkernel
Monolithic vs Microkernel
M d l
M d l
Modules
Modules
• Most modern operating systems
implement kernel modules
– Uses object-oriented approach – Each core component is separate
– Each talks to the others over known
interfaces
– Each is loadable as needed within the kernel
• Overall, similar to layers but with more
flexible
S l i M d l A
h
S l i M d l A
h
Solaris Modular Approach
Solaris Modular Approach
Vi
l M hi
Vi
l M hi
Virtual Machine
Virtual Machine
• Mesin virtual mengambil pendekatan layer secara logika • Mesin virtual mengambil pendekatan layer secara logika. • Mesin virtual memperlakukan hardware dan sistem operasi
seolah-olah berada pada level yang sama sebagai hardware
hardware.
• Pendekatan Mesin virtual menyediakan sebuah interface yang identik dengan seluruh hardware yang ada.
• Sistem Operasi host membuat ilusi dari banyak proses • Sistem Operasi host membuat ilusi dari banyak proses,
masing-masing dieksekusi pada prosesornya sendiri dengan virtual memorinya sendiri.
• Setiap guest menyediakan sebuah (virtual) copy dari p g y ( ) py semua hal yang ada pada komputer
• VM dibuat dengan pembagian sumber daya oleh physical computer
Vi
l M hi
(2)
Vi
l M hi
(2)
Virtual Machine (2)
Virtual Machine (2)
S mbe d
fi ik dib gi oleh VM nt k
• Sumber daya fisik dibagi oleh VM untuk:
– Penjadwalan CPU bisa menciptakan
penampilan seakan user mempunyai prosesor penampilan seakan user mempunyai prosesor sendiri
– Spooling bisa menyediakan virtual card readers dan virtual line printers
readers dan virtual line printers
– Sebuah time-sharing terminal, yang dapat melayani user dengan tepat
• VM software membutuhkan disk space
untuk menyediakan Virtual memory dan
spooling yaitu sebuah virtual disk
Virtual Machines History and Benefits
Virtual Machines History and Benefits
• First appeared commercially in IBM mainframes i 1972
in 1972
• Fundamentally, multiple execution
environments (different operating systems) can environments (different operating systems) can
share the same hardware • Protect from each other VM
• Commutate with each other, other physical systems via networking
U f l f d l i • Useful for development, testing
• “Open Virtual Machine Format”, standard format of virtual machines allows a VM to run within of virtual machines, allows a VM to run within many different virtual machine (host) platforms
K
VM
K
VM
Keuntungan VM
Keuntungan VM
• Keamanan bukanlah masalah
– VM mempunyai pelindungan lengkap pada berbagai sistem sumber daya
– Tidak ada pembagian sumber daya secara llangsung
• VM sistem adalah kendaraan yang
“
”
k
l
d
“sempurna” untuk penelitian dan
pengembangan sistem operasi
– Dengan VM perubahan suatu bagian tidak akan mempengaruhi komponen yang lain
K
K
lili
VM
VM
K
Kesulitan
esulitan VM
VM
VM lit dii l t ik k b k t • VM sulit diimplementasikan karena banyak syarat
yang dibutuhkan untuk menyediakan duplikat yang tepat dari mesin host
ya g tepat da es ost
– Harus punya virtual-user mode dan virtual-monitor mode yang keduanya berjalan di pysichal mode.
Akibatnya saat instruksi yang hanya membutuhkan – Akibatnya, saat instruksi yang hanya membutuhkan
virtual monitor mode dijalankan, register berubah dan bisa berefek pada virtual user mode, bahkan bisa me-restart VM
restart VM
• Waktu yang dibutuhkan I/O bisa lebih
cepat(karena ada spooling), tapi bisa lebih lambat (karena diinterpreted)
Virtual Machines (Cont)
Virtual Machines (Cont)
Virtual Machines (Cont)
Virtual Machines (Cont)
Non-virtual Machine Virtual Machine
VMware Architecture
VMware Architecture
VMWare
VMWare
J
Vi
l M hi
J
Vi
l M hi
Java Virtual Machine
Java Virtual Machine
• Program Java yang telah dicompile adalah
platform-neutral bytecodes yang
dieksekusi oleh Java Virtual Machine(JVM)
• JVM terdiri dari:
– Class loader
– Class verificatier – runtime interpreter
• Just In-Time(JIT) compilers meningkatkan
Just In Time(JIT) compilers meningkatkan
performance
Th J
Vi
l M hi
Th J
Vi
l M hi
The Java Virtual Machine
The Java Virtual Machine
Flow Chart of BIOS Functions
Flow Chart of BIOS Functions
Turn on Computer Post = power on self test
Pass through POST Error Free
YES
NO Output to Monitor
Plug’n’Play YES
Pass through POST Error Test Boot Drive
Bootable media found NO
g Free
Pass through POST Error Free
YES
NO
Load boot program Pass through POST Error Free YES
B
l d
B
l d
Bootstrap loader
Bootstrap loader
• Operating system must be made available
to hardware, so hardware can start it
– Small piece of code – bootstrap loader,
locates the kernel, loads it into memory, and t t it
starts it
– boot block at fixed location loads bootstrap loader
loader
– When power initialized on system, execution starts at a fixed memory location
starts at a fixed memory location