Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

C program for dining philosopher problem

04/12/2021 Client: muhammad11 Deadline: 2 Day

Write in C language ( will not accept any others than C and will consider ZERO

We discussed both the pthreads library and the dining philosophers problem in class. We also implemented, and discussed, an “arbitrator solution”. You will find with this homework a pthreads implementation of a bad dining philosophers solution that will deadlock. This bad solution is in the file bad_philosophers.c. You will also find with this homework a pthread implementation of a working dining philosophers problem that uses an arbitrator to prevent deadlocks. This solution is in the file good_philosophers1.c. You may modify either of these programs to address any of the questions in this homework. You may also start from scratch if you so choose.

First 1: By yourself, code a version of the “resource hierarchy solution” for dining philosophers. You MAY turn in a fixed/modified version of the bad_philosophers.c code of you can start from scratch. Note that the resource hierarchy solution is discussed in the book and in hundreds of online tutorials. The solution is:

Each philosopher runs in an independent thread and each thread is defined as follows:

While (1) { think for some period of time;

when the fork next to me with the smallest number is available, pick it up; when the fork next to me with the largest number is available, pick it up; eat for some period of time; put one fork down;

put the other fork down; }

Note that the “high” numbered and the “low” numbered fork many NOT always have the same “right fork/left fork” mapping for all the philosopher. The key here is NOT doing left first and then right first or right first and then left first. Rather, it is doing LOWEST NUMBER first and HIGHEST NUMBER second.

Note, there are versions of this program online. It would be best if you do not refer to them and cheat yourself of a chance to figure it out. In any case, you may NOT copy online solutions. Your solution should be your own and it should be THROROUGLY commented to explain exactly what the code is doing. Uncommented code will be scored zero for this question. Your turn in for this question is a C program in a file called good_philosophers2.c. Again, it should be lavishly commented.

Seconds 2: For this question, we’ll define “fair” as meaning that all the philosophers eat about as often as all of the rest of them. How would you determine if a particular algorithm is fair? Using this method, experiment with the arbiter solution and the resource hierarchy solution that you have in good_philosophers1.c and good_philosophers2.c good_philosophers1.c and good_philosophers1.c respectively. Are they both fair? If one is not, provide

your reasoning about WHY it is not fair. Your answer to this question, including any pictures of figures you may want to use, should be in a PDF file called question_2.pdf

3. Third 3: In real programs, it is more likely that any resource could need to grab any resource (chopstick) instead of just some smaller set (chopsticks “close-by”). Consider the program bad_jerk_philosophers.c that implements a new version of the dining philosophers problem. In this case, all the philosophers are jerks and each will, when hungry, make a random choice about which two chopsticks to take from ANYWHERE on the table. The provided code deadlocks fairly quickly. Write two NEW versions of the “jerk dining philosopher problem” that do NOT deadlock. One version should use an arbiter solution and should be called good_jerk_philosophers1.c. The second version should use a resource hierarchy solution and should be called good_jerk_philosophers2.c. As before, both pieces of code should be lavishly commented. Uncommented code will not be graded. Each of the two programs is worth 20 points each.

4. Forth 4: Consider a version of the dining philosophers problem in which any of the N philosophers may grab between 2 and N chopsticks before eating. This means each philosopher may grab ANY number between two and all the chopsticks on the table and those chopsticks need not be anywhere near him (though they could be). Would a resource hierarchy solution for this problem prevent deadlocks? Could such a solution livelock? Could such a solution fail to prevent starvation? Explain your answers for each. You answer, including any diagrams you may wish to include, should be in a single pdf file with the name Four_a.pdf.

5. 5) Fifth 5: Write code that solves the problem in number 4 (A), that prevents both deadlocks and starvation. Call this program Five_b.c You should lavishly comment your code. Explain, in comments, how you designed the program to prevent deadlocks and starvation.

When you are done, create a single zip archive file with ALL your answer files in it. The name of the file should be _hw2.zip. The zip archive should contain the following files:

good_philosophers2.c - Your resource hierarchy modifications to bad_philosophers.c

question2.pdf - Your answers to problem 2

good_jerk_philosophers1.c - Yourarbitermodificationstobad_jerk_philosophers.c

good_jerk_philosophers2.c - Yourresourcehierarchymodificationstobad_jerk_philosophers.c

Four_a.pdf - written answers for problem 4

Four_b.c - code for problem 5

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Pro Writer
Study Master
Engineering Exam Guru
Academic Mentor
Calculation Master
Innovative Writer
Writer Writer Name Offer Chat
Pro Writer

