INPUT:
enter total no. of processes : 4
enter claim matrix :
0 1 0 0 1
0 0 1 0 1
0 0 0 0 1
1 0 1 0 1
enter allocation matrix :
1 0 1 1 0
1 1 0 0 0
0 0 0 1 0
0 0 0 0 0
enter resource vector :
2 1 1 2 1
enter the availability vector :
0 0 0 0 1
OUTPUT :
deadlock causing processes are : 1 2
#include<stdio.h> #include<conio.h> void main() { int found,flag,l,p[4][5],tp,c[4][5],i,j,k=1,m[5],r[5],a[5],temp[5],sum=0; clrscr(); printf("enter total no of processes"); scanf("%d",&tp); printf("enter clain matrix"); for(i=1;i<=4;i++) for(j=1;j<=5;j++) { scanf("%d",&c[i][j]); } printf("enter allocation matrix"); for(i=1;i<=4;i++) for(j=1;j<=5;j++) { scanf("%d",&p[i][j]); } printf("enter resource vector:\n"); for(i=1;i<=5;i++) { scanf("%d",&r[i]); } printf("enter availability vector:\n"); for(i=1;i<=5;i++) { scanf("%d",&a[i]); temp[i]=a[i]; } for(i=1;i<=4;i++) { sum=0; for(j=1;j<=5;j++) { sum+=p[i][j]; } if(sum==0) { m[k]=i; k++; } } for(i=1;i<=4;i++) { for(l=1;l<k;l++) if(i!=m[l]) { flag=1; for(j=1;j<=5;j++) if(c[i][j]>temp[j]) { flag=0; break; } } if(flag==1) { m[k]=i; k++; for(j=1;j<=5;j++) temp[j]+=p[i][j]; } } printf("deadlock causing processes are:"); for(j=1;j<=tp;j++) { found=0; for(i=1;i<k;i++) { if(j==m[i]) found=1; } if(found==0) printf("%d\t",j); } getch(); }
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
March 31st, 2010 at 1:49 pm
explain deadlock detection?what is allocation matrix&claim matrix?
what is resource vector and availiblity vector?
April 10th, 2010 at 1:15 pm
explain deadlock detection?what is allocation matrix&claim matrix?
what is resource vector and availiblity vector?
April 10th, 2010 at 1:16 pm
what is allocation matrix?
April 26th, 2010 at 10:08 am
Please answer me any one…
How to implement the deadlock condition by using real resource like
memory,dvd rom,no of process….
I am struggle with doing this,please any one help me…
February 7th, 2011 at 12:07 pm
what is claim matrix?
can u expalin the program with sum?
February 7th, 2011 at 12:07 pm
what is claim matrix?
can u expalin the above program with sum?
February 13th, 2011 at 7:43 pm
i guess claim matrix is d maximum need of resources for each process
March 2nd, 2011 at 11:07 pm
sir if cycle present in a graph it is known as deadlock .what are the methods or algorithm that we can prevent the deadlock. and explain me a for loop now as soon as possible iam waiting for ur reply.
March 19th, 2011 at 1:58 am
The claim matrix and the allocation matrix actually come from the Resource allocation graph (RAG).
How do i input these matrices directly from the RAG. That is instead of using scanf, i can update the matrices.
How do i do it ?
Please advice.
Thanks
sheshank
May 4th, 2011 at 1:28 am
Hi I’m writing a program in java for simple deadlock detection : I’m given a muti-dimensional array with dependencies like
A B
B C
C A
Indicating that A depends on B, B on C and C on A. Hence there’s a deadlock. I wanted some help with the logic to write this in java.
Any help is appreciated.
-Mahesh
June 7th, 2011 at 3:21 am
Hello.This article was really interesting, especially because I was looking for thoughts on this topic last Saturday.
June 9th, 2011 at 12:49 pm
hello mahesh,could u plz elaborate ur question??
June 29th, 2011 at 8:28 pm
hai iam sravani i need exact step by step algorithm fordead lock detection
July 1st, 2011 at 3:45 pm
such a waste program i have ever seen…………………….
November 7th, 2011 at 7:50 pm
program is executing but we want its explanation. . . . .
January 25th, 2012 at 11:22 am
Bakwaaaaassss
January 31st, 2012 at 11:04 am
this pogram is wrong………………..u hav given right output here…but we r getting wrong output wen we execute it