Process Synchronization

dokumen-dokumen yang mirip
Bab 6: Sinkronisasi Proses. Latar Belakang

Proses Sinkronisasi. Latar Belakang Masalah Critical Section Sinkronisasi Hardware Semaphores Monitors

7 Sinkronisasi. Proses Sinkronisasi. Overview (1) Overview (2) Latar Belakang Masalah Critical Section Sinkronisasi Hardware Semaphores Monitors

Bab 5. Sinkronisasi Proses POKOK BAHASAN: TUJUAN BELAJAR: 5.1 LATAR BELAKANG

Sekolah Tinggi Teknologi Adisutjipto Yogyakarta

Monitor. Process Synchronization. SISTIM OPERASI (IKI-20230) ProcessSynchronization Ch. 6. Johny Moningka

Process Synchronization (Background)

Sistem Operasi Komputer. Pertemuan VI Proses Sinkronisasi

BAB 4. SINKRONISASI & DEADLOCK

B. Jawablah dengan ringkas dan lengkap. (Jawaban tidak lebih dari 10 kalimat) (Nilai 40) Solusi: kata kunci dalam huruf miring.

CRITICAL REGIONS DAN MONITORS

Concurrency 1 : Mutual Exclusion dan Sinkronisasi (P ( e P rtemuan ua ke-9) 9 September 2014

The Critical Section Problem Algorithm III

Paralel processing Benefits Job level Process level Thread level

The Critical Section Problem Algorithm III. Muhammad Fikry Hazmi (143) Kresna Ridwan (145) Guntur Kondang Prakoso (153)

Apa yang akan dipelajari?

Analisis Penerapan Semaphore dalam Mengatasi Masalah Sinkronisasi Dining Philosophers.

Sinkronisasi dan Deadlock Sistem Operasi

Masalah Deadlock. Contoh Persimpangan Jalan. Resource-Allocation Graph. Deadlock

Pertemuan #3: Sinkronisasi dan Deadlock

PROSES & THREADS 2 AGUS PAMUJI. SISTEM OPERASI - Proses & Threads

two/more processor operate in unison.

Sinkronisasi dan Deadlock

Critical Section Mutual Exclusion Semaphore Tugas. Sinkronisasi Thread. Praktikum Sistem Operasi. Ilmu Komputer IPB. Sinkronisasi Thread

Sistem Operasi Pertemuan 5 Concurrency: Mutual Exclusion & Synchronization

Laporan Tugas Scheduling Pengantar Sistem Operasi

Bab 22. Perangkat Sinkronisasi II

Processes. Processes. SISTIM OPERASI (Operating System) IKI-20230

T UGAS STUDI KASUS SISTEM OPERASI. Mutual Exclusion. Mata Kuliah : Sistem Operasi [ CF 1322] Disusun Oleh :

Virtual Memory Ch. 9. Virtual Memory. SISTIM OPERASI (Operating System) IKI Johny Moningka

Sekolah Tinggi Teknologi Adisutjipto Yogyakarta

Bab 19. Solusi Critical Section

PERANGKAT LUNAK SIMULASI DEADLOCK MENGGUNAKAN ILUSTRASI DINING PHILOSOPHERS PROBLEM

Sinkronisasi dan Deadlock

Tahun Akademik 2014/2015 Semester II. DIG1I3 - Instalasi dan Penggunaan Sistem Operasi. Mutual Exclusion dan Sinkronisasi

Sequential Process. Keterangan SISTEM OPERASI KOMUNIKASI ANTAR PROSES

Concurrency 1: y Mutual Exclusion dan Sinkronisasi (Perte rt muan ke muan -10) 10 Oktober 2014

1/3/2013. Race Condition adalah situasi di mana beberapa proses mengakses

Komunikasi & Sinkronisasi Proses

Melakukan Operasi Logika

Sistem Operasi. Critical section, konkurensi, mutasi exclusion, starvation dan deadlock. Juliansyahwiran, S. Kom, MTI. Modul ke: Fakultas FASILKOM

Konkurensi merupakan landasan umum perancangan sistem operasi. Proses-proses disebut konkuren jika proses-proses berada pada saat yang sama.

Untuk mengatasi kondisi pacu harus dijamin tidak boleh dua proses atau lebih memasuki critical section yang sama secara bersamaan.

BAB II TINJAUAN PUSTAKA

Semester Ganjil 2014 Fak. Teknik Jurusan Teknik Informatika Universitas Pasundan. Caca E. Supriana, S.Si.,MT.

Sistem Operasi Pertemuan 6 Concurrency: Deadlock & Starvation. H u s n i Lab. Sistem Komputer & Jaringan Teknik Informatika Univ.

Sistem Operasi Komputer. Pembahasan Deadlock

1/5. while and do Loops The remaining types of loops are while and do. As with for loops, while and do loops Praktikum Alpro Modul 3.

Kelas: Nilai (Diisi Dosen):... IF

SOLUSI QUIZ 2 SISOP CS3613

MANAJEMEN PROSES. Satu Empat Model program counter program counter Proses

Deadlock Ch. 7. Deadlock. SISTIM OPERASI (Operating System) IKI Johny Moningka

Deadlock. Pada kasus ini juga bisa terjadi kelaparan, yaitu ada proses yang tidak terlayani

Monitor. Makalah Sistem Operasi. Disusun oleh :

Adam Mukharil Bachtiar English Class Informatics Engineering Algorithms and Programming Searching

CRITICAL REGION - SEMAPHORE MUTEX DALAM CPU OS SIMULATOR V

MODUL 5 MANAJEMEN PROSES (2) (PENJADWALAN PROSES)

Sistem operasi menjalankan banyak dan beragam program :

IKI20210 Pengantar Organisasi Komputer Kuliah Minggu ke-3: Bahasa Rakitan AVR

BAB II MANAJEMEN PROSES

OLEH : HASANUDDIN SIRAIT

Jawaban Soal UTS Instalasi dan Penggunaan Sistem Operasi Semester Genap 2014/2015 D3 Teknik Informatika, Fakultas Ilmu Terapan, Universitas Telkom

Bab 3: Proses-Proses. Konsep Proses

ILUSTRASI KLASIK: BOUNDED BUFFER

Computer System Structures

Mahasiswa dapat memahami konsep dasar deskripsi dan kontrol pada proses

Sistem operasi menjalankan banyak dan beragam program :

OBJECT ORIENTED PROGRAMMING. Day 3 : Operator dan Assignment

Mahasiswa dapat memahami konsep dasar deskripsi dan kontrol pada proses

Dosen pengampu : Mohamad Dani Sifat : Tutup buku dan peralatan elektronik

Sistem Operasi. Deadlock & Penanganannya. Aditya Wikan Mahastama

Interaksi Antar Proses

Bab 6. Deadlock POKOK BAHASAN: TUJUAN BELAJAR:

Kuliah#7 TSK617 Pengolahan Paralel - TA 2011/2012. Eko Didik Widianto

BAB II STACK Atau TUMPUKAN

SATUAN ACARA PERKULIAHAN (SAP) Mata Kuliah : Struktur Data Kode : TIS3213 Semester : III Waktu : 2 x 3 x 50 Menit Pertemuan : 14 & 15

Sistem Operasi PENGATURAN PROSES

Memory Management. Memory Ch. 8. Latar Belakang. Main-Memory Management

Konstruksi Dasar Algoritma

4 Proses. Proses. Konsep Proses. Proses. Prosesor mengeksekusi program-program komputer Prosesor adalah sebuah chip dalam sistem

DIG1G3 Implementasi Struktur Data

Operasi Unit Kontrol. Arsitektur Komputer II. STMIK AUB Surakarta

Operator dan Assignment. Pertemuan 3 Pemrograman Berbasis Obyek

MODUL 4 KONSEP PROSES, KONKURENSI, MANAJEMEN PROSES (1) M. R A J A B F A C H R I Z A L - S I S T E M O P E R A S I - M O D U L 4

Optimisasi Penjadwalan Proses Pada Central Processing Unit Dengan Menggunakan Algoritma Greedy

SISTEM OPERASI PENJADWALAN PROSES

BAB 3 ANALISIS DAN PERANCANGAN SISTEM

BAB VIII DEADLOCK ...

STRATEGI DIVIDE AND CONQUER

6 Maret Structure of Java [Penyeleksian Kondisi]

Tipe Boolean. Oleh : Fiftin Noviyanto

PENJADWALAN PROSES. Pendahuluan

Data Structures. Class 4 Arrays. Pengampu : TATI ERLINA, M.I.T. Copyright 2006 by The McGraw-Hill Companies, Inc. All rights reserved.

Tipe Boolean 20/01/2012. Oleh : Fiftin Noviyanto

Bab 3: Proses-Proses. Konsep Proses

Rencana Perkuliahan Sistem Operasi CSG3E3 2015/2016

Operating System: An Overview. Ch. 3: Process Management. Ch. 3: Process Management

DEADLOCK. KELOMPOK : Aurora Marsye Mellawaty Vidyanita Kumalasari Y

IMPLEMENTASI PENANGANAN DEADLOCK MENGGUNAKAN METODE TASKKILL

PRAKTIKUM STRUKTUR DATA QUEUE. SULIDAR FITRI, M.Sc

Transkripsi:

Process Synchronization SISTIM OPERASI (Operating System) IKI-20230 Johny Moningka (moningka@cs.ui.ac.id) Fakultas Ilmu Komputer Universitas Indonesia Semester 2000/2001 Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors OS Processes JM-2000/v1.1/2 1

Synchronization Sinkronisasi: Koordinasi akses ke shared data, misalkan hanya satu proses yang dapat menggunakah shared var. Contoh operasi terhadap var. counter harus dijamin di-eksekusi dalam satu kesatuan (atomik) : counter := counter + 1; counter := counter - 1; Sinkronisasi merupakan issue penting dalam rancangan/implementasi OS (shared resources, data, dan multitasking). OS Processes JM-2000/v1.1/3 The Critical-Section Problem n proses mencoba menggunakan shared data bersamaan Setiap proses mempunyai code yang mengakses/ manipulasi shared data tersebut => Problem: Menjamin jika ada satu proses yang sedang eksekusi pada bagian tidak ada proses lain yang diperbolehkan masuk ke code dari proses tersebut. Structure of process P i entry section exit section reminder section OS Processes JM-2000/v1.1/4 2

Solution (pre-requsite) Ide: Mencakup pemakaian secara exclusive dari shared variable tersebut Menjamin proses lain dapat menggunakan shared variable tersebut Solusi problem harus memenuhi: 1. Mutual Exclusion: Jika proses Pi sedang eksekusi pada bagian (dari proses Pi) maka tidak ada prosesproses lain dapat eksekusi pada bagian dari proses-proses tersebut. 2. Progress: Jika tidak ada proses sedang eksekusi pada critical section-nya dan jika terdapat lebih dari satu proses lain yang ingin masuk ke, maka pemilihan siapa yang berhak masuk ke tidak dapat ditunda tanpa terbatas. OS Processes JM-2000/v1.1/5 Solutions (cont.) 3. Bounded Waiting: Terdapat batasan berapa lama suatu proses harus menunggu giliran untuk mengakses jika seandainya proses lain yang diberikan hak akses ke. Menjamin proses dapat mengakses ke (tidak mengalami starvation: proses se-olah berhenti menunggu request akses ke diperbolehkan). Tidak ada asumsi mengenai kecepatan eksekusi prosesproses n tersebut. OS Processes JM-2000/v1.1/6 3

Simple solution: case 2 process Hanya 2 proses Struktur umum dari program code Pi dan Pj: entry section exit section reminder section Software solution: merancang algoritma program untuk solusi Proses dapat mengunakan common var. untuk menyusun algoritma tsb. OS Processes JM-2000/v1.1/7 Algorithm 1 Shared variables: var turn: (0..1); initially turn = 0 turn = i Pi dapat masuk ke Process P i while turn i do no-operation; turn := j; reminder section Satisfies mutual exclusion, but not progress OS Processes JM-2000/v1.1/8 4

Algorithm 2 Shared variables var flag: array [0..1] of boolean; initially flag [0] = flag [1] = false. flag [i] = true P i ready to enter its Process P i flag[i] := true; while flag[j] do no-op; flag [i] := false; remainder section Satisfies mutual exclusion, but not progress requirement. OS Processes JM-2000/v1.1/9 Algorithm 3 Combined shared variables of algorithms 1 and 2. Process P i flag [i] := true; turn := j; while (flag [j] and turn = j) do no-op; flag [i] := false; remainder section Meets all three requirements; solves the critical-section problem for two processes. OS Processes JM-2000/v1.1/10 5

Bakery Algorithm Critical Section for n processes Sebelum proses akan masuk ke dalam critical section, maka proses harus mendapatkan nomor (tiket). Proses dengan nomor terkecil berhak masuk ke critical section. If processes P i and P j receive the same number, if i < j, then P i is served first; else P j is served first. The numbering scheme always generates numbers in increasing order of enumeration; i.e., 1,2,3,3,3,3,4,5... OS Processes JM-2000/v1.1/11 Bakery Algorithm (Cont.) Notasi < lexicographical order (ticket #, process id #) => pasti unik (a,b) < (c,d) if a < c or if a = c and b < d note: (b dan d pasti tidak sama) max (a 0,, a n-1 ) is a number, k, such that k a i for i - 0,, n 1 Shared data var choosing: array [0..n 1] of boolean; number: array [0..n 1] of integer, Initialized: choosing =: false ; number => 0 OS Processes JM-2000/v1.1/12 6

Bakery Algorithm (Cont.) choosing[i] := true; number[i] := max(number[0], number[1],, number[n 1])+1; choosing[i] := false; for j := 0 to n 1 do begin while choosing[j] do no-op; while number[j] 0 and (number[j],j) < (number[i], i) do no-op; end; number[i] := 0; remainder section OS Processes JM-2000/v1.1/13 Synchronization Hardware Memerlukan dukungan hardware (prosesor) Dalam bentuk instruction set khusus: test-and-set Menjamin operasi atomik (satu kesatuan): test nilai dan ubah nilai tersebut. Test-and-Set dapat dianalogikan dengan kode: function Test-and-Set (var target:boolean): boolean; begin end; Test-and-Set := target; target := true; OS Processes JM-2000/v1.1/14 7

Test-and-Set (mutual exclusion) Mutual exclusion dapat diterapkan: Gunakan shared data, variabel: lock: boolean (initially false) lock: menjaga Process Pi: while Test-and-Set (lock) do no-op;.... lock := false; remainder section OS Processes JM-2000/v1.1/15 Semaphore Synchronization tool that does not require busy waiting. Semaphore S integer variable Dapat dijamin akses ke var. S oleh dua operasi atomik: wait (S): while S 0 do no-op; S := S 1; signal (S): S := S + 1; OS Processes JM-2000/v1.1/16 8

Example: n processes Shared variables var mutex : semaphore initially mutex = 1 Process Pi wait(mutex); signal(mutex); remainder section OS Processes JM-2000/v1.1/17 Semaphore Implementation Define a semaphore as a record type semaphore = record value: integer L: list of process; end; Assume two simple operations: block() : suspends the process that invokes it. wakeup(p) : resumes the execution of a blocked process P. OS Processes JM-2000/v1.1/18 9

Implementation (Cont.) Semaphore operations now defined as wait(s): S.value := S.value 1; if S.value < 0 then begin end; signal(s): S.value := S.value + 1; if S.value 0 then begin end; add this process to S.L; block; remove a process P from S.L; wakeup(p); OS Processes JM-2000/v1.1/19 Semaphore: Synchronization Tool Execute B in Pj only after A executed in Pi Use semaphore flag initialized to 0 Code: Pi Pj M M A wait(flag) signal(flag) B OS Processes JM-2000/v1.1/20 10

Two Types of Semaphores Counting semaphore Integer value can range over an unrestricted domain. Efektif untuk pemakaian membatasi jumlah proses, counter (blok pada nilai tertentu) dll. Semaphore s = 10; Binary semaphore Integer value can range only between 0 and 1; Digunakan untuk mutula exclusion: membatasi hanya ada satu proses pada. Semaphore s = 1; OS Processes JM-2000/v1.1/21 Semaphore: bounded buffer P C Shared data (array of item): buffer Semaphore: Binary Semaphore mutex; // mutual exclusion akses ke buffer Semaphore empty_slot; // slot buffer yang kosong : n Semaphore full_item; // item di buffer; Inisialisasi: mutex = 1; empty_slot = n; full_item = 0; OS Processes JM-2000/v1.1/22 11

Semaphrore: bounded buffer Producer: do.. produce item pada nextp; wait(empty_slot); wait(mutex); () add nextp to buffer; signal(mutex); signal(full_item); while (true); Consumer: do wait(full_item); wait(mutex); () remove nextp buffer; signal(mutex); signal(empty_slot);.. consume item nextp; while (true); OS Processes JM-2000/v1.1/23 Deadlock and Starvation Deadlock two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes. Let S and Q be two semaphores initialized to 1 P 0 P 1 wait(s); wait(q); wait(q); wait(s); M M signal(s); signal(q); signal(q) signal(s); Starvation indefinite blocking. A process may never be removed from the semaphore queue in which it is suspended. OS Processes JM-2000/v1.1/24 12