QuestionQuestion

You will be testing the efficiency of different dynamic storage-allocation algorithms in this homework.

Construct your code in C using the following steps:

a) Assume that the memory storage has M=2,048 (MB). It’s empty at the beginning and we can imagine it as a big free space (we have thus ignored the OS storage requirement).
b) For each new process that you need to bring into memory, use the selected algorithm (A=first-fit, best-fit, or worst-fit) to choose one hole (free space) to occupy.
c) Once the selection is made, update the available space.
d) If one process can’t be loaded because there is no space for it, count it as a failed assignment.
e) Once the process duration ends, free up the space that it has been using and mark the space as available.
f) Repeat for all processes.
g) At the end, efficiency of algorithm A can be computed as

1 - failed_assignements/total_assignments

The following processes will arrive (the first column is space requirement, the second column is arrival time, the third column is duration that it will stay in memory). Therefore, the first process has a memory requirement of 144 (MB). It arrives at time 20 and it will stay for 341 unit times, i.e., be done at time 341+20=361, etc.

144 20 341
6 28 278
53 48 536
192 54 71
5 72 65
159 86 236
157 100 419
19 107 534
143 121 29
9 142 176
12 157 573
158 165 458
155 181 34
197 188 18
189 198 557
147 214 223
192 226 11
26 243 303
134 247 570
76 252 560
108 268 33
187 275 550
179 286 303
45 300 116
18 309 372
43 314 526
136 316 253
87 319 559
97 329 319
144 338 508
63 344 457
167 358 390
164 372 559
61 385 420
163 387 138
5 393 423
167 408 144
98 424 325
21 443 227
116 455 381
30 460 594
184 476 467
145 489 431
29 509 507
42 520 158
98 528 278
58 545 219
133 552 371
20 573 187
154 582 381
59 585 468
32 586 534
51 598 408
194 601 130
41 620 119
181 635 247
32 645 461
94 651 473
187 669 361
27 671 97
157 683 114
133 696 516
146 703 310
35 711 282
74 732 4
142 745 456
83 762 309
49 775 266
176 777 586
139 779 211
136 789 120
6 804 288
129 818 534
11 826 337
148 837 150
197 841 160
141 844 339
149 856 477
116 864 14
190 872 443
19 875 242
183 896 427
98 905 386
67 921 390
172 937 576
5 955 310
43 972 9
97 983 498
180 989 377
145 1008 366
174 1026 425
81 1027 322
19 1029 38
6 1044 334
103 1050 41
100 1051 452
157 1064 22
163 1066 576
146 1069 225
154 1077 599
67 1078 456
118 1088 51
161 1091 309
32 1106 521
119 1120 397
189 1132 42
87 1144 556
52 1154 25
187 1162 595
36 1164 421
198 1182 518
144 1202 102
106 1221 415
56 1237 510
25 1244 139
27 1252 76
149 1262 32
68 1274 385
74 1287 48
82 1293 463
167 1306 335
124 1314 57
34 1320 438
18 1341 253
49 1355 404
18 1364 485
35 1367 535
37 1374 402
59 1376 498
126 1385 582
153 1400 451
103 1417 350
137 1420 572
62 1439 130
58 1454 125
77 1457 592
61 1473 311
82 1489 144
90 1506 233
46 1519 129
184 1531 180
164 1548 414
190 1568 375
166 1570 63
47 1574 173
121 1592 362
108 1593 522
156 1607 490
175 1625 226
74 1633 291
163 1648 468
142 1657 132
139 1677 94
47 1687 149
27 1698 587
59 1700 325
25 1705 400
77 1722 405
193 1725 369
45 1735 41
56 1750 278
145 1760 212
29 1761 364
169 1776 368
153 1782 184
162 1787 504
180 1790 105
177 1802 4
3 1815 131
111 1817 322
156 1822 206
16 1831 100
48 1835 368
91 1854 172
93 1873 182
178 1883 301
54 1887 318
25 1898 9
47 1915 72
51 1928 84
16 1943 458
134 1953 125
105 1968 303
137 1975 141
98 1977 398
56 1988 386
105 1993 511
185 2013 525
151 2029 569
99 2042 486
178 2051 47
183 2070 181
91 2082 64
65 2098 423
67 2107 273
51 2115 211
47 2131 484
72 2148 35
57 2157 114
197 2174 169
98 2185 453
138 2194 245
31 2203 192
89 2222 264
32 2238 211
80 2254 277
119 2265 248
169 2274 569
182 2292 570
29 2298 277
112 2299 223
78 2302 203
61 2319 294
150 2340 512
195 2351 42
71 2361 317
101 2376 198
159 2381 206
138 2384 440
52 2394 501
125 2403 426
57 2409 96
26 2425 587
152 2445 337
128 2448 284
103 2465 238
139 2470 52
89 2471 167
35 2480 221
191 2484 479
4 2496 8
115 2508 139
199 2523 413
34 2542 23
101 2543 473
82 2558 398
188 2579 454
98 2600 312
141 2610 595
73 2618 108
70 2639 263
187 2650 379
145 2657 405
166 2666 551
98 2667 546
114 2678 39
146 2682 383
133 2689 290
50 2695 174
60 2696 434
96 2712 304
192 2726 407
129 2735 482
136 2746 411
188 2759 70
200 2763 576
84 2770 202
153 2788 192
89 2806 402
135 2808 89
19 2819 168
137 2837 397
57 2856 326
47 2873 171
52 2894 587
194 2906 346
157 2908 437
141 2911 529
196 2932 398
138 2942 314
41 2961 154
103 2980 405
94 3000 516
94 3017 285
190 3037 549
119 3052 38
32 3067 294
193 3071 550
121 3074 295
155 3077 292
117 3085 165
139 3105 56
166 3113 401
44 3133 76
50 3136 66
119 3139 267
34 3150 333
133 3169 579
146 3173 344
28 3177 47
84 3185 218
43 3195 13
56 3196 279
137 3205 575
153 3210 588
71 3228 87
120 3240 165
34 3258 584
50 3260 464
11 3271 365
33 3275 506
159 3285 408
12 3295 555
19 3302 586
87 3322 36
2 3337 17
34 3351 427
196 3371 385
109 3387 282
183 3398 335
195 3412 58
24 3428 493
1 3446 226
3 3464 548
195 3470 505
72 3477 357
89 3486 59
86 3491 144
41 3496 15
94 3500 93
138 3518 529
89 3538 72
83 3555 517
46 3559 520
172 3575 538
188 3580 8
63 3590 479
194 3608 110
178 3612 20
164 3625 99
129 3639 330
167 3655 462
9 3661 469
118 3673 210
198 3693 426
51 3713 199
21 3726 371
49 3743 276
65 3750 132
112 3756 260
59 3766 385
142 3782 500
87 3792 426
169 3813 109
50 3831 349
164 3838 468
165 3843 456
51 3861 151
147 3879 207
133 3882 439
157 3898 173
151 3902 267
199 3915 505
154 3932 591
176 3937 370
70 3939 107
162 3956 39
194 3958 412
47 3974 139
85 3982 400
199 3991 508
122 3996 442
4 4016 541
192 4020 148
11 4030 531
194 4048 28
83 4054 297
170 4064 349
177 4085 570
96 4105 380
18 4107 285
98 4119 74
125 4120 169
121 4135 463
116 4148 451
135 4156 12
78 4163 510
8 4165 542
18 4180 407
198 4199 25
53 4215 298
9 4228 413
148 4248 23
71 4256 151
153 4259 191
157 4270 101
6 4274 277
161 4280 552
183 4281 30
191 4297 170
187 4313 490
177 4314 537
167 4317 475
182 4320 15
114 4323 49
176 4336 554
42 4347 309
157 4358 26
84 4372 475
126 4390 438
199 4391 58
29 4409 475
74 4425 425
3 4432 235
103 4447 545
124 4466 77
29 4486 277
21 4492 317
192 4496 369
180 4504 32
160 4509 14
18 4511 68
5 4516 334
167 4522 364
29 4543 471
185 4557 574
187 4560 118
21 4577 281
176 4593 548
81 4608 251
28 4620 180
159 4629 155
27 4637 500
98 4640 418
152 4645 5
191 4648 383
188 4664 490
64 4666 398
185 4679 202
125 4686 576
129 4697 322
122 4717 341
10 4732 71
135 4741 306
193 4744 490
185 4753 380
83 4765 79
64 4771 321
25 4772 572
150 4784 48
64 4803 263
6 4812 470
146 4830 99
137 4834 417
103 4847 262
162 4865 493
179 4872 334
198 4881 474
81 4890 162
48 4903 319
27 4907 391
87 4910 110
168 4914 120
137 4924 94
61 4934 593
74 4949 151
36 4957 225
72 4964 289
51 4966 184
77 4986 428
39 4988 284
90 5008 377
17 5014 126
52 5017 236
95 5033 104
87 5049 349
4 5068 167
32 5081 56
132 5092 157
117 5099 503
36 5109 453
70 5119 220
125 5132 361
102 5148 207
168 5169 263
20 5187 156
192 5194 260
31 5212 22
147 5224 48
198 5225 205
94 5241 126
93 5259 447
122 5265 300
192 5275 42
56 5294 235
187 5297 156
51 5308 454
156 5314 528
62 5317 522
54 5327 128
29 5329 268
197 5335 14
13 5346 467
149 5354 241
61 5367 375
137 5373 585
129 5392 228
24 5404 419
87 5422 272
56 5426 267
26 5433 147
109 5446 102
66 5449 388
13 5463 9
18 5468 8
82 5473 249
146 5490 195
169 5492 208
82 5505 148
140 5520 247
86 5539 30
43 5546 570
144 5564 23
82 5573 321
184 5594 315
129 5607 53
77 5627 140
71 5629 231
33 5634 256
115 5637 465
138 5642 513
122 5661 568
189 5674 72
151 5690 114
42 5702 66
123 5707 274
141 5723 122
171 5727 171
98 5745 205
172 5763 367
137 5779 395
24 5794 589
188 5805 255
1 5824 502
33 5831 115
126 5834 236
41 5842 338
136 5845 575
110 5858 28
157 5866 40
54 5879 546
50 5892 417
187 5907 514
30 5919 464
45 5929 576
114 5937 231
134 5939 254
57 5949 157
105 5954 299
44 5969 7
113 5985 528
73 5991 199
98 5992 117
88 6009 170
187 6030 571
189 6043 386
170 6051 168
20 6071 185
165 6089 267
58 6099 536
105 6103 196
21 6117 226
90 6121 466
60 6128 395
123 6132 5
72 6136 54
122 6142 151
171 6153 158
171 6163 68
109 6182 298
128 6189 284
63 6196 323
16 6208 562
2 6224 38
127 6243 52
96 6251 482
9 6258 307
110 6271 235
69 6282 72
4 6288 394
129 6306 158
110 6318 313
83 6334 21
161 6343 579
32 6358 560
150 6373 315
97 6380 377
84 6383 508
136 6396 526
199 6406 34
197 6426 44
200 6434 118
104 6449 326
133 6459 329
162 6465 158
45 6476 127
134 6489 443
104 6499 245
48 6502 310
88 6522 427
125 6527 596
133 6530 95
131 6542 286
184 6546 289
121 6547 255
11 6559 293
83 6573 598
95 6582 50
57 6594 9
54 6597 593
117 6608 571
107 6611 472
72 6617 46
110 6621 252
18 6623 217
57 6642 593
98 6644 564
112 6654 10
84 6667 285
102 6675 540
79 6685 87
30 6702 148
177 6719 80
71 6726 423
116 6732 199
118 6741 63
126 6745 134
121 6761 511
142 6763 474
144 6766 112
82 6786 238
37 6799 157
5 6817 360
81 6826 402
173 6834 47
175 6841 237
161 6844 140
109 6858 569
138 6878 217
136 6890 175
162 6904 59
26 6924 388
34 6936 299
140 6955 161
70 6975 441
126 6982 571
166 7002 580
52 7019 498
173 7031 115
190 7048 472
91 7063 277
65 7081 76
32 7093 231
162 7108 41
161 7110 547
138 7126 586
45 7131 420
67 7143 149
10 7155 406
33 7162 55
78 7177 582
179 7197 400
133 7209 69
66 7215 51
165 7216 23
48 7232 344
181 7233 505
58 7239 462
125 7251 601
161 7255 364
6 7265 221
176 7269 11
198 7288 142
130 7300 409
76 7313 258
146 7325 101
184 7343 327
99 7354 354
36 7370 488
95 7388 284
14 7391 552
183 7401 519
102 7408 314
51 7426 318
81 7428 409
192 7441 410
131 7449 114
154 7455 284
23 7467 371
53 7471 557
162 7475 101
152 7495 519
85 7503 166
138 7508 345
138 7510 76
37 7529 312
2 7549 50
6 7557 223
20 7560 405
169 7579 17
21 7588 392
64 7592 537
146 7606 271
73 7608 521
102 7610 451
52 7622 270
115 7641 365
94 7645 421
146 7648 141
21 7649 273
196 7665 30
83 7680 368
159 7698 11
86 7704 376
162 7717 118
97 7719 304
108 7722 289
2 7730 427
121 7740 415
46 7743 437
138 7758 266
103 7770 198
39 7781 329
168 7801 516
19 7805 550
54 7819 377
89 7837 311
115 7845 323
21 7847 98
22 7848 84
3 7849 358
85 7856 365
60 7861 388
54 7868 39
131 7881 39
153 7893 363
182 7898 246
96 7907 264
175 7915 49
17 7931 246
135 7939 69
148 7948 599
77 7960 425
132 7973 280
4 7975 73
120 7978 451
67 7989 580
23 8008 521
134 8014 529
109 8028 105
35 8030 174
79 8031 512
98 8042 279
88 8056 599
127 8065 170
31 8074 216
186 8082 445
174 8098 329
53 8111 344
102 8117 45
98 8137 51
8 8146 120
81 8154 539
76 8162 405
33 8181 365
170 8191 32
131 8202 306
104 8219 182
144 8223 145
16 8228 467
186 8233 537
7 8234 33
45 8252 335
100 8253 92
28 8254 595
50 8272 317
182 8288 323
108 8306 428
172 8326 492
105 8327 525
170 8332 374
48 8347 7
23 8368 134
129 8381 33
22 8393 310
57 8413 537
20 8428 349
57 8436 378
182 8444 88
103 8464 450
53 8471 169
68 8473 522
98 8485 482
158 8499 294
51 8515 585
124 8535 317
199 8542 132
3 8558 119
92 8565 12
104 8584 208
175 8598 502
30 8605 166
37 8612 396
186 8627 103
157 8632 178
32 8642 223
187 8650 390
13 8655 342
76 8667 308
138 8685 37
6 8695 468
177 8709 19
183 8714 409
88 8735 537
46 8736 224
122 8749 375
185 8766 417
127 8775 472
11 8794 380
198 8805 415
59 8825 483
48 8838 226
77 8852 30
52 8871 63
45 8881 325
74 8895 511
35 8900 320
154 8912 546
117 8915 55
63 8922 519
181 8934 515
180 8939 531
87 8946 46
14 8952 206
129 8964 138
168 8976 508
181 8989 81
124 8990 530
85 8995 117
1 9006 509
194 9007 126
106 9017 403
68 9020 131
118 9026 40
178 9039 258
91 9043 183
139 9052 352
183 9071 148
22 9089 445
45 9101 135
98 9111 1
160 9115 3
88 9126 556
34 9138 25
177 9146 323
6 9155 116
72 9160 99
173 9178 419
147 9193 402
131 9198 472
99 9211 314
20 9226 478
53 9228 348
93 9239 310
102 9245 234
119 9256 349
94 9276 297
83 9293 336
103 9311 514
31 9330 416
48 9337 28
39 9356 542
140 9362 154
110 9367 334
20 9372 369
70 9390 493
177 9400 330
23 9409 17
174 9427 504
143 9432 577
34 9451 500
177 9461 242
15 9465 303
141 9471 393
134 9482 419
138 9498 469
198 9507 528
12 9509 139
124 9530 481
97 9541 453
61 9559 590
29 9578 68
191 9593 431
192 9604 401
175 9614 108
150 9623 214
76 9625 235
124 9630 352
142 9633 118
12 9650 105
113 9659 552
109 9661 214
195 9668 42
24 9686 119
127 9706 303
29 9716 237
43 9734 544
7 9745 147
155 9764 141
52 9770 11
157 9782 271
122 9788 418
6 9806 425
182 9818 277
75 9826 60
83 9832 391
185 9836 377
91 9849 90
194 9866 122
39 9884 399
157 9902 199
168 9908 169
154 9919 248
77 9933 513
190 9936 184
108 9948 457
109 9955 329
59 9964 468
150 9976 473
24 9986 567
33 9992 69
198 9994 521
13 9996 511
152 10002 178
87 10017 141
28 10025 287
10 10041 116
193 10058 549
46 10060 191
77 10061 66
30 10077 265
116 10091 324
87 10104 31
21 10123 332
1 10127 356
79 10147 166
176 10152 252
59 10154 300
137 10160 369
148 10175 504
181 10183 539
144 10198 293
129 10211 151
135 10214 92
146 10228 374
180 10244 516
187 10262 535
88 10263 95
70 10267 359
186 10279 502
191 10285 487
14 10303 480
68 10313 528
3 10320 242
79 10333 504
121 10341 377
29 10359 125
81 10366 227
15 10376 426
123 10392 18
66 10401 171
17 10407 374
150 10416 63
149 10421 223
46 10431 302
63 10444 195
32 10450 538
8 10468 422
111 10484 73
134 10491 598
198 10508 567
180 10518 473
30 10533 374
18 10540 571
71 10556 68
170 10572 527
141 10587 462
33 10592 412
40 10596 433
188 10608 365
52 10623 82
8 10624 342
130 10629 209
77 10645 408
141 10666 204
14 10671 198
186 10677 130
51 10685 224
134 10689 266
50 10697 281

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>

struct process
{
int start;
int size;
int duration;
int startinmemory;
int active;
};

int main()
{
int size, start, duration;
int memory[3][2048];
int i, j, k;
int t;
int found;
int holestart, holesize, minsize, maxsize;
int cnt;
int failed[3];
FILE * f;
struct process processes[3][1000];

       // Load processes from file to array
       f = fopen("Processes.txt", "r");
i = 0;
while (fscanf(f, " %d %d %d", &size, &start, &duration) > 0)
{
for (j = 0; j < 3; j++)
{
processes[j][i].size = size;
processes[j][i].start = start;
processes[j][i].duration = duration;
processes[j][i].active = 0;
}
i++;
}
fclose(f);...

By purchasing this solution you'll be able to access the following files:
SolutionProcesses.txt and Solution.c.

50% discount

Hours
Minutes
Seconds
$18.00 $9.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats