Skip to main content
edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
Notice removed Reward existing answer by user34073
Bounty Ended with ChrisWue's answer chosen by CommunityBot
Tweeted twitter.com/#!/StackCodeReview/status/548011183945826305
Notice added Reward existing answer by user34073
Bounty Started worth 50 reputation by CommunityBot
deleted 23 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this problem. I have never written a multi-threaded program before, nor have I written a program with mutual exclusion before, so I decided to request a review here. I

I implemented three variations, a busy-waiting variation, a SemaphoreSemaphore variation, and a MonitorMonitor variation. All of these reside in a class named ProgramProgram, which is needed for the threading. The MonitorMonitor variation looks as if there should be a simpler solution with fewer variables, is. Is this so?

This is the SemaphoreSemaphore implementation:

And this is the MonitorMonitor implementation:

Any comments will be appreciated.

I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this problem. I have never written a multi-threaded program before, nor have I written a program with mutual exclusion before, so I decided to request a review here. I implemented three variations, a busy-waiting variation, a Semaphore variation, and a Monitor variation. All of these reside in a class named Program, which is needed for the threading. The Monitor variation looks as if there should be a simpler solution with fewer variables, is this so?

This is the Semaphore implementation:

And this is the Monitor implementation:

Any comments will be appreciated.

I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this problem. I have never written a multi-threaded program before, nor have I written a program with mutual exclusion before, so I decided to request a review here.

I implemented three variations, a busy-waiting variation, a Semaphore variation, and a Monitor variation. All of these reside in a class named Program, which is needed for the threading. The Monitor variation looks as if there should be a simpler solution with fewer variables. Is this so?

This is the Semaphore implementation:

And this is the Monitor implementation:

Added relevant tag.
Link
Brythan
  • 7k
  • 3
  • 22
  • 37
Source Link
user34073
user34073
Loading