Deadlock Prevention

Introduction (เคชเคฐเคฟเคšเคฏ)

เคนเคฎเคจเฅ‡ เคชเคขเคผเคพ เค•เคฟ deadlock เคคเคฌ เคนเฅ‹เคคเคพ เคนเฅˆ เคœเคฌ เคšเคพเคฐเฅ‹เค‚ conditions เคเค• เคธเคพเคฅ true เคนเฅ‹ เคœเคพเคคเฅ€ เคนเฅˆเค‚เฅค

เค…เคฌ idea เคฏเคน เคนเฅˆ เค•เคฟ เค…เค—เคฐ เคนเคฎ เค‡เคจ conditions เคฎเฅ‡เค‚ เคธเฅ‡ เค•เคฟเคธเฅ€ เคเค• เค•เฅ‹ เคญเฅ€ break เค•เคฐ เคฆเฅ‡เค‚,
เคคเฅ‹ deadlock เค•เคญเฅ€ เคนเฅ‹เค—เคพ เคนเฅ€ เคจเคนเฅ€เค‚เฅค

เค‡เคธเฅ€ concept เค•เฅ‹ เค•เคนเคคเฅ‡ เคนเฅˆเค‚: Deadlock Prevention

Deadlock Prevention เค•เฅเคฏเคพ เคนเฅ‹เคคเคพ เคนเฅˆ

Deadlock Prevention เคตเคน technique เคนเฅˆ เคœเคฟเคธเคฎเฅ‡เค‚ system เค•เฅ‹ เค‡เคธ เคคเคฐเคน design เค•เคฟเคฏเคพ เคœเคพเคคเคพ เคนเฅˆ เค•เคฟ deadlock เคนเฅ‹เคจเฅ‡ เค•เฅ€ เคธเค‚เคญเคพเคตเคจเคพ เคนเฅ€ เค–เคคเฅเคฎ เคนเฅ‹ เคœเคพเคเฅค

Simple Definition

Deadlock Prevention = deadlock เค•เฅ‹ เคนเฅ‹เคจเฅ‡ เคธเฅ‡ เคชเคนเคฒเฅ‡ เคฐเฅ‹เค•เคจเคพ

Basic Idea

Deadlock เคนเฅ‹เคจเฅ‡ เค•เฅ‡ เคฒเคฟเค 4 conditions เคœเคฐเฅ‚เคฐเฅ€ เคนเฅˆเค‚:

  1. Mutual Exclusion
  2. Hold and Wait
  3. No Preemption
  4. Circular Wait

เค…เค—เคฐ เค‡เคจเคฎเฅ‡เค‚ เคธเฅ‡ เค•เคฟเคธเฅ€ เคเค• เค•เฅ‹ เคญเฅ€ remove เค•เคฐ เคฆเคฟเคฏเคพ เคœเคพเค โ†’ deadlock เคจเคนเฅ€เค‚ เคนเฅ‹เค—เคพ

Deadlock Prevention Techniques

เค…เคฌ เคนเคฎ เคนเคฐ condition เค•เฅ‹ เค•เฅˆเคธเฅ‡ break เค•เคฐเคคเฅ‡ เคนเฅˆเค‚, เคฏเคน เคธเคฎเคเคคเฅ‡ เคนเฅˆเค‚:

1. Mutual Exclusion เค•เฅ‹ remove เค•เคฐเคจเคพ

Idea

Resource เค•เฅ‹ shareable เคฌเคจเคพ เคฆเฅ‹

Example

  • Printer share เคจเคนเฅ€เค‚ เคนเฅ‹ เคธเค•เคคเคพ
  • เคฒเฅ‡เค•เคฟเคจ read-only file share เคนเฅ‹ เคธเค•เคคเฅ€ เคนเฅˆ

Limitation

เคธเคญเฅ€ resources shareable เคจเคนเฅ€เค‚ เคนเฅ‹ เคธเค•เคคเฅ‡

2. Hold and Wait เค•เฅ‹ remove เค•เคฐเคจเคพ

Idea

Process เค•เฅ‹ เคเค• เคธเคพเคฅ เคธเคญเฅ€ resources เคฎเคพเค‚เค—เคจเฅ‡ เคนเฅ‹เค‚เค—เฅ‡

Working

  • Process เคชเคนเคฒเฅ‡ เคนเฅ€ เคธเคญเฅ€ resources request เค•เคฐเฅ‡เค—เคพ
  • เคฏเคพ เคœเฅ‹ resources hold เค•เคฐ เคฐเคนเคพ เคนเฅˆ, เค‰เคจเฅเคนเฅ‡เค‚ release เค•เคฐเค•เฅ‡ เคจเคฏเคพ request เค•เคฐเฅ‡เค—เคพ

