-
Notifications
You must be signed in to change notification settings - Fork 17
/
test_prog.html
581 lines (512 loc) · 26 KB
/
test_prog.html
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ExpL Test Programs</title>
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="img/favicon.jpg" />
<!-- CSS
================================================== -->
<!-- Bootstrap css file-->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Font awesome css file-->
<link href="css/font-awesome.min.css" rel="stylesheet">
<!-- Superslide css file-->
<link rel="stylesheet" href="css/superslides.css">
<!-- Slick slider css file -->
<link href="css/slick.css" rel="stylesheet">
<!-- smooth animate css file -->
<link rel="stylesheet" href="css/animate.css">
<!-- Elastic grid css file -->
<link rel="stylesheet" href="css/elastic_grid.css">
<!-- Circle counter cdn css file -->
<link rel='stylesheet prefetch' href='css/jquery.circliful.css'>
<!-- Default Theme css file -->
<link id="orginal" href="css/themes/eucalyptus-theme.css" rel="stylesheet">
<!-- Main structure css file -->
<link href="style.css" rel="stylesheet">
<!-- Google fonts -->
<link href='css/opensans.css' rel='stylesheet' type='text/css'>
<link href='css/varela.css' rel='stylesheet' type='text/css'>
<link href='css/montserrat.css' rel='stylesheet' type='text/css'>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!--Css added only for this file to get the line numbers in the code-->
<style type="text/css">
pre {
font-family: monospace;
line-height: 0;
counter-reset: line;
}
pre span {
display: block;
line-height: 1.5rem;
}
pre span:before {
counter-increment: line;
content: counter(line);
display: inline-block;
padding: 0.5em;
margin-right: 0.5em;
border-right: 1px solid #ddd;
}
</style>
</head>
<body>
<!-- BEGAIN PRELOADER -->
<div id="preloader">
<div id="status"> </div>
</div>
<!-- END PRELOADER -->
<!--=========== BEGIN HEADER SECTION ================-->
<header id="header">
<!-- BEGIN MENU -->
<div class="menu_area">
<nav class="navbar navbar-default navbar-fixed-top past-main" role="navigation">
<div class="container">
<div class="navbar-header">
<!-- FOR MOBILE VIEW COLLAPSED BUTTON -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- LOGO -->
<!-- TEXT BASED LOGO -->
<a class="navbar-brand" href="index.html">eXpOS<span>NITC</span></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul id="top-menu" class="nav navbar-nav navbar-right main_nav">
<li><a href="./index.html">Home</a></li>
<li><a href="./documentation.html" target="_blank">Documentation</a></li>
<li><a href="./Roadmap.html" target="_blank">Roadmap</a></li>
<li><a href="faq.html" target="_blank">FAQ</a></li>
<li><a href="About_us.html" target="_blank">About Us</a></li>
</ul>
</div>
</div>
</nav>
</div>
<!-- END MENU -->
</header>
<!--=========== End HEADER SECTION ================-->
<!--=========== BEGIN contents SECTION ================-->
<section>
<div class="container">
<div class="row">
<!-- heading -->
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="heading">
<br /><br /><br />
<h2>ExpL Test Programs</h2>
<br>
<br>
</div>
</div>
<!--end heading-->
<div class="panel-body" id="shell_version_2_p">
<b style="font-size: 20px">1. Test Program 1 (Shell version-II without multiuser)</b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input<b></td>
<td>Executable file name/string "Shutdown"</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Executes given xsm program/halt system if input is "Shutdown"</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> shell version II without the multiuser</p><br>
The code for the test program can be found <a href="test_prog/test_prog_1.html" target="_blank">here</a>
</div>
<div class="panel-body" id="ll">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">2. Test Program 2 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>An integer N and N integers. </td>
</tr>
<tr>
<td><b>Output</b></td>
<td>N integers entered in the input.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program given below implements a linked list for
integers. The program reads an integer N from the console. It then creates a linked list and inserts N
integers entered from console into the linked list in the same order. The program traverses the linked list
and prints data to the console.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_2.html" target="_blank">here</a>
</div>
<div class="panel-body" id="ll_fork">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px; ">3. Test Program 3 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input<b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Integers 1 to 100, not necessarily in the order. </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program creates a linked list with numbers 1 to 100 in
them. The program invokes fork to create a child process. The parent and the child process reads from the
shared linked list with different pointers and prints the data read to the console. Parent process prints
the even numbers 2, 4, 6, 8.. and child process prints 1, 3, 5 .. </p><br>
The code for the test program can be found <a href="test_prog/test_prog_3.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_4">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">4. Test Program 4 (Reader-Writer Program)</b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Integers from 1 to 100, but not necessarily in sequential order.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The reader-writer program provides below has two writers and
one reader. The parent process will create two child processes by invoking <i>fork</i>. The parent and two
child processes share a buffer of one word. At a time only one process can read/write to this buffer. To
acheive this, these three processes use a shared semaphore. A writer process can write to the buffer if it
is empty and the reader process can only read from the buffer if it is full. Before the word in the buffer
is overwritten the reader process must read it and print the word to the console. The parent process is the
reader process and its two children are writers. One child process writes even numbers from 1 to 100 and
other one writes odd numbers from 1 to 100 to the buffer. The parent process reads the numbers and prints
them on to the console.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_4.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_5">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">5. Test Program 5</b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>Name of a data file (String)</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Content of the given file</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program takes names of data files as input and opens the
file first. It then forks to create a child process. The content of the file with shared open instance
(shared LSEEK) will be printed to the terminal concurrently by parent and child. To synchronize the use
open instance between parent and child a semaphore is used.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_5.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_6">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">6. Test Program 6</b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>A file name (String) and permission (Integer)</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Integers from 1 to 100, but not necessarily in sequential order.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program takes a file name and permission as input and
creates a new file with given inputs. It then forks to create two child processes. Similar to Reader-Writer
program seen before, the two child processes act as writers and parent as reader. A file open instances is
shared between two writers and there is separate open instance of the same file for reader. Two writers
will write numbers from 1 to 100 to file - one writer will write even numbers other will write odd numbers
and reader will read from the file and print to the console concurrently. To synchronize the use of the
shared open instance between two writers a semaphore is used. </p><br>
The code for the test program can be found <a href="test_prog/test_prog_6.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_7">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">7. Test Program 7 (Extended Shell)</b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>Built in shell command/ Name of XSM executable file (String)</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Ouput of corresponding to shell command or executable file.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> Shell program given below reads command from console. If the
command is halt, then program will invoke Shutdown system call. If the command is built in shell command,
then shell will read suitable number of arguments from the console and corresponding system call is invoked
from shell itself. If the command is an executable file, shell will fork and exec with the given executable
file. </p>
<p>Note that the shell program should fit in 2 blocks/pages provided in <a href="os_implementation.html"
target="_blank">disk/memory organization</a>. The program given below is optimized to fits in 2
blocks/pages. In order to optimize the code, the program violates some of the type checkings. Even with
type checking errors, the program will still compile and execute correctly. Also some system calls are
invoked with arguments, even though the system call does not need any arguments. This will not cause any
problem as these arguments will simply be ignored in the corresponding system call. </p><br>
The code for the test program can be found <a href="test_prog/test_prog_7.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_8">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">8. Test Program 8 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>Delay Parameter</td>
</tr>
<tr>
<td><b>Output </b></td>
<td>8 integers - PID*100 to PID*100+7. </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program given in above link will first read a delay parameter and then, call the Fork system call and create 12 processes. Each process prints numbers from PID*100 to PID*100 + 7. After printing each number, a delay function is called with the the delay parameter provided. </p><br>
The code for the test program can be found <a href="test_prog/test_prog_8.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_9">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">9. Test Program 9 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output </b></td>
<td>Out of 12 processes created, if N processes complete execution, then N data files each containing 100
consecutive integers (PID-3)*100+1 to (PID-3)*100+100 are created. </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program will create a file with name "num.dat" with open
permission. Integers 1 to 1200 are written to this file and file is closed. The program will then invoke <i>Fork</i>
system call four times, back to back to create 12 processes and Exec system call is invoked with file
"pgm1.xsm". The program for "pgm1.xsm" is provided <a href="test_prog.html#test_program_10" target="_blank">here</a>.
</p><br>
The code for the test program can be found <a href="test_prog/test_prog_9.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_10">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">10. Test Program 10 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output (For each 12 proceesses)</b></td>
<td>A file will be created containing 100 consecutive numbers (PID-3)*100+1 to (PID-3)*100+100 </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> This program can not be run individualy. The test program 9
will invoke Exec with below given program with name "pgm1.xsm". Make sure to compile and save this program
as "pgm1.xsm". Below given program will create a new file according to the PID of the process and read 100
numbers from file "num.dat" from offset (PID-3)*100 to (PID-3)*100+99 and write to newly created file.
After successful execution, there should be 12 data files each containing 100 consecutive numbers
(PID-3)*100+1 to PID-3)*100+100.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_10.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_11">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">11. Test Program 11 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td> - </td>
</tr>
<tr>
<td><b>Output </b></td>
<td> Out of 12 processes created, if N processes complete execution, then N data files each containing
100 consecutive integers from X*1000+1 to X*1000+100 (where X ∈ {3,4..14}) are created. </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The program will create a file with name "numbers.dat" with
open permission and open the file. The program also invokes Semget to acquire a shared semaphore. The
program will then invoke <i>Fork</i> system call four times, back to back to create 12 processes. The 12 processes now share a file open instance and a semaphore. Each process will write 100 numbers
consecutatively (PID*1000+1 to PID*1000+100) to the file "numbers.dat". Exec system call is invoked with
file "pgm2.xsm". The program for "pgm2.xsm" is provided <a href="test_prog.html#test_program_12" target="_blank">here</a>.
</p><br>
The code for the test program can be found <a href="test_prog/test_prog_11.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_12">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">12. Test Program 12 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output (For each 12 proceesses)</b></td>
<td>A file will be created containing 100 consecutive numbers from data file "numbers.dat". </td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> This program can not be run individualy. Test program 11
will invoke Exec with below given program with name "pgm2.xsm". Make sure to compile and save this program
as "pgm2.xsm". Below given program will create a new file according to the PID of the process and read 100
numbers from file "numbers.dat" from offset (PID-3)*100 to (PID-3)*100+99 and write to newly created file.
After successful execution, there should be 12 data files each containing 100 numbers each X*1000
-X*1000+99, where X=[3,4..14]. The numbers written by a process in the newly created file need not be the
same numbers the process has written in "numbers.dat" file.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_12.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_13">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">13. Test Program 13 </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output (For each 8 processes with PID = 2 to 9)</b></td>
<td>Return values from Fork system call and integers from PID*100 to PID*100+9.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> This program calls fork 3 times creating 8 child processes.
Each process prints the value returned from the last Fork system call and Exec system call is invoked with
file "child.xsm". The "child.xsm" program stores numbers from PID*100 to PID*100+9 onto a linked list and
prints them to the console. </p><br>
The code for the <i>parent.expl</i> can be found <a href="test_prog/test_prog_13a.html" target="_blank">here</a> and the code for the <i>child.expl</i> can be found <a href="test_prog/test_prog_13b.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_14">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">14. Test Program 14 (Merge Sort) </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Print numbers from 1 to 64 in ascending order.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> These two ExpL programs perform merge sort in two different
ways. The first one is done in a sequential manner and the second one, in a concurrent approach. Values
from 1 to 64 are stored in decreasing order in a linked list and are sorted using a recursive merge sort
function. In the concurrent approach, the process is forked and the merge sort function is called
recursively for the two sub-lists from the two child processes. </p><br>
The code for the Sequential approach can be found <a href="test_prog/test_prog_14a.html" target="_blank">here</a> and the code for the Concurrent approach can be found <a href="test_prog/test_prog_14b.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_15">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">15. Test Program 15 (Merge Files) </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Creates a file <i>merge.dat</i> with numbers from 1 to 2048.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The ExpL program first creates 4 files with values from s to
4*c+s, where s=[1..4] and c=[0..511]. The program then, merges the 4 files taking 2 at a time, and finally, creates a <i>merge.dat</i> file containing numbers from 1 to 2048.</p><br>
The code for the test program can be found <a href="test_prog/test_prog_15.html" target="_blank">here</a>
</div>
<div class="panel-body" id="test_program_16">
<br><br>
<hr>
<br><br>
<b style="font-size: 20px;">16. Test Program 16 (Merge Sort with Files) </b><br><br>
<table class="table table-bordered">
<tr>
<td><b>Input</b></td>
<td>-</td>
</tr>
<tr>
<td><b>Output</b></td>
<td>Creates a file <i>merge.dat</i> with numbers from 1 to 512 and also prints them.</td>
</tr>
</table>
<p style="text-indent: 0px"><b>Description :</b> The first ExpL program, <i>merge.expl</i>, first stores numbers from 1 to 512 in a random order into a file <i>merge.dat</i>. It then forks and executes <i>m_store.expl</i> which creates 8 files <i>temp{i}.dat</i>, where i=1..8 and stores 64 numbers each from <i>merge.expl</i>. Then, all the temporary files are sorted by executing <i>m_sort.expl</i>. Next, the first ExpL program forks and executes <i>m_merge.expl</i> which merges all the temporary files back into <i>merge.dat</i> and finally, prints the contents from 1 to 512 in ascending order.
</p><br>
The test programs are <a href="test_prog/test_prog_16a.html" target="_blank">merge.expl</a>, <a href="test_prog/test_prog_16b.html" target="_blank">m_store.expl</a>, <a href="test_prog/test_prog_16c.html" target="_blank">m_sort.expl</a> and <a href="test_prog/test_prog_16d.html" target="_blank">m_merge.expl</a>
</div>
</div>
</div>
</section>
<!--=========== END SECTION ================-->
<!--=========== BEGIN FOOTER ================-->
<footer id="footer">
<div class="container">
<div class="row">
<a style="float: right" rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License"
style="border-width:0" src="./img/creativecommons.png" /></a>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="footer_left">
<p><a href="http://www.nitc.ac.in/">National Institute of Technology, Calicut</a></p>
</div>
</div>
</div>
</div>
</footer>
<!--=========== END FOOTER ================-->
<!-- Javascript Files
================================================== -->
<!-- initialize jQuery Library -->
<script src="js/jquery.min.js"></script>
<!-- Google map -->
<script src="js/map_js.js"></script>
<script src="js/jquery.ui.map.js"></script>
<!-- For smooth animatin -->
<script src="js/wow.min.js"></script>
<!-- Bootstrap js -->
<script src="js/bootstrap.min.js"></script>
<!-- superslides slider -->
<script src="js/jquery.superslides.min.js" type="text/javascript"></script>
<!-- slick slider -->
<script src="js/slick.min.js"></script>
<!-- for circle counter -->
<script src='js/jquery.circliful.min.js'></script>
<!-- for portfolio filter gallery -->
<script src="js/modernizr.custom.js"></script>
<script src="js/classie.js"></script>
<script src="js/elastic_grid.min.js"></script>
<script src="js/portfolio_slider.js"></script>
<!-- Custom js-->
<script src="js/custom.js"></script>
</body>
</html>