Classical Problems of Synchronization

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

เคนเคฎเคจเฅ‡ เคชเคขเคผเคพ เค•เคฟ multiple processes shared resources use เค•เคฐเคคเฅ‡ เคนเฅˆเค‚ เค”เคฐ synchronization เคœเคฐเฅ‚เคฐเฅ€ เคนเฅ‹เคคเคพ เคนเฅˆเฅค

เคฒเฅ‡เค•เคฟเคจ real systems เคฎเฅ‡เค‚ เค•เฅเค› standard problems เคฌเคพเคฐ-เคฌเคพเคฐ เค†เคคเฅ€ เคนเฅˆเค‚, เคœเคฟเคจเคธเฅ‡ synchronization techniques เค•เฅ‹ เคธเคฎเคเคพเคฏเคพ เคœเคพเคคเคพ เคนเฅˆเฅค

เค‡เคจเฅเคนเฅ€เค‚ เค•เฅ‹ เค•เคนเคคเฅ‡ เคนเฅˆเค‚:
Classical Problems of Synchronization

Classical Problems เค•เฅเคฏเคพ เคนเฅ‹เคคเฅ‡ เคนเฅˆเค‚

เคฏเฅ‡ predefined problems เคนเฅˆเค‚ เคœเฅ‹ process synchronization เค”เคฐ coordination เค•เฅ‹ เคธเคฎเคเคพเคจเฅ‡ เค•เฅ‡ เคฒเคฟเค use เค•เฅ€ เคœเคพเคคเฅ€ เคนเฅˆเค‚เฅค

Main Classical Problems

เค‡เคธ topic เคฎเฅ‡เค‚ เคฎเฅเค–เฅเคฏเคคเคƒ 3 problems เคชเคขเคผเฅ€ เคœเคพเคคเฅ€ เคนเฅˆเค‚:

  1. Producer-Consumer Problem
  2. Dining Philosophers Problem
  3. Readers-Writers Problem

เค…เคฌ เคนเคฎ เคเค•-เคเค• เค•เคฐเค•เฅ‡ detail เคฎเฅ‡เค‚ เคธเคฎเคเคคเฅ‡ เคนเฅˆเค‚เฅค

1. Producer-Consumer Problem

Concept

  • Producer data เคฌเคจเคพเคคเคพ เคนเฅˆ
  • Consumer data use เค•เคฐเคคเคพ เคนเฅˆ
  • เคฆเฅ‹เคจเฅ‹เค‚ เค•เฅ‡ เคฌเฅ€เคš buffer เคนเฅ‹เคคเคพ เคนเฅˆ

Problem

  • เค…เค—เคฐ buffer full เคนเฅˆ โ†’ producer wait เค•เคฐเฅ‡เค—เคพ
  • เค…เค—เคฐ buffer empty เคนเฅˆ โ†’ consumer wait เค•เคฐเฅ‡เค—เคพ

Example

  • Producer โ†’ data create เค•เคฐเคคเคพ เคนเฅˆ
  • Consumer โ†’ data consume เค•เคฐเคคเคพ เคนเฅˆ

Main Issue

  • Synchronization เคœเคฐเฅ‚เคฐเฅ€ เคนเฅˆ
  • Buffer เค•เคพ overflow เคฏเคพ underflow avoid เค•เคฐเคจเคพ เคนเฅ‹เคคเคพ เคนเฅˆ

Solution Idea

Semaphores เค•เคพ use:

  • empty โ†’ buffer empty slots
  • full โ†’ buffer filled slots
  • mutex โ†’ mutual exclusion

2. Dining Philosophers Problem

Concept

  • 5 philosophers table เคชเคฐ เคฌเฅˆเค เฅ‡ เคนเฅˆเค‚
  • เคนเคฐ philosopher เค•เฅ‹ เค–เคพเคจเฅ‡ เค•เฅ‡ เคฒเคฟเค 2 forks เคšเคพเคนเคฟเค

Problem

  • เคนเคฐ philosopher เคเค• fork เค‰เค เคพ เคฒเฅ‡เคคเคพ เคนเฅˆ
  • เคฒเฅ‡เค•เคฟเคจ เคฆเฅ‚เคธเคฐเคพ fork เคจเคนเฅ€เค‚ เคฎเคฟเคฒเคคเคพ

Result: เคธเคญเฅ€ wait เค•เคฐเคคเฅ‡ เคฐเคน เคœเคพเคคเฅ‡ เคนเฅˆเค‚

Issue

  • Deadlock
  • Starvation

เค†เค—เฅ‡ เคนเคฎเฅ‡เค‚ เค‡เคจเฅเคนเฅ‡เค‚ เคชเคขเฅ‡เค‚เค—เฅ‡ |

Solution Idea

  • Resource allocation control เค•เคฐเคจเคพ
  • เคเค• เคธเคฎเคฏ เคฎเฅ‡เค‚ เคธเคญเฅ€ เค•เฅ‹ fork เคจ เคฒเฅ‡เคจเฅ‡ เคฆเฅ‡เคจเคพ

3. Readers-Writers Problem

Concept

  • Readers โ†’ data read เค•เคฐเคคเฅ‡ เคนเฅˆเค‚
  • Writers โ†’ data modify เค•เคฐเคคเฅ‡ เคนเฅˆเค‚

Problem

  • Multiple readers allowed
  • เคฒเฅ‡เค•เคฟเคจ writer เค•เฅ‡ เคธเคฎเคฏ เค•เฅ‹เคˆ reader เคจเคนเฅ€เค‚ เคนเฅ‹เคจเคพ เคšเคพเคนเคฟเค

Issue

  • Data inconsistency
  • Synchronization problem

Solution Idea

  • Readers เค•เฅ‹ parallel allow เค•เคฐเคจเคพ
  • Writer เค•เฅ‹ exclusive access เคฆเฅ‡เคจเคพ

Comparison (Quick Revision)

ProblemMain IssueConcept
Producer-ConsumerBuffer controlData sharing
Dining PhilosophersDeadlockResource sharing
Readers-WritersData consistencyRead/Write control

Important Concepts Covered

เค‡เคจ problems เคธเฅ‡ เคนเคฎ เคธเฅ€เค–เคคเฅ‡ เคนเฅˆเค‚:

  • Mutual Exclusion
  • Deadlock
  • Starvation
  • Synchronization

Real Life Understanding

  • Producer-Consumer โ†’ factory system
  • Dining Philosophers โ†’ limited resources sharing
  • Readers-Writers โ†’ library system

Exam Focus Points

  • เคคเฅ€เคจเฅ‹เค‚ problems เค•เฅ‡ concept
  • Problem เค•เฅเคฏเคพ เคนเฅˆ
  • Solution idea (Semaphore based)
  • Deadlock เค”เคฐ starvation

Conclusion

Classical Problems of Synchronization Operating System เค•เฅ‡ important case studies เคนเฅˆเค‚, เคœเฅ‹ synchronization techniques เค•เฅ‹ practically เคธเคฎเคเคจเฅ‡ เคฎเฅ‡เค‚ เคฎเคฆเคฆ เค•เคฐเคคเฅ‡ เคนเฅˆเค‚เฅค

เค‡เคจเคธเฅ‡ เคนเคฎเฅ‡เค‚ real-life system problems เค•เฅ‹ solve เค•เคฐเคจเฅ‡ เค•เคพ เคคเคฐเฅ€เค•เคพ เคฎเคฟเคฒเคคเคพ เคนเฅˆเฅค

Leave a Comment

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

Scroll to Top