80 likes | 206 Views
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. Tape drives. Tape drives. CD ROMs. CD ROMs. Scanners. Scanners.
E N D
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
Tape drives Tape drives CD ROMs CD ROMs Scanners Scanners Plotters Plotters Available Existing Request Matrix Current Allocation Matrix P1 P1 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
Tape drives Tape drives CD ROMs CD ROMs Scanners Scanners Plotters Plotters Available Existing Request Matrix Current Allocation Matrix P1 P1 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
Tape drives Tape drives CD ROMs CD ROMs Scanners Scanners Plotters Plotters Available Existing Request Matrix Current Allocation Matrix P1 P1 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
Tape drives Tape drives CD ROMs CD ROMs Scanners Scanners Plotters Plotters Available Existing Request Matrix Current Allocation Matrix P1 P1 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
Tape drives Tape drives CD ROMs CD ROMs Scanners Scanners Plotters Plotters Available Existing Request Matrix Current Allocation Matrix P1 P1 P2 P2 P3 P3 • Setelah P1 Selesai • Available = (0 0 1 0) + (4 2 2 1) = (4 2 3 1)
Karena semua permintaan dapat dipenuhi Maka Tidak terjadi deadlock