MENDETEKSI DEADLOCK
Contoh algoritma pendeteksian deadlock dengan Multiple Resource of Each Type Terdapat 4 sumberdaya Tape drives 4 buah Plotters 2 buah Scanner 2 buah CDRom 2 buah Terdapat 3 proses Proses 1 menggunakan 1 scanner meminta 2 tape drives dan 1 CDRoms Proses 2 menggunakan 2 tape drives dan 1 CDRoms meminta 1 tape drives dan 1 scanner Proses 3 menggunakan 1 plotter dan 2 scanner meminta 2 tape drives dan 1 plotter
Current Allocation Matrix Request Matrix Tape drives CD ROMs Tape drives CD ROMs Scanners Scanners Plotters Plotters Existing 4 2 3 1 Available 2 1 Current Allocation Matrix Request Matrix P1 1 2 P1 2 1 P2 P2 P3 P3 Maka resource yang tersedia (availabe) adalah Tape drives 4 – (0 + 2 + 0) = 2 Plotters 2 – (0 + 0 + 1) = 1 Scanners 3 – (1 + 0 + 2) = 0 CD ROMs 1 – (0 + 1 + 0) = 0
Current Allocation Matrix Request Matrix Tape drives CD ROMs Tape drives CD ROMs Scanners Scanners Plotters Plotters Existing 4 2 3 1 Available 2 1 Current Allocation Matrix Request Matrix P1 1 2 P1 2 1 P2 P2 P3 P3 Periksa apakah ada proses yang permintaannya dapat dipenuhi P1 Apakah (2 0 0 1) <= (2 1 0 0)? Tidak P2 Apakah (1 0 1 0) <= (2 1 0 0)? Tidak P3 Apakah (2 1 0 0) <= (2 1 0 0)? Ya
Current Allocation Matrix Request Matrix Tape drives CD ROMs Tape drives CD ROMs Scanners Scanners Plotters Plotters Existing 4 2 3 1 Available 2 Current Allocation Matrix Request Matrix P1 1 2 P1 2 1 P2 P2 P3 P3 Setelah P3 Selesai Available = (2 1 0 0) + (0 1 2 0) = (2 2 2 0) Periksa apakah ada proses yang permintaannya dapat dipenuhi P1 Apakah (2 0 0 1) <= (2 2 2 0)? Tidak P2 Apakah (1 0 1 0) <= (2 2 2 0)? Ya
Current Allocation Matrix Request Matrix Tape drives CD ROMs Tape drives CD ROMs Scanners Scanners Plotters Plotters Existing 4 2 3 1 Available 4 2 1 Current Allocation Matrix Request Matrix P1 1 2 P1 2 1 P2 P2 P3 P3 Setelah P2 Selesai Available = (2 0 0 1) + (2 2 2 0) = (4 2 2 1) Periksa apakah ada proses yang permintaannya dapat dipenuhi P1 Apakah (2 0 0 1) <= (4 2 2 1)? Ya
Current Allocation Matrix Request Matrix Tape drives CD ROMs Tape drives CD ROMs Scanners Scanners Plotters Plotters Existing 4 2 3 1 Available 4 2 3 1 Current Allocation Matrix Request Matrix P1 1 P1 2 1 P2 P2 P3 P3 Setelah P1 Selesai Available = (0 0 1 0) + (4 2 2 1) = (4 2 3 1)
Tidak terjadi deadlock Karena semua permintaan dapat dipenuhi Maka Tidak terjadi deadlock