sistem operasi 2 - lecturer.ukdw.ac.idlecturer.ukdw.ac.id/anton/download/so2.pdf · • so...

50
Sistem Operasi Sistem Operasi 2 2 “Sistem operasi” “Sistem operasi” Antonius Rachmat C, S.Kom, Antonius Rachmat C, S.Kom, M.Cs M.Cs

Upload: duongnga

Post on 16-Mar-2019

237 views

Category:

Documents


0 download

TRANSCRIPT

Sistem Operasi Sistem Operasi 2222

“Sistem operasi”“Sistem operasi”

Antonius Rachmat C, S.Kom, Antonius Rachmat C, S.Kom, M.CsM.Cs

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)

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.

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 hardware dan software– Untuk setiap error, OS harus menanganinya

dengan aksi yang tepat dan konsisten– Harus adanya fasilitas debugging

DebuggingDebugging

Layanan SOLayanan SO

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

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

• Protection and security– Protection meyakinkan hak akses yang

diperbolehkan dari dalam sistem

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

A View of Operating System A View of Operating System ServicesServices

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.

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 menggunakan gabungan 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)

Command InterpreterCommand Interpreter

The Mac OS X GUIThe Mac OS X GUI

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

Example of System CallsExample of System Calls

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

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

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

–Ex: http://syscalls.kernelgrok.com/

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

Standard C Library ExampleStandard C Library Example

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

Parameter Parameter 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

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

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

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

MSMS--DOS DOS process process executionexecution

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

LinuxLinux Running Multiple ProgramsRunning Multiple Programs

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

Manajemen DeviceManajemen Device• Meminta device, melepaskan device

• Read, write, reposition

• Mengambil dan men-set device attributes

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

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

• Men-set proses, file, or device attributes

• Menampilkan informasi tentang sistem

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

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– Fungsi-fungsi dibagi per modul

MSMS--DOS Layer StructureDOS Layer Structure

Traditional UNIX System StructureTraditional UNIX System Structure

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

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

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 modifikasi

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

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

Monolithic vs MicrokernelMonolithic vs Microkernel

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

Solaris Modular ApproachSolaris Modular Approach

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

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

Keuntungan VMKeuntungan VM

• Keamanan

• Kemudahan instalasi

• Cocok digunakan dalam penelitian dan percobaandan percobaan

• Mendukung green computing

• Murah

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 spesifikasi yang cukup tinggi

Virtual Machines (Cont)Virtual Machines (Cont)

Non-virtual Machine Virtual Machine

(a) Nonvirtual machine (b) virtual machine

Solaris 10 with Two ContainersSolaris 10 with Two Containers

VMware ArchitectureVMware Architecture

VMWareVMWare

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

The Java Virtual MachineThe Java Virtual Machine

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

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

NEXTNEXT

• Process