SlideShare a Scribd company logo
1 of 1
Computer Science 531
                                       Assignment #3
                                     Due: Tuesday, Nov. 4
                                          150 points


A group of M fraternity brothers and sorority sisters is having a party and drinking from a keg
that can hold 100 servings of beverage. One unlucky pledge is responsible for replacing the keg
each time it empties. When a partier wants to drink, he or she fills a cup from the keg, unless it
is empty. If the keg is empty, the partier wakes up the pledge and then waits until the pledge has
returned with a new keg. The behavior of the partiers and pledge is specified by the following
'threads':

       Partier:
          loop
             tellPledgeIfKeglsEmpty
             getServingFromKeg
             drink
             waitSomeAmountOfTime
          end loop

       Pledge:
          loop
             waitForKegloEmpty
             getNewKeg
          end loop

1)Develop a Java monitor or Ada protected record which implements the actions of a
semaphore.

2)Write a solution to the above program using that semaphore implementation for
synchronization. Your Java or Ada solution should have a single command-line argument
representing the number of partiers.

3)Write a solution to the above program without using the semaphore implementation. This
program can use a separate class or protected record for synchronization but it should be
one especially developed for the program (rather than a generic semaphore). It should not
be exactly equivalent to the solution of 2). Again, use a single command-line argument
representing the number of partiers.

More Related Content

Viewers also liked (8)

Results & Atmosphere
Results & AtmosphereResults & Atmosphere
Results & Atmosphere
 
Linked In Exec4r
Linked In Exec4rLinked In Exec4r
Linked In Exec4r
 
Vermisste Sprachfeatures in Java (german)
Vermisste Sprachfeatures in Java (german)Vermisste Sprachfeatures in Java (german)
Vermisste Sprachfeatures in Java (german)
 
Refecting on
Refecting onRefecting on
Refecting on
 
Frt 120206 - presentatie flevum leadgeneratie en social media februari 2012
Frt   120206 - presentatie flevum leadgeneratie en social media februari 2012Frt   120206 - presentatie flevum leadgeneratie en social media februari 2012
Frt 120206 - presentatie flevum leadgeneratie en social media februari 2012
 
La Vuelta Al Mundo En 80 Días
La Vuelta Al Mundo En 80 DíasLa Vuelta Al Mundo En 80 Días
La Vuelta Al Mundo En 80 Días
 
Portatile Ita
Portatile ItaPortatile Ita
Portatile Ita
 
Was ist Plone?
Was ist Plone?Was ist Plone?
Was ist Plone?
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 

Test

  • 1. Computer Science 531 Assignment #3 Due: Tuesday, Nov. 4 150 points A group of M fraternity brothers and sorority sisters is having a party and drinking from a keg that can hold 100 servings of beverage. One unlucky pledge is responsible for replacing the keg each time it empties. When a partier wants to drink, he or she fills a cup from the keg, unless it is empty. If the keg is empty, the partier wakes up the pledge and then waits until the pledge has returned with a new keg. The behavior of the partiers and pledge is specified by the following 'threads': Partier: loop tellPledgeIfKeglsEmpty getServingFromKeg drink waitSomeAmountOfTime end loop Pledge: loop waitForKegloEmpty getNewKeg end loop 1)Develop a Java monitor or Ada protected record which implements the actions of a semaphore. 2)Write a solution to the above program using that semaphore implementation for synchronization. Your Java or Ada solution should have a single command-line argument representing the number of partiers. 3)Write a solution to the above program without using the semaphore implementation. This program can use a separate class or protected record for synchronization but it should be one especially developed for the program (rather than a generic semaphore). It should not be exactly equivalent to the solution of 2). Again, use a single command-line argument representing the number of partiers.