الجمود المتبادل (Deadlocks)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
recognize and prevent deadlock.
الموضوعات المخطط لها
- Deadlock: threads each hold a lock and wait for another's; none proceeds.
- Four conditions: mutual exclusion, hold and wait, no preemption, circular wait.
- Prevention: acquire locks in a global order; hold fewer locks; use
tryLockwith timeout. - Livelock and starvation are related: threads busy but no progress, or never scheduled.
- Thread dumps report deadlocks explicitly.
تفاصيل المخطط المبدئي
عرض عملي
transfer(a,b) and transfer(b,a) locking in opposite order; fix by locking the lower ID first.
اختبر فهمك
What simple rule prevents circular wait?
أظهر الإجابة
Always acquire locks in the same global order.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.