Programming Assignment 3
General Grading Guidelines:
The following deduc!ons will apply to all programming assignments.
1. Any program that does not compile will result in a zero for the assignment. No excep!ons will be made for ‘accidental’ uploads, so check your code before submi”ng.
2. Poor Forma”ng and programming style will result in a 5% deduc”on. Please see the style guidelines to avoid this deduc!on.
3. This can be individual work or group of max 3 individuals.
4. The code will go through 2 steps of plagiarism detec!on. Zero tolerance for academic misconduct! If you commit any form of academic misconduct in this course, you WILL be reported to the FIU Student Conduct and Academic Affairs office.
5. Error management is required and is worth 5pts. (e.g. if mutex init or lock fails )
Programming Style Guidelines:
The major purpose of programming style guidelines is to make programs easy to read and understand.
Good programming style helps make it possible for a person knowledgeable in the applica!on area to
quickly read a program and understand how it works.
1. Your program should begin with a comment that briefly summarizes what it does. For this course, this comment should also include your Name and pantherID.
2. Use addi!onal comments when needed in order for a reader to understand what is happening (see also, point 3).
3. Variable names and func!on names should be sufficiently descrip!ve so that a knowledgeable reader can easily understand what the variable means and what the func!on does. If this is not possible, comments should be added to make the meaning clear.
4. Use consistent indenta!on to emphasize block structure.
5. Use names of moderate length for variables. Most names should be between 2 and 12 le%ers long.
6. Use either underscores or capitaliza!on (camelNaming) for compound names for variables. e.g: tot_vol, total_volumn, or totalVolumn.
Assignment descrip”on :
Implement a solu!on to the cri!cal sec!on problem with threads using semaphores. You will modify the
same code as in the previous programming assignment (PA2), but you must add a third coun!ng thread
which counts by 1 each !me it enters its cri!cal sec!on to 2,000,000. Each counts to 2,000,000 for a total
of 6,000,000.
You will need to read about semaphore opera!ons from Linux manual pages. The important ones are
seminit, semwait, and sempost.
Make comments indica!ng the following sec!ons in your code:
entry sec”on
cri”cal sec”on
exit sec”on
remainder sec”on
Expected output:
both threads need to report the number of updates done at the end of their remainder sec!ons.
both threads need to report the current value of the shared variable counter at the end of their remainder
sec!ons.
thread1 needs to report the number of !mes it got the bonus at the end of its remainder sec!ons.
Im thread1, I did 2000000 updates and I got the bonus for 18562 !mes, counter = 2106222
Im thread3, I did 2000000 updates, counter = 5573136
Im thread2, I did 2000000 updates, counter = 6000000
from parent counter = 6000000
IMPORTANT!
No loop should be inside the cri”cal sec”on!
Remember to include the following as a comment in your file:
Your name
Your panther ID
A descrip!on of the program
Ques”ons?
if you have any ques!ons or you need help with code please contact your TA Cong Hoang and a%end the
weekly help sessions.
Deliverables:
Please submit:
1- your code in a PDF format. (e.g. semaphore.pdf )
2- zip file with your C source code included and (op!onally) a makefile. (e.g. semaphore.zip)
Your code will be tested on a Linux machine with gcc compiler using the command gcc -ofname thread-
solu!on.c -lpthread .
PEER EVALUATION (ONLY FOR GROUPS):
if you choose to work in a group, every member of the group should submit a peer evalua!on to Peer
evalua!on for PA3 . Only one member should submit the deliverables here.
The peer evalua!on is worth 5pts of the total assignment grade. if the group contains 3 members, you will
get the average of both ra!ngs of your teammates. However, if you assign a ra!ng <=3 to a team mate you need to provide a jus!fica!on in the peer evalua!on assignment. Any member reported as non- coopera!ve and non-contribu!ng will get a zero in this assignment. if a member did not submit the peer evalua!on of his team members he will get -5pts of his assignment grade. Programming Assignment 3 Criteria Forma”ng 5 to >2.67 pts
Full Marks
Student solu!on abides by programming forma”ng guidelines stated in assignment.
Ra”ngs Pts
2.67 to >0.0 pts 0 pts
Half Marks No Marks
Student solu!on par!ally abides Student 5 pts
by programming forma”ng solu!on
guidelines stated in assignment. poorly
forma%ed.
Error
Management
Entry
Sec!on for
T1
Func!onality
Entry
Sec!on for
T2
Func!onality
Cri!cal
Sec!on for
T1+ Bonus
Func!onality
semaphore
usage
Func!onality
Cri!cal
Sec!on for
T2
Func!onality
Exit sec!on
for T1
Func!onality
Exit sec!on
for T2
Func!onality
5 pts 3 pts 0 pts
Full Marks Half Marks No Marks
Student includes error Student par!ally includes Student does
management in solu!on error management in solu!on not include any
(e.g. if mutex init or lock (e.g. if mutex init or lock fails). error
fails). management.
5 pts 0 pts
Full Marks No Marks
T1 does not exceed 2M. T1 does exceed 2M.
5 pts 0 pts
Full Marks No Marks
T2 does not exceed 2M. T2 does exceed 2M.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes cri!cal Student solu!on does not include
sec!on for T1. cri!cal sec!on for T1.
15 pts 0 pts
Full Marks No Marks
Student solu!on contains bonus in Student solu!on does not contain
cri!cal sec!on for T1. bonus in cri!cal sec!on for T1.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes cri!cal Student solu!on does not include
sec!on for T2. cri!cal sec!on for T2.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes exit Student solu!on does not include exit
sec!on for T1. sec!on for T1.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes exit Student solu!on does not include exit
sec!on for T2. sec!on for T2.
5 pts
5 pts
5 pts
5 pts
15 pts
5 pts
5 pts
5 pts
Parent
wai!ng to
join both
threads
Func!onality
10 pts Full Marks
Student solu!on includes parent process wai!ng for its 2 threads to join.
5.33 pts
Half Marks
Student solu!on par!ally includes parent process wai!ng for its 2 threads to join.
0 pts
No Marks
Student solu!on does
not include parent 10 pts
process wai!ng for its 2
threads to join.
Final value
of counter
(4M)
Func!onality
Peer
evalua!on
Entry
Sec!on for
T3
Func!onality
Cri!cal
Sec!on for
T3
Func!onality
Exit sec!on
for T3
Func!onality
15 pts 0 pts
Full Marks No Marks
Student solu!on’s counter has a Student solu!on’s counter does not have 15 pts
final value of 4M. a final value of 4M.
5 pts 0 pts 5 pts
Full Marks No Marks
5 pts 0 pts
Full Marks No Marks 5 pts
T2 does not exceed 2M. T2 does exceed 2M.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes cri!cal Student solu!on does not include 5 pts
sec!on for T2. cri!cal sec!on for T2.
5 pts 0 pts
Full Marks No Marks
Student solu!on includes exit Student solu!on does not include exit 5 pts
sec!on for T2. sec!on for T2.
Total Points: 100
“PREVIOUS NEXT#
What are We?
Homeworkmerchants.com is an excellent online academic writing site that offers students a reliable and high-quality service in completing their assignments. With the help of our talented team of writers, who are graduates from Ivy League universities and professors in prestigious institutions across the globe, we guarantee that all our customers will receive quality work at affordable prices.
Below are some unique features which has made Homeworkmerchants.com one of the most sought after online writing sites:
• Writers from Ivy League Universities – We have a team of professional writers with advanced degrees from Ivy League universities, so you can be assured that your assignment will be written by experts with extensive knowledge and experience in their respective fields of study.
• Professors from Prestigious Institutions – In addition to our writers’ credentials, we also source subject matter experts with teaching or research experience at top schools like Harvard University, Stanford University, Massachusetts Institute of Technology (MIT) and other prestigious institutions around the world. This means that you can always expect exceptional quality when you order papers from us as each paper is thoroughly checked for accuracy and originality prior to delivery.
• Affordable Prices – We understand that students do not have deep pockets which is why we offer competitive rates for all our services without compromising on quality! As such, there’s no need for you to spend precious time worrying about how much your order will cost as we provide transparent pricing structure every step along the way.
• 24/7 Customer Support – At Homeworkmerchants.com , customer satisfaction is our priority which is why we offer round-the-clock customer support service so you can get assistance whenever needed during any stage of your project – whether it’s selecting a topic or submitting final drafts before deadline!
• On Time Delivery – We guarantee on-time delivery regardless if it’s a short essay or complex dissertation because we understand your deadlines are important too! Our dedicated team will make sure everything runs smoothly so you can submit your assignments right on time without any delays whatsoever!