-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamir.cpp
More file actions
135 lines (70 loc) · 2.02 KB
/
Copy pathamir.cpp
File metadata and controls
135 lines (70 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include<stdio.h>
#include<conio.h>
struct page{
int process;
int *address;
};
int main(){
int ram[20],vram[20];
int p,p_r,p_v,i,s_p,*add,top=0;
struct page table[40];
printf("\nEnter the number of process in ram");
scanf("%d",&p_r);
for(i=0;i<p_r;i++){
printf("\nenter process::");
scanf("%d",&p);
ram[i]=p;
}
printf("\nenter the number of process in vram");
scanf("%d",&p_v);
for(i=0;i<p_v;i++){
printf("\nenter process::");
scanf("%d",&p);
vram[i]=p;
}
x: printf("\nall processes in ram");
for(i=0;i<p_r;i++){
printf("\nprocess:: p[%d]",ram[i]);
}
printf("\nall processes in vram");
for(i=0;i<p_v;i++){
printf("\nprocess:: p[%d]",vram[i]);
}
for(i=0;i<p_r;i++){
table[i].process=ram[i];
table[i].address=&ram[i];
}
for(i=p_r;i<(p_r+p_v);i++){
int j=0;
table[i].process=vram[j];
table[i].address=NULL;
j++;
}
for(i=0;i<p_r+p_v;i++){
printf("\n%d::",table[i].process);
printf("%d\n",table[i].address);
}
printf("\nenter process you want in cpu::");
scanf("%d",&s_p);
for(i=0;i<p_r+p_v;i++){
if(s_p==table[i].process){
add=table[i].address;
break;
}
}
if(add==0){
for(i=0;i<p_v;i++){
if(s_p==vram[i]){
int temp = ram[top];
ram[top]=vram[i];
vram[i]=temp;
top++;
goto x;
}
}
}else{
printf("\nprocess processed");
}
getch();
return 0;
}