Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Standard C, C++
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 10-25-2004, 05:20 AM   #1 (permalink)
coolsc81
Registered User
 
Join Date: Oct 2004
Posts: 2
coolsc81 is on a distinguished road
C++ Deadlock Detection Program Help...

I am having a hard time constructing the following C++ program provided the following 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 that you can provide me would be appreciated, thanks.
__________________
coolsc81 is offline   Reply With Quote
Old 10-26-2004, 05:57 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
What exactly is the problem? Do you need a container but don't know how to code it? Or do you want to know what a deadlock or a resource graph is?

What have you so far? Show it so I know what you are talking about.
__________________
Valmont is offline   Reply With Quote
Old 10-26-2004, 06:14 AM   #3 (permalink)
coolsc81
Registered User
 
Join Date: Oct 2004
Posts: 2
coolsc81 is on a distinguished road
Here is what I got so far... I need help with finishing the code and implementing it to a program.

Thanks for the help.

- Shawn


Sample code:
Code:
struct Node { char Name: Node *next; }; Node Graph[20]; // 1. Construct Resource Graph // 2. Detect deadlock // 3. Quit // Source: A // Destination: B // More? If true: // Source: B // Destination: D // ... // ... // More? If false: // Execute Detection Algorithum // .. // print L = A , B , C , D , C // index: void Main() { indx = 0; Menu; switch(choice) { n case 1: break; case 2: break; } } // Case 1: while (Ans != 'T') { node * S_Pointer, D_Pointer; cout << "Source:"; cin >> source; cout << "Destination:"; cin >> destination; for(i=0; i<20; i++) { if ( Graph[i].Name == source) { SePointer = Graph[i].Name; found = true; } if(!found) { S_Pointer = Graph[index]; index++; } } } // same for destination
::edited by sde, please use [ code] tags::
__________________

Last edited by sde : 10-26-2004 at 06:52 AM.
coolsc81 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
c simple question problem with switch case if13121 Standard C, C++ 1 10-24-2004 09:43 PM
Simple C program Spooky Standard C, C++ 1 10-22-2004 07:26 AM
math not quite accurate in C program uman Standard C, C++ 4 09-27-2004 05:19 PM
Starting out with C anon C 0 02-24-2003 01:06 PM
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 02:08 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle