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

Dining philosophers problem in c

22/11/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:

Ideas & Innovations
Instant Homework Helper
George M.
Accounting & Finance Specialist
Top Writing Guru
Quick Finance Master
Writer Writer Name Offer Chat
Ideas & Innovations

ONLINE

Ideas & Innovations

I am an elite class writer with more than 6 years of experience as an academic writer. I will provide you the 100 percent original and plagiarism-free content.

$32 Chat With Writer
Instant Homework Helper

ONLINE

Instant Homework Helper

After reading your project details, I feel myself as the best option for you to fulfill this project with 100 percent perfection.

$30 Chat With Writer
George M.

ONLINE

George M.

As per my knowledge I can assist you in writing a perfect Planning, Marketing Research, Business Pitches, Business Proposals, Business Feasibility Reports and Content within your given deadline and budget.

$20 Chat With Writer
Accounting & Finance Specialist

ONLINE

Accounting & Finance Specialist

This project is my strength and I can fulfill your requirements properly within your given deadline. I always give plagiarism-free work to my clients at very competitive prices.

$41 Chat With Writer
Top Writing Guru

ONLINE

Top Writing Guru

I have assisted scholars, business persons, startups, entrepreneurs, marketers, managers etc in their, pitches, presentations, market research, business plans etc.

$38 Chat With Writer
Quick Finance Master

ONLINE

Quick Finance Master

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.

$43 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

1 6 diaminohexane and sebacoyl chloride - Bulletproof diet food list - Gcse science biology boardworks - How starbucks growth destroyed brand value - Pdf principles and characteristics of forensic accounting - Communicating at work 11th edition pdf download - Wadsworth college reading series book 2 answers - Practical strategies for technical communication 2nd edition pdf free - What is the impact of rapid environmental changes on organizations - Renaissance art literature and science - What best describes greek theater - Bbc dance mat typing - Business Assignment - Plants to oxygenate and strengthen the brain - Acap bachelor of psychological science and counselling - Skittles taste the rainbow - Student exploration titration gizmo answer key - Unwieldy inheritance - Maslow's hierarchy of needs the blind side - Discuss eli lilly practice from the perspectives of utilitarianism - Pros and cons of internal and external growth strategy - Criminal Justice Capstone Project Partial Draft Five - The buret is filled with the naoh titrant - Sutherlands hair and beauty - International business essay questions and answers - Color attraction h2o alpha lenses - Universal coupling assembly drawing pdf - Jrp online portal login - Legal studies practice exams - My Last Duches 1 - Formulating quantitative and qualitative research question - Reading checklist for students - Synthes locking small frag inventory control form - Episure autodetect epidural syringe - I don't really know (I just need help with these two steps! - Citi trends in cahokia illinois - Boyz n the hood discussion questions - Consider the following decision tree - Dhl express insurance policy - Key components in collaboration and consultations - 300 words - Advocacy Through Legislation - Hlf polyurethane manufacturing - Sonnet 73 literary devices - Alliteration in the tyger - Highest Custom Whiteboard Animation Video Maker - Epidemiology for public health practice 5th edition pdf - Gilgamesh map - Hbr the core competence of the corporation - Apple inc cash flow statement - Building Relationships DB - Marcum showdown troller 2.0 problems - Week 6 E-marketing - Lawrence peter fogelberg cause of death - Why did the zoot suit riots occur - Estudent macquarie university log in - Answer 4 questions - Intro to economics quiz - 4 pages introduction section of research proposal project - BE JAA7 - Ps4 error ws 37269 7 - Natafuta HM Mkt Account - A christmas carol scenes - Role of education in democracy ppt - Physics essay questions and answers - 4 indicators of chemical change - Statistics Homework/Quiz - Abb sace tmax motor operator wiring diagram - Peter oakes clinical psychologist - Differential analysis the key to decision making - Seeking the scout wow - The author to her book by bradstreet - Political lens us constitution - Vehicles in your convex mirrors are - What is life process - 4150 s atlantic ave new smyrna beach fl 32169 - Uses of infrared radiation in physiotherapy - Adult disability assessment tool - Describe two cryptographic applications and how they are used in Information System Security. - Cognitive psychology computer analogy - Norman crisologo and max eigenmann son - Footwear company vision statement - Hubspot ai chatbot - Www hp com go mobileprintingwww hp com go mobileprintingwww hp com go mobileprinting - Cal maritime alumni job board - Practical Connection Infer Stats in Decision-Making - Dq response - DQ8 - Before the flood quizlet - Mornington peninsula walking tracks - Aqa physics formula booklet - Speech on aids awareness - High concept game design - High energy ignition system flare - Star delta starter function - Safe harbor provisions under hipaa - BHA415 Module 4 Case - On january 1 you sold short one round lot - Blanka dobrynin - Street fighter resurrection terroriser scene