struktur os, sys call & vm

49
Aditya Wikan Mahastama Aditya Wikan Mahastama Antonius Rachmat C Antonius Rachmat C Sistem Operasi Sistem Operasi Struktur Sistem Operasi Struktur Sistem Operasi System Call System Call Virtual Machine Virtual Machine

Upload: tranphuc

Post on 13-Feb-2017

246 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Struktur OS, Sys Call & VM

Aditya Wikan MahastamaAditya Wikan Mahastama Antonius Rachmat CAntonius Rachmat C

Sistem OperasiSistem OperasiStruktur Sistem OperasiStruktur Sistem OperasiSystem CallSystem CallVirtual MachineVirtual Machine

Page 2: Struktur OS, Sys Call & VM

Definisi SODefinisi SO• Dari sudut pandang user

– Sistem Operasi sebagai alat untuk mempermudahpenggunaan Komputer

– Sistem Operasi sebagai alat untuk memaksimalkanpenggunaan sumber daya komputer (dalam lingkungan multi-user)multi-user)

• Dari sudut pandang sistem– Sistem Operasi sebagai alat yang menempatkan sumber daya secara efisien (Resource Allocator)

– Sistem Operasi sebagai alat yang mangatur eksekusi program dan operasi dari alat I/O (Control Program)

– Sistem Operasi sebagai sebuah program yang selalu berjalan setiap saat pada komputer (Kernel)

Page 3: Struktur OS, Sys Call & VM

Layanan SOLayanan SO• User interface

– Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch

• Program execution – SO harus bisa meload program ke memory dan mengeksekusinya, menghentikan eksekusi programmenghentikan eksekusi program

• I/O operations - program yang sedang berjalan butuh I/O, baik mengakses file ataupun I/O device

• File-system manipulation - programs butuh read dan write baik file atau directories, create dan delete, search file/dir, list file information, dan permission management.

Page 4: Struktur OS, Sys Call & VM

Layanan SOLayanan SO• Communications – proses harus berkomunikasi antar proses dalam komputer yang sama atau antar komputer dalam jaringan– shared memory / message passing

• Error detection – harus mampu menangani error

• Error detection – harus mampu menangani error– Bisa terjadi pada CPU, memory hardware, dalam I/O devices, dan dalam user program

– Untuk setiap error, OS harus menanganinya dengan aksi yang tepat dan konsisten

– Harus adanya fasilitas debugging

Page 5: Struktur OS, Sys Call & VM

Layanan SOLayanan SO

• Resource allocation – ketika multiple users atau multiple jobs berjalan bersama-sama (concurrent), resources harus dialokasikan

• Accounting – menentukan berapa penggunaan sumber daya sistempenggunaan sumber daya sistem

• Protection and security– Protection meyakinkan hak akses yang diperbolehkan

– Security sistem, baik program atau I/O dari pihak luar menggunakan autentikasi.

Page 6: Struktur OS, Sys Call & VM

A View of Operating System A View of Operating System ServicesServices

Page 7: Struktur OS, Sys Call & VM

Command Line InterpreterCommand Line Interpreter

• Sistem Operasi menunggu instruksi dari pengguna (command driven).

– Sometimes commands built-in, sometimes just names of programs

• CLI: Program yang membaca instruksi dan • CLI: Program yang membaca instruksi dan mengartikan control statements (keinginan user) umumnya disebut:

– command-line interpreter

– UNIX shell.

Page 8: Struktur OS, Sys Call & VM

User Operating System Interface User Operating System Interface -- GUIGUI

• User-friendly desktop metaphor interface– Menggunakan mouse, keyboard, and monitor

– Icons merepresentasikan files, programs, actions, dll

– Menggunakan directory = folder

– Invented at Xerox PARC

• SO sekarang menggunakan antara CLI dan GUI interfacesinterfaces– Microsoft Windows is GUI with CLI “command” shell

– Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available

– Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

Page 9: Struktur OS, Sys Call & VM

Command InterpreterCommand Interpreter

Page 10: Struktur OS, Sys Call & VM

The Mac OS X GUIThe Mac OS X GUI

Page 11: Struktur OS, Sys Call & VM
Page 12: Struktur OS, Sys Call & VM

Sistem CallsSistem Calls• System calls menyediakan interface/penghubung antara proses dan sistem operasi.

• Biasanya dibuat menggunakan bahasa tingkat tinggi (C or C++)

• Diakses menggunakan Application Program • Diakses menggunakan Application Program Interface (API) daripada pemanggilan langsung

• 3 API yang umum adalah: – Win32 API for Windows, – POSIX API for POSIX-based systems (UNIX, Linux, and Mac OS X),

