0% found this document useful (0 votes)
75 views6 pages

Individual Assignment (System) Week 14

The document provides instructions for an assignment on modeling a coffee cafe scenario using concurrent programming in Java. Students must simulate 3 baristas and up to 20 customers as separate processes or threads. The baristas take orders, make drinks using shared resources like espresso machines, and sleep when not serving customers. Customers enter the cafe, wait in line or for seating if busy, order drinks, and leave once finished. The program must output status updates from each process and synchronize shared resources between threads to model the interactions accurately. Additional requirements include tracking customer wait times and drink preparation progress.

Uploaded by

Spam Use
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views6 pages

Individual Assignment (System) Week 14

The document provides instructions for an assignment on modeling a coffee cafe scenario using concurrent programming in Java. Students must simulate 3 baristas and up to 20 customers as separate processes or threads. The baristas take orders, make drinks using shared resources like espresso machines, and sleep when not serving customers. Customers enter the cafe, wait in line or for seating if busy, order drinks, and leave once finished. The program must output status updates from each process and synchronize shared resources between threads to model the interactions accurately. Additional requirements include tracking customer wait times and drink preparation progress.

Uploaded by

Spam Use
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

Objective:

This assignment has been designed for students to apply appropriate concurrent program
methods in implementing a concurrent program from a program specification.

Learning Outcomes

ON COMPLETION OF THIS ASSIGNMENT, YOU SHOULD BE ABLE TO DEMONSTRATE THE


FOLLOWING LEARNING OUTCOME(S):
No. Learning Outcome Assessment
1 Explain the fundamental concepts of concurrency and parallelism Exam
in the design of a concurrent system (C2, PLO1)
2 Apply the concepts of concurrency and parallelism in the Individual
construction of a system using a suitable programming language. Assignment (System)
(C3, PLO2)
3 Explain the safety aspects of multi-threaded and parallel systems Individual
(A3, PLO6) Assignment (Report)

Programme Outcomes (PO):

PLO2 Cognitive Skills - This relates to thinking or intellectual capabilities and the ability to apply
knowledge and skills. The capacity to develop levels of intellectual skills progressively begins
from understanding, critical/creative thinking, assessment, and applying, analysing, problem
solving as well as synthesizing to create new ideas, solutions, strategies, or new practices. Such
intellectual skills enable the learner to search and comprehend new information from different
fields of knowledge and practices.

Individual Assignment - Report (20%):


Question Vs Taxonomy
Question Affective Level
No. Topic 1 2 3 4 5 PLO
SQ SQ SQ SQ SQ
1 Introduction and background 20% 6
Explanation of the safety aspects of 6
2 30%
multi-threaded system implemented
Justification of coding techniques 6
3 30%
implemented.
Depth of discussion of concurrency 6
4 20%
concepts.
Total 100%

Page 1 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

Individual Assignment - System (25%):


Question Vs Taxonomy
Question Cognitive Level
No. Topic 1 2 3 4 5 6 PLO
SQ SQ SQ SQ SQ SQ
Appropriateness of coding techniques 2
used to implement design with
1 20%
appropriate comment lines in source
codes
Appropriateness of the Java 2
2 concurrent programming facilities 20%
used.
Program runs appropriately with 2
3 20%
basic requirements
4 Additional requirements met 20% 2
Explanations of concurrency concepts 2
5 implemented with relevant code 20%
samples
Total 100%

Submission Requirements:
Assignment Handout Date : 29th November 2023

Assignment Due Date : 23rd February 2024

Case Study

GoGo Coffee Cafe.


Three baristas work independently in a small coffee café.
The café has 5 tables, each with 2 chairs.
There is 1 espresso machine, 1 milk frothing machine and 1 juice tap in the café.
*****************************Basic Requirements****************************
Each hairdresser follows the same work plan:

• The barista sleeps when no customer is waiting.

• When the baristas are asleep, the baristas waits to be awakened by a new customer. (Any
available baristas can be told to wake up if multiple baristas are asleep.)

• Once awake, the baristas take the order of a customer.

• The barista requires the espresso machine and milk frothing machine to prepare a
cappuccino which costs RM9.

Page 2 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

• The barista requires the espresso machine to prepare an espresso which costs RM6.

• The barista requires the juice tap to prepare a juice drink which costs RM7.

• Customers pay upon ordering and collect their drinks when ready.

• All customers consume their beverages in the café. No takeaways are assumed for this
simulation.

• If no customer is waiting, the barista goes back to sleep.

Each customer follows the following sequence of events.

• When the customer first enters the cafe, the customer leaves immediately if more than 5
people are waiting. On the other hand, if the cafe is not too full, the customer enters and
waits.

