Upload
donhu
View
215
Download
0
Embed Size (px)
Citation preview
Sistem Operasi Sistem Operasi 22
“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.CsM.Cs
D fi i i SOD fi i i SODefinisi SODefinisi SOD i d t d • Dari sudut pandang user– Sistem Operasi sebagai alat untuk mempermudah
penggunaan Komputerp 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
berjalan setiap saat pada komputer (Kernel)
L SOL SOLayanan SOLayanan SOUser 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 SOL SOLayanan SOLayanan SO• Communications proses harus • Communications – proses harus
berkomunikasi antar proses dalam komputer yang sama atau antar komputer dalam jaringandalam jaringan– Menggunakan shared memory atau
menggunakan message passingd 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 konsistendengan aksi yang sesuai, benar, dan konsisten– Harus adanya fasilitas debugging
Layanan SOLayanan 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 dmenggunakan 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.
C d Li IC d Li ICommand Line InterpreterCommand Line InterpreterSi 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 modificationshell 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 -- GUIGUI
• User-friendly desktop metaphor interfaceM 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 facesinterfaces– 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)Desktop, KDE)
Si C llSi C llSistem CallsSistem CallsS 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), – Java API for the Java virtual machine (JVM)
Example of System CallsExample of System Callsp yp y• System call sequence to copy the contents of
fil t th filone file to another file
Example of Standard APIExample of Standard APIExample of Standard APIExample 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 iS C ll i l iSystem Call implementationSystem Call implementationTh ll d k thi• The caller need know nothingabout how the system call is
l dimplemented– 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)
Standard C Library ExampleStandard C Library Example• C program invoking printf() library call,
which calls write() system call
S C llS C llSystem CallsSystem CallsTig metode m m ng dig n k n d l m • Tiga metode umum yang digunakan dalam memberikan parameter kepada sistem operasioperasi– Melalui registers
• In some cases, may be more parameters than registersregisters
– Menyimpan parameter dalam block / tabel pada memori dan alamat block tsbdib ik b i t d i tdiberikan 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
Jenis System Calls Jenis System Calls –– System System PPProgramProgram
• Process Control• Manajemen filej• Manajemen Device • Information Maintenance• Information Maintenance• Komunikasi• Proteksi
• Biasanya digunakan pada system programprogram
P C lP C lProcess ControlProcess ControlS 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
M j FilM j FilManajemen FileManajemen File• Membuat dan menghapus file• Membuka dan menutup file• Membuka dan menutup file• Read, write, reposition • Mengambil dan men-set file
attributes attributes
M j D iM j D iManajemen DeviceManajemen Device• Meminta device, melepaskan device• Read write reposition• Read, write, reposition• Mengambil dan men-set device
tt ib tattributes• Logically attach or detach device Logically attach or detach device
(mount / umount)
I f i M iI f i M iInformation MaintenanceInformation Maintenance• Mengambil dan men-set waktu dan
tanggalgg• Men-set proses, file, or device
attributesattributes
K ik iK ik iKomunikasiKomunikasi• Menciptakan, menghapus hubungan
komunikasi• Mengirim dan menerima pesan
M t f t t i f i• Mentransfer status informasi• Attach atau detach remote deviceAttach atau detach remote device• Komunikasi dapat dilakukan melalui
message passing ata shared message passing atau shared memory
S k Si O iS k Si O iStruktur Sistem OperasiStruktur Sistem OperasiSt 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
Layered Operating SystemLayered Operating Systemy p g yy p g y
• Layer adalah implementasi• Layer adalah implementasi dari object abstrak yang merupakan enkapsulasi darip pdata dan operasi yang bisamemanipulasi data tersebut• Layer paling bawah : hardware
L li t• Layer paling atas : user interface
L d OSL d OSLayered OSLayered OSK • 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 lMik k lMikrokernelMikrokernelF 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 modifkernel tidak perlu di modif
– mendukung keamanan reliabilitas lebih, karena sebagian besar pada level pengguna, SO jadi terjaga
• Contoh sistem operasi :– Tru64 UNIX, MacOSX, QNX
M d lM d lModulesModules• 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
Vi l M hiVi l M hiVirtual MachineVirtual 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 ( ) pysemua hal yang ada pada komputer
• VM dibuat dengan pembagian sumber daya oleh physical computer
• VM ada 2: system VM dan application VM
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 printersreaders 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 diskspooling, yaitu sebuah virtual disk
Virtual Machines History and BenefitsVirtual Machines History and Benefits
• First appeared commercially in IBM mainframes i 1972in 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 networkingU 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 VMK VMKeuntungan VMKeuntungan 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
KK lili VMVMKKesulitanesulitan VMVMVM lit dii l t ik k b k t • VM sulit diimplementasikan karena banyak syarat yang dibutuhkan untuk menyediakan duplikat yang tepat dari mesin hostya 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
(a) Nonvirtual machine (b) virtual machine
J Vi l M hiJ Vi l M hiJava Virtual MachineJava 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
Flow Chart of BIOS FunctionsFlow Chart of BIOS FunctionsTurn on Computer Post = power on self test
Pass through POST Error FreeYES
NO Output to Monitor
Plug’n’Play
YES
Pass through POST Error Test Boot Drive
Bootable media found NO
gFree
Pass through POST Error Free
YES
NO
Load boot programPass through POST Error
Free
YES
Start operating system
B l dB l dBootstrap loaderBootstrap 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 itstarts it
– boot block at fixed location loads bootstrap loaderloader
– When power initialized on system, execution starts at a fixed memory locationstarts at a fixed memory location• Firmware used to hold initial boot code