– Java API for the Java virtual machine (JVM)– .NET API

Page 13: Struktur OS, Sys Call & VM

Example of System CallsExample of System Calls

• System call sequence to copy the contents of one file to another file

Page 14: Struktur OS, Sys Call & VM

Example of Standard APIExample of Standard API• Consider the ReadFile() function in the• Win32 API—a function for reading from a file

• 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

Page 15: Struktur OS, Sys Call & VM

System Call implementationSystem Call implementation

• The caller need know nothingabout how the system call is implemented– Just needs to obey API and understand what OS will do as a

– Just needs to obey API and understand what OS will do as a result call

–Most details of OS interface hiddenfrom programmer by API •Managed by run-time support library

Page 16: Struktur OS, Sys Call & VM

API API –– System Call System Call –– OS RelationshipOS Relationship

Page 17: Struktur OS, Sys Call & VM

Standard C Library ExampleStandard C Library Example

• C program invoking printf() library call, which calls write() system call

Page 18: Struktur OS, Sys Call & VM

System CallsSystem Calls• Tiga metode untuk memberikan parameter dari program ke SO:– Melalui registers

• Parameters > registers

– Menyimpan parameter dalam block / tabel pada memori dan alamat block tsbpada memori dan alamat block tsbdiberikan sebagai parameter pada register• This approach taken by Linux and Solaris

– Menyimpan parameter (push) ke dalam stack(oleh program), dan melakukan pop off pada stack (oleh sistem operasi)• Sifatnya semi dinamis

Page 19: Struktur OS, Sys Call & VM

Examples of Windows and Examples of Windows and Unix System CallsUnix System Calls

Page 20: Struktur OS, Sys Call & VM

Jenis System Calls Jenis System Calls –– System System ProgramProgram

• Process Control

• Manajemen file

• Manajemen device

• Komunikasi• Komunikasi

• Information management

• Proteksi

• Biasanya digunakan pada system program

Page 21: Struktur OS, Sys Call & VM

Process ControlProcess Control• Selesai, abort

• Load, eksekusi

• Membuat dan men-terminate proses

• Mengambil dan men-set process • Mengambil dan men-set process attributes

• Wait for time

• Wait event, signal event

• Allocate and free memory

Page 22: Struktur OS, Sys Call & VM

MSMS--DOS DOS process process executionexecution

(a) At system startup (b) running a program

Page 23: Struktur OS, Sys Call & VM

LinuxLinux Running Multiple ProgramsRunning Multiple Programs

Page 24: Struktur OS, Sys Call & VM

Manajemen FileManajemen File• Membuat dan menghapus file

• Membuka dan menutup file

• Read, write, reposition

• Mengambil dan men-set file attributes • Mengambil dan men-set file attributes

Page 25: Struktur OS, Sys Call & VM

Manajemen DeviceManajemen Device• Meminta device, melepaskan device

• Read, write, reposition

• Mengambil dan men-set device attributes

• Logically attach or detach device (mount / umount)umount)

Page 26: Struktur OS, Sys Call & VM

Information MaintenanceInformation Maintenance• Mengambil dan men-set waktu dan tanggal

• Men-set proses, file, or device attributes

• Menampilkan informasi tentang sistem

Page 27: Struktur OS, Sys Call & VM

KomunikasiKomunikasi• Menciptakan, menghapus hubungan komunikasi

• Mengirim dan menerima pesan• Mentransfer status informasi• Attach atau detach remote device• Komunikasi dapat dilakukan melalui • Komunikasi dapat dilakukan melalui message passing atau shared memory

Page 28: Struktur OS, Sys Call & VM

Struktur Sistem OperasiStruktur Sistem Operasi• Struktur Sederhana

– Tidak dibagi dalam modul-modul

– Contoh : Struktur sistem MS-DOS:

• Metode pendekatan Layer / Level– Contoh: UNIX, terdiri dari kernel (berisi device driver dan interface) dan programdan interface) dan program

• Mikrokernel– Menyusun sistem operasi dengan menghapus semua komponen yang tidak esensial dari kernel, dan mengimplementasikannya sebagai sistem program pada user-level

• Modular– Dibagi per modul

Page 29: Struktur OS, Sys Call & VM

MSMS--DOS Layer StructureDOS Layer Structure

Page 30: Struktur OS, Sys Call & VM

Traditional UNIX System StructureTraditional UNIX System Structure

Page 31: Struktur OS, Sys Call & VM

Layered Operating SystemLayered Operating System

• Layer adalah implementasi dari object abstrak yang merupakan enkapsulasi daridata dan operasi yang bisa memanipulasimemanipulasidata tersebut• Layer paling bawah : hardware• Layer paling atas : user interface

