Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Banker's Algorithm

Posted on 2010-11-14
2
2,220 Views
1 Endorsement
Last Modified: 2012-05-10
This is an academic question (i.e. student question).  Since the original person who was helping ran into some computer problems, he/she asked me to delete the first one and repost.  Therefore, I am.  I am a student at Uinversity of New Mexico in an OS class working on my second masters.  I've been around for a while, and am not trying to cheat the system :-)

My study partner and I have worked on this and have run into a deadend (sort of).  When I compile the code it runs correctly for the first run.  The next runs have a segmentation fault.  When I recompile . . . it runs good for the first run, then has a segmentation fault for the next runs . . . on and on.  Therefore, I know we are just about there, but...we are apparently missing something (probably fairly simple).  That's the problem with we students . . . little problems can really be big, and big problems can really be little.  Therefore, I'm asking for assistance.

Apparently we have the basic concept laid out correctly, or it wouldn't run correctly the first time.  I believe the problem lies somwhere around lines 40 thru 45.  I think that the way we have the PThread being created may be causing a problem.  However, I'm not sure.  Thus, my question.  

I've attached the code.  Please take a look and let me know your thoughts.  I don't want anyone to do it for me, I just want some advice.  


Thanks much,
Darrell
rrb-bankers.c
1
Comment
Question by:dlb_sun
2 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 250 total points
ID: 34133000
There seem to be a couple of problems, that may result in the issue that you are seeing (I haven't tried actually running your code) or not but at least should be something that you should address.

- Line 38, you initialise the mutex a second time

- Lines 44 - 49, you create only 3 threads but you are 'joining' 9 threads (3 loops on i and j each)

0
 

Author Closing Comment

by:dlb_sun
ID: 34173144
Thanks for your advice.  Although it didn't specifically rectify all our issues, it did help in that direction.  I apologize for being so long in getting back to this.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix, date minus 1, 2 or 3 days (last working day) 11 67
Super Scope, DHCP 5 91
Android development question 2 54
Query group by data in SQL Server - cursor? 3 47
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question