You are here:

C++/Deadlock Detection program in C++

Advertisement


Question
I am having trouble figuring out ohow to construct the following C++ program based on these instructions:

Design a program that can detect deadlocks in a resource graph.

Your program should have a menu system with two options:

1. Construct a resource graph
2. Detect deadlocks
?
If user selects 1, you program should prompt for further inputs as followings.

Source:
Dest.:
More?

If user answer for More is N' then your program will go back to main menu. Otherwise continue adding more nodes to the resource graph.

When user selects 2, you start to search for a deadlock.

Your program should utilize the following data structure

struct node
{
  char name;
  node *next1;
  node *next2;
};

If you detect a deadlock, you should print program will try to find a deadlock within the resource graph the content of L so that L contains the deadlock set.


Any help you can provide me with constructing this C++ program will be apprreciated. Thanks.

Shawn Oberoi

Answer
Hello Shawn, thanks for the question.

I'm not sure exactly what you mean by detecting a deadlock. What you can do to prevent data corruption and deadlocks is to use a CRITICAL_SECTION object. If you go to the MSDN and look up the help for CRITICAL_SECTION, I'm sure it will be more than adequate for accomplishing what you want to do. If you do not have a copy of the MSDN it can be found online at msdn.msn.com I believe.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.