Page 32: Struktur OS, Sys Call & VM

Layered OSLayered OS

• Keuntungan: –Menerapkan modularitas

–mempermudah debug dan verifikasi sistem

– layer pertama bisa didebug tanpa mengganggu sistem yang lain

• Kesulitan:–hanya bisa menggunakan service dari layer dibawahnya

Page 33: Struktur OS, Sys Call & VM

MikrokernelMikrokernel• Fungsi utama: mendukung fasilitas komunikasi antara program user dan bermacam-macam layanan yang juga berjalan di user-space

• Kernel menjadi lebih kecil

• Komunikasi dilakukan melalui message passing• Komunikasi dilakukan melalui message passing

• Keuntungan:– ketika layanan baru akan ditambahkan ke user-space, kernel tidak perlu di modif

– mendukung keamanan reliabilitas lebih, karena sebagian besar pada level pengguna, SO jadi terjaga

• Contoh sistem operasi :– Tru64 UNIX, MacOSX, QNX

Page 34: Struktur OS, Sys Call & VM

Monolithic vs MicrokernelMonolithic vs Microkernel

Page 35: Struktur OS, Sys Call & VM

ModulesModules

• 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

Page 36: Struktur OS, Sys Call & VM

Solaris Modular ApproachSolaris Modular Approach

Page 37: Struktur OS, Sys Call & VM

Virtual MachineVirtual Machine• Mesin virtual mengambil pendekatan layer secara logika. • Mesin virtual memperlakukan hardware dan sistem operasi

seolah-olah berada pada level yang sama sebagai 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 semua hal yang ada pada komputer

• VM dibuat dengan pembagian sumber daya oleh physical computer

• VM ada 2: system VM dan application VM

Page 38: Struktur OS, Sys Call & VM

Virtual Machines History and BenefitsVirtual Machines History and Benefits

• First appeared commercially in IBM mainframes in 1972

• Fundamentally, multiple execution environments (different operating systems) can share the same hardware

• Protect from each other VM• Protect from each other VM

• Commutate with each other, other physical systems via networking

• Useful for development, testing

• Using “Open Virtual Machine Format”, standard format of virtual machines, allows a VM to run within many different virtual machine (host) platforms

Page 39: Struktur OS, Sys Call & VM

Keuntungan VMKeuntungan VM

• Keamanan

• Kemudahan instalasi

• Cocok digunakan dalam penelitian dan percobaandan percobaan

• Mendukung green computing

• Murah

Page 40: Struktur OS, Sys Call & VM

Kerugian VMKerugian VM

• Waktu yang dibutuhkan I/O bisa lebih cepat (karena ada spooling), tapi bisa lebih lambat (karena diinterpreted)diinterpreted)

• Tidak semua aplikasi kompatible

• Membutuhkan hardware dengan spek yang cukup tinggi

Page 41: Struktur OS, Sys Call & VM

Virtual Machines (Cont)Virtual Machines (Cont)

Non-virtual Machine Virtual Machine

(a) Nonvirtual machine (b) virtual machine

Page 42: Struktur OS, Sys Call & VM

Solaris 10 with Two ContainersSolaris 10 with Two Containers

Page 43: Struktur OS, Sys Call & VM

VMware ArchitectureVMware Architecture

Page 44: Struktur OS, Sys Call & VM

VMWareVMWare

Page 45: Struktur OS, Sys Call & VM

Java Virtual MachineJava Virtual Machine

• Program Java yang telah dicompile adalah platform-neutral bytecodes yang dieksekusi oleh Java Virtual Machine(JVM)

• JVM terdiri dari:• JVM terdiri dari:

– Class loader

– Class verificatier

– runtime interpreter

• Mendukung Just In-Time (JIT) compilers yang meningkatkan performance

Page 46: Struktur OS, Sys Call & VM

The Java Virtual MachineThe Java Virtual Machine

Page 47: Struktur OS, Sys Call & VM

Bootstrap 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 locates the kernel, loads it into memory, and starts it

– boot block at fixed location loads bootstrap loader

– When power initialized on system, execution starts at a fixed memory location

• Firmware used to hold initial boot code

Page 48: Struktur OS, Sys Call & VM

Flow Chart of BIOS FunctionsFlow Chart of BIOS Functions

Pass through POST Error Free

Plug’n’Play

Test Boot Drive

Turn on Computer

YES

NO Output to Monitor

Pass through POST Error

Post = power on self test

Test Boot Drive

Bootable media found

Load boot program

Start operating system

NO

Pass through POST Error Free

Pass through POST Error Free

Pass through POST Error Free

YES

NO

Page 49: Struktur OS, Sys Call & VM

NEXTNEXT

• Process & Thread