15
1 Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC) Matakuliah : T0316/sistem Operasi Tahun : 2005 Versi/Revisi : 5 OFFCLASS01

Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

  • Upload
    yannis

  • View
    115

  • Download
    11

Embed Size (px)

DESCRIPTION

Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC). Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5. OFFCLASS01. Learning Outcomes. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : - PowerPoint PPT Presentation

Citation preview

Page 1: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

1

Pertemuan 5Komunikasi antar Proses /

Interprocess Communication (IPC)

Matakuliah : T0316/sistem OperasiTahun : 2005Versi/Revisi : 5

OFFCLASS01

Page 2: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

2

Learning Outcomes

Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu :• menjelaskan perlunya komunikasi antar process,

dan menerangkan beberapa mekanisme untuk berkomunikasi (C2)

Page 3: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

3

Outline Materi

• Race Condition• Critical Region• Mutual Exclusion with busy waiting

– Disabling interrupts– Lock variables– Strict Alternation– Peterson’s solution– TSL Instruction

• Sleep and wakeup

Page 4: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

4

Problems-    Passing information between process-    Making sure two or more processes do not get into each

other’s way-    Proper sequencing when dependencies are present 

Interprocess Communication

RACE CONDITION

Situation where two or more processes are reading or writing some shared data and the final result depends on who runs precisely when

Page 5: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

5

 Examples: spooler directory for printer

Two processes want to access shared memory at same time

Page 6: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

6

spooler (2)

Process AReads in = 7Store local_next_slot = 7

Reads local_next_slot = 7Store buffer[7] = AUpdate in = 8

Process B

Reads in = 7Store local_next_slot = 7Store buffer[7] = BUpdate in = 8

B will never receive any output

Page 7: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

7

Critical Regions

Four conditions to provide mutual exclusion1. No two processes simultaneously in critical region2. No assumptions made about speeds or numbers of CPUs3. No process running outside its critical region may block

another process4. No process must wait forever to enter its critical region

Mutual Exclusion:    mechanism to prevent process accessing resource used

by another process

Part of the programs in which the shared memory is accessed

Page 8: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

8

Mutual exclusion using critical regions

Page 9: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

9

1. Disabling Interrupt

    Each process disable all interrupts just after entering its critical regions and re-enable them just before leaving it

but, disabling interrupt shall not be carried out by user process

 

Mutual Exclusion with Busy Waiting

Page 10: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

10

2. Lock Variables

    Shared (lock) variables, initially set to 0    If lock = 0, lock is set to = 1, then enters the critial

region    If lock = 1, wait until lock = 0

problem: race condition

Page 11: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

11

3. Strict Alternation

(a) Process 0.

(b) Process 1.

Page 12: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

12

4. Peterson’s Solution

Page 13: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

13

5. TSL Instruction (Test and Set Lock)

Note:Peterson and TSL are correct bur requires busy waiting

Initially lock = 0 JNE = false just RET

Page 14: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

14

Sleep: system call yang menyebabkan proses yang memanggil diblock, atau ditunda (suspended)

Wakup: system call yang menyebabkan proses dibangunkan, atau menjadi ready

Sleep and Wakeup

Case: Producer-Consumer Problem (Bounded-Buffer Problem)

Page 15: Pertemuan 5 Komunikasi antar Proses / Interprocess Communication (IPC)

15

Example of producer-consumer problem with fatal race condition