ONLINE

Pro Writer

I find your project quite stimulating and related to my profession. I can surely contribute you with your project.

$26 Chat With Writer
Study Master

ONLINE

Study Master

I have done dissertations, thesis, reports related to these topics, and I cover all the CHAPTERS accordingly and provide proper updates on the project.

$24 Chat With Writer
Engineering Exam Guru

ONLINE

Engineering Exam Guru

I am an academic and research writer with having an MBA degree in business and finance. I have written many business reports on several topics and am well aware of all academic referencing styles.

$25 Chat With Writer
Academic Mentor

ONLINE

Academic Mentor

I will be delighted to work on your project. As an experienced writer, I can provide you top quality, well researched, concise and error-free work within your provided deadline at very reasonable prices.

$36 Chat With Writer
Calculation Master

ONLINE

Calculation Master

I am an academic and research writer with having an MBA degree in business and finance. I have written many business reports on several topics and am well aware of all academic referencing styles.

$45 Chat With Writer
Innovative Writer

ONLINE

Innovative Writer

I find your project quite stimulating and related to my profession. I can surely contribute you with your project.

$23 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Mary louise pratt contact zone - West Coast Transit Case - Norton mix composition writing 101 pdf - The need for more than justice annette baier pdf - Primary Document Analysis - Narrative essay transition words - System breach - Racism quotes in tkam - Afl solicitors tony nikolic letter - Cango final presentation - Your session could not be established - 12 6 preparing a payroll register answers - Beads and buttons galore melbourne - The good earth characters - Parts of gas meter - Hhmi biointeractive virus explorer answer key - Us history essay - Assignment 5 employee compensation and benefits - Homework - Public Policy and Response to Social Change - The waiting times between a subway departure chegg - CRIMINAL JUSTICE - Case study write up for columbia's final mission - Little heath sixth form - I love my momma lunch money lewis - What is a chemical reaction worksheet - Diploma in veterinary pharmacy syllabus - Why do you dress me in borrowed robes literary device - Https finance yahoo com quote aapl p aapl - Combining like terms and distributive property worksheet - What was jackson's net cash provided by operating activities - Intended only for brilliant answers - Nursing Care Plan - Balanced equation for naoh and khp - Reply to my peers - I need 1200 words 12 answers the Questions - Dave shelly and chainsaw movie - The pulmonary semilunar valve permits flow from - Institutionalized organizations formal structure as myth and ceremony - Can you burn kwila decking - Amazon vs walmart case study answers - Research questions about apartheid - Dirt bikes usa information systems - Doubling and halving strategy multiplication - Inert sidewinder missile for sale - Please read requirement in below comment section. - Vitamins calories per gram - Https www amazon com ref nav_logo_prime - F ma problems and answers - Nutrition Therapy Strategies for Wound Healing - Calculate quick burger's free cash flow in - Change through persuasion summary - Bartley barstools has an equity multiplier - Nursing Discussion - 1105 shackleton road apex nc 27502 - Does tantoo cardinal have a cleft palate - Cchbc share price lse - Animal farm chapter 5 summary - Philosophy of man reflection paper - Sample letter to inform patients - Universal laser inc just paid a dividend of - Ave maria frank o'hara analysis - Www cbussuper com au - The winslow boy 1948 cast - +91 9928097710 jadu tona specialist astrologer in Surat - Processing hour of code - Dulux trade paint expert - Risk Management - Anz eftpos network attach in progress - Chcage001 assessment answers - Common holy days in jewish religious traditions worksheet - Autodesk flexnet license server - Hassra north east shop - Guild wars 2 error code 45 6 3 2157 - What is activity cost pool - Who is the parent company of tylenol - Sharp company comparative balance sheet - Wk 5 - Apply: Regression Modeling - Cinahl with full text - Feedback form format for seminar - How to defer unisa - Easy flo brazing rod - Liberty by julia alvarez full story - Enrolled nurse supervision in general practice - Competency and image enhancement as a means of addressing devaluation - Thanksgiving hymns dead sea scrolls - The coddling of the american mind chapter 1 summary - Gare saint lazare painting - Esol skills for life entry 3 4692 - Poststructuralism in international relations - Renova toilet paper case study summary - Cobit p09 - Current event - Business valuation report template - Adobe muse manual pdf download - +91-8306951337 kala jadu specialist astrologer IN Muzaffarnagar - Bachelor of nursing acu atar - Basics of occupational safety goetsch pdf - Medical terminology prefixes suffixes root words quiz - IOS Models