Problem

  • Resource utilization เค•เคฎ เคนเฅ‹ เคœเคพเคคเคพ เคนเฅˆ
  • Waiting time เคฌเคขเคผ เคธเค•เคคเคพ เคนเฅˆ

3. No Preemption เค•เฅ‹ remove เค•เคฐเคจเคพ

Idea

เค…เค—เคฐ process resource hold เค•เคฐ เคฐเคนเคพ เคนเฅˆ เค”เคฐ เคจเคฏเคพ resource เคšเคพเคนเคฟเค, เคคเฅ‹ เค‰เคธเค•เคพ current resource เคฒเฅ‡ เคฒเฅ‹

Working

  • Process เคธเฅ‡ resource เค›เฅ€เคจ เคฒเคฟเคฏเคพ เคœเคพเคคเคพ เคนเฅˆ
  • เคฌเคพเคฆ เคฎเฅ‡เค‚ เคตเคพเคชเคธ เคฆเคฟเคฏเคพ เคœเคพ เคธเค•เคคเคพ เคนเฅˆ

Problem

  • เคนเคฐ resource เคชเคฐ apply เคจเคนเฅ€เค‚ เคนเฅ‹ เคธเค•เคคเคพ
  • Data inconsistency เคนเฅ‹ เคธเค•เคคเฅ€ เคนเฅˆ

4. Circular Wait เค•เฅ‹ remove เค•เคฐเคจเคพ

Idea

Resources เค•เฅ‹ เคเค• fixed order เคฎเฅ‡เค‚ allocate เค•เคฐเฅ‹

Working

  • เคนเคฐ resource เค•เฅ‹ เคเค• number เคฆเคฟเคฏเคพ เคœเคพเคคเคพ เคนเฅˆ
  • Process เค•เฅ‡เคตเคฒ increasing order เคฎเฅ‡เค‚ resource request เค•เคฐเฅ‡เค—เคพ

Example

R1 โ†’ R2 โ†’ R3

Process เค•เฅ‹ เคชเคนเคฒเฅ‡ R1 เคฒเฅ‡เคจเคพ เคนเฅ‹เค—เคพ, เคซเคฟเคฐ R2

เค‡เคธเคธเฅ‡ cycle เคจเคนเฅ€เค‚ เคฌเคจเฅ‡เค—เคพ โ†’ deadlock เคจเคนเฅ€เค‚ เคนเฅ‹เค—เคพ

Summary Table (Quick Revision)

ConditionPrevention Method
Mutual ExclusionResource shareable เคฌเคจเคพเคจเคพ
Hold and WaitAll resources เคเค• เคธเคพเคฅ request
No PreemptionResource forcefully เคฒเฅ‡เคจเคพ
Circular WaitFixed ordering เคฒเคพเค—เฅ‚ เค•เคฐเคจเคพ

Advantages

  • Deadlock เคชเฅ‚เคฐเฅ€ เคคเคฐเคน avoid เคนเฅ‹ เคœเคพเคคเคพ เคนเฅˆ
  • System safe เคฐเคนเคคเคพ เคนเฅˆ

Disadvantages

  • Resource utilization เค•เคฎ เคนเฅ‹ เคธเค•เคคเคพ เคนเฅˆ
  • Processes เค•เฅ‹ unnecessary wait เค•เคฐเคจเคพ เคชเคกเคผเคคเคพ เคนเฅˆ
  • System performance เค•เคฎ เคนเฅ‹ เคธเค•เคคเฅ€ เคนเฅˆ

Important Point (Exam Focus)

  • Deadlock Prevention = condition break เค•เคฐเคจเคพ
  • Circular Wait removal เคธเคฌเคธเฅ‡ practical เคคเคฐเฅ€เค•เคพ เคนเฅˆ

Conclusion

Deadlock Prevention เคเค• proactive approach เคนเฅˆ, เคœเคฟเคธเคฎเฅ‡เค‚ system เค•เฅ‹ เค‡เคธ เคคเคฐเคน design เค•เคฟเคฏเคพ เคœเคพเคคเคพ เคนเฅˆ เค•เคฟ deadlock เคนเฅ‹เคจเฅ‡ เค•เฅ€ possibility เคนเฅ€ เค–เคคเฅเคฎ เคนเฅ‹ เคœเคพเคเฅค

เคนเคพเคฒเคพเค‚เค•เคฟ เคฏเคน safe เคนเฅˆ, เคฒเฅ‡เค•เคฟเคจ เค‡เคธเคธเฅ‡ system performance เค”เคฐ resource utilization เคชเคฐ negative effect เคชเคกเคผ เคธเค•เคคเคพ เคนเฅˆเฅค

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top