• If all baristas are busy, the customer stands in line to make an order.

*****************************Additional Requirements****************************
Customers keep track of their arrival, so the person waiting the longest is always the next
customer to get a drink.
Similarly, standing customers remember their order, so the person standing the longest takes the
next available seat.
Some customers do not like to share a table with strangers. They will wait for a table to become
available for a certain amount of time, before willing to share a table with strangers.
The cafe should close after all customers have left and all baristas are sleeping.
Customers drink preparation progress should be seen.
Customers drinking progress should be seen.
Which machines are used by which barista should be clearly stated.
Espresso machine, milk frothing machine, and juice tap availability should be stated when
baristas attempt to acquire.
Each event should take some time.
70% of customers order Cappuccino, 20% order Espresso, and 10% order Juice.
Total number of each drink and sales for the day should be reported.
*****************************************************************************
Extra points: Some customers who are standing get tired after a while and leave the cafe.
Deliverables:
For this exercise, you are to model the cafe and write a Java program to simulate activity for
this cafe:

Page 3 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

Simulate each barista and each customer as a separate process.


Altogether, 20 customers should try to enter.
Use a random number generator, so a new customer arrives every 0, 1, or 2 seconds.
Similarly, use a random number generator, so each customer drinks their beverage between 3
and 6 seconds.
Each customer should report when he/she starts sipping their drink and when he/she finishes.
Each customer should report when he/she enters the cafe. The customer also should report if
he/she decides to leave.
Similarly, if the customer must stand or sit on a chair, the customer should report when each
activity begins.

Sample Output
In order to see what is happening dynamically you must have output from the Customers and
the barista reporting all their major events.
Add information about which process/thread is doing the output. This way you can see if a
process/thread acts for another, which is strictly forbidden, but is a common error for Java
solutions (objects are not processes!). An example of such incorrect behaviour is
Thread-Barista1: 21.31: Barista1: Espresso for Customer 3 is done!
main: 21.50: Barista1: Next customer please!
Thread-Customer-12 : 21.50: Customer12 is waiting for a chair.
Thread- Barista1: 21.51: Barista1: Acquiring Juice Tap!

Where you can see that not only the Barista1 thread but also the main thread is acting for the
Barista.
Note that realistic time stamps are not required, it is fine to use any function to generate them.
You must not
• Kill a thread or process. You may not use any of the following in Java:
o Thread.stop
o Thread.resume
o Thread.suspend
o Thread.interrupt
o setDaemon
If any of those primitives are found in your code, you will fail the assignment no matter
the functionality of it.

Page 4 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

State your assumptions and how you will implement them.

Implementation

You should implement your simulation in Java.


The simulation run should not take more than 60 seconds to simulate.

Documentation for System (Report)


The documentation should detail the system implementation and testing.

1. Basic requirements met:


• List of requirements met.
- Short explanation of concurrency concepts (atomic statements,
synchronization, etc) implemented.
- Code snippet of the Java concurrent programming facilities implemented.

2. Additional requirements met:


• List of requirements met.
- Short explanation of concurrency concepts (atomic statements,
synchronization, etc) implemented.
- Code snippet of the Java concurrent programming facilities implemented.

3. Requirements which were NOT met:


• List of basic requirements.
• List of additional requirements

Should not exceed 1500 words excluding references/appendix/coding.

Submission for System


• Java files required to run the simulation.
• Video of the simulation running. Maximum 5 minutes per person.
o Simulate scenarios as stated above.
o Show which requirements are met in the output and corresponding code.
Both code and presentation Zipped into a single zip file named TP0XXXXX CCP.zip

Page 5 of 6
Concurrent Programming - CT074-3-2 Asia Pacific University of Technology & Innovation Level 2

Marking Scheme (NOT for student’s documentation guidance)

Report (20%)
Criteria Total marks Marks
awarded
Assumptions [LO3-PO6] 20
Explanation of the safety aspects of multi-threaded system 30
implemented [LO3-PO6]
Justification of coding techniques implemented [LO3-PO6] 30
Depth of discussion of concurrency concepts [LO3-PO6] 20
TOTAL MARKS 100

System (25%)
Criteria Total marks Marks
awarded
Appropriateness of coding techniques used to implement 20
design with appropriate comment lines in source codes *
Appropriateness of the Java concurrent programming facilities 20
used.
Program runs appropriately with basic requirements * 20
Additional requirements met * 20
Explanations of concurrency concepts implemented with 20
relevant code samples *
TOTAL MARKS 100

*Based on video presentation of the simulation.

Page 6 of 6

You might also like