Skip to content

Commit a263e85

Browse files
style and some erros handled
1 parent 6b60732 commit a263e85

3 files changed

Lines changed: 178 additions & 49 deletions

File tree

index.html

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ <h1>💻 VOS - VIRTUAL OPERATING SYSTEM SIMULATOR</h1>
3636
></textarea>
3737
</div>
3838

39-
4039
<!-- Execution Control Panel -->
41-
40+
4241
<div class="execution-control-panel">
4342
<div class="panel">
4443
<div class="panel-title">Execution Control</div>
@@ -52,8 +51,10 @@ <h1>💻 VOS - VIRTUAL OPERATING SYSTEM SIMULATOR</h1>
5251
<div class="speed-control">
5352
<label for="speedRange">
5453
Execution Delay :
55-
<br>
56-
<small>Increasing this value slows down the simulation.</small>
54+
<br />
55+
<small
56+
>Increasing this value slows down the simulation.</small
57+
>
5758
</label>
5859
<input
5960
type="range"
@@ -124,11 +125,14 @@ <h1>💻 VOS - VIRTUAL OPERATING SYSTEM SIMULATOR</h1>
124125
<div class="panel" id="pcb-display">
125126
<div class="panel-title">Process Control Block</div>
126127
<div class="pcb-grid">
127-
<div class="pcb-item">Execution Summary</div>
128128
<div class="pcb-item">
129129
<div class="pcb-label">PROCESS ID</div>
130130
<div class="pcb-value">-</div>
131131
</div>
132+
<div class="pcb-item">
133+
<div class="pcb-label">INSTRUCTION COUNT</div>
134+
<div class="pcb-value">-</div>
135+
</div>
132136
<div class="pcb-item">
133137
<div class="pcb-label">TIME LIMIT</div>
134138
<div class="pcb-value">-</div>
@@ -170,9 +174,12 @@ <h1>💻 VOS - VIRTUAL OPERATING SYSTEM SIMULATOR</h1>
170174
After Execution -> Hover over memory cells to see their purpose and
171175
details.
172176
</p>
173-
<p class="hover-instruction">
174-
Reset the simulator to run a new job card.
175-
</p>
177+
<p class="hover-instruction">Reset the simulator to run a new job card.</p>
178+
179+
<footer>
180+
<p>&copy; virtual operating system simulator | <a href="https://github.com/ovuiproduction">@ovuiproduction</a></p>
181+
<p class="footer-tagline">💻 Made with passion 💻</p>
182+
</footer>
176183

177184
<!-- Instructions Modal -->
178185
<div class="modal-overlay" id="modalOverlay"></div>
@@ -183,6 +190,9 @@ <h2>VOS SIMULATOR - INSTRUCTIONS</h2>
183190
After Execution -> Hover over memory cells to see their purpose and
184191
details.
185192
</p>
193+
<p class="hover-instruction">
194+
Try job with errors to see error handling in action!
195+
</p>
186196
<h3 style="margin-top: 20px; color: var(--accent-yellow)">
187197
System Assumptions:
188198
</h3>
@@ -221,13 +231,15 @@ <h3 style="margin-top: 20px; color: var(--accent-yellow)">
221231
<li><strong>4</strong> - Operation Code Error</li>
222232
<li><strong>5</strong> - Operand Error</li>
223233
<li><strong>6</strong> - Invalid Page Fault</li>
234+
<li><strong>7</strong> - Instruction Limit Exceeded</li>
224235
</ul>
225236
</div>
226237

227238
<!-- Job Card Modal -->
228239
<div class="modal" id="jobCardBlock">
229240
<span class="modal-close" id="jobCardClose"></span>
230241
<h2>Job Card Format</h2>
242+
<p class="hover-instruction">In one job only 10 instructions allowed</p>
231243
<p>Each job card consists of the following sections:</p>
232244
<ul>
233245
<li>
@@ -265,7 +277,7 @@ <h2>Job Card Format</h2>
265277
<div class="job-example-list">
266278
<h2>Example Job Card:</h2>
267279
<div>
268-
<h4>Print VIT</h4>
280+
<h4>1️⃣Print VIT</h4>
269281
<p>
270282
$AMJ000100040001 <br />
271283
GD10PD10H <br />
@@ -275,7 +287,18 @@ <h4>Print VIT</h4>
275287
</p>
276288
</div>
277289
<div>
278-
<h4>Load Store and Print</h4>
290+
<h4>2️⃣ Multiple GD, PD operations</h4>
291+
<p>
292+
$AMJ000100040001 <br />
293+
GD10GD20PD10H <br />
294+
$DTA <br />
295+
VIT <br />
296+
VIIT <br />
297+
$END0001 <br />
298+
</p>
299+
</div>
300+
<div>
301+
<h4>3️⃣ Load Store and Print</h4>
279302
<p>
280303
$AMJ000200070001 <br />
281304
GD10LR10SR20PD10H <br />
@@ -285,7 +308,7 @@ <h4>Load Store and Print</h4>
285308
</p>
286309
</div>
287310
<div>
288-
<h4>Multiple Load Store oprations</h4>
311+
<h4>4️⃣ Multiple Load Store oprations</h4>
289312
<p>
290313
$AMJ000300130001 <br />
291314
GD20GD30GD40GD50LR20SR60PD60H <br />
@@ -297,17 +320,90 @@ <h4>Multiple Load Store oprations</h4>
297320
$END0003 <br />
298321
</p>
299322
</div>
323+
</div>
324+
325+
<div class="job-example-list">
326+
<h2>⚠️ Example Jobs with Errors</h2>
327+
328+
<!-- 1 - Out Of Data -->
329+
<div>
330+
<h4>1️⃣ Out Of Data</h4>
331+
<p>
332+
$AMJ000100070001 <br />
333+
GD10GD20GD30H <br />
334+
$DTA <br />
335+
INPUT1 <br />
336+
INPUT2 <br />
337+
$END0001 <br />
338+
<!-- ❌ GD30 tries to read third data line but only 2 are provided -->
339+
</p>
340+
</div>
341+
342+
<!-- 2 - Line Limit Exceeded -->
343+
<div>
344+
<h4>2️⃣ Line Limit Exceeded</h4>
345+
<p>
346+
$AMJ000200080001 <br />
347+
GD10PD10PD10PD10PD10PD10H <br />
348+
$DTA <br />
349+
HELLO <br />
350+
$END0002 <br />
351+
<!-- ❌ More print operations than allowed by line limit (04) -->
352+
</p>
353+
</div>
354+
355+
<!-- 3 - Time Limit Exceeded -->
356+
<div>
357+
<h4>3️⃣ Time Limit Exceeded</h4>
358+
<p>
359+
$AMJ000300130001 <br />
360+
GD10PD10GD20PD20GD30PD30GD40PD40H <br />
361+
$DTA <br />
362+
DATA1 <br />
363+
DATA2 <br />
364+
DATA3 <br />
365+
DATA4 <br />
366+
$END0003 <br />
367+
<!-- ❌ Too many instructions for time limit (02) -->
368+
</p>
369+
</div>
370+
371+
<!-- 4 - Operation Code Error -->
300372
<div>
301-
<h4>Compare Strings</h4>
373+
<h4>4️⃣ Operation Code Error</h4>
302374
<p>
303-
$AMJ000400150001 <br />
304-
GD10GD20GD30GD40LR10CR20BT09PD30HPD40H <br />
375+
$AMJ000400060001 <br />
376+
XY10PD10H <br />
377+
$DTA <br />
378+
TESTDATA <br />
379+
$END0004 <br />
380+
<!-- ❌ XY10 is not a valid operation code -->
381+
</p>
382+
</div>
383+
384+
<!-- 5 - Operand Error -->
385+
<div>
386+
<h4>5️⃣ Operand Error</h4>
387+
<p>
388+
$AMJ000500040001 <br />
389+
GD1APD10H <br />
305390
$DTA <br />
306391
VIT <br />
392+
$END0005 <br />
393+
<!-- ❌ Operand "1A" is invalid (must be two digits) -->
394+
</p>
395+
</div>
396+
397+
<!-- 6 - Invalid Page Fault -->
398+
<div>
399+
<h4>6️⃣ Invalid Page Fault</h4>
400+
<p>
401+
$AMJ000600050001 <br />
402+
GD10LR90PD10H <br />
403+
$DTA <br />
307404
VIT <br />
308-
NOT SAME <br />
309-
SAME <br />
310-
$END0004 <br />
405+
$END0006 <br />
406+
<!-- ❌ LR90 tries to access a non-existing page (invalid address) -->
311407
</p>
312408
</div>
313409
</div>

script.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class opsys {
167167
this.rd = 0;
168168
this.function = "";
169169
this.opAdd = 0;
170+
this.instructionCount = 0;
170171

171172
this.pcb = {
172173
pid: 0,
@@ -181,10 +182,13 @@ class opsys {
181182
result.innerHTML = `
182183
<div class="panel-title">Process Control Block</div>
183184
<div class="pcb-grid">
184-
<div class="pcb-item">Execution Summary</div>
185185
<div class="pcb-item">
186186
<div class="pcb-label">PROCESS ID</div>
187187
<div class="pcb-value">${this.pcb.pid}</div>
188+
</div>
189+
<div class="pcb-item">
190+
<div class="pcb-label">Instruction Count</div>
191+
<div class="pcb-value">${this.instructionCount}</div>
188192
</div>
189193
<div class="pcb-item">
190194
<div class="pcb-label">TIME LIMIT</div>
@@ -224,6 +228,7 @@ class opsys {
224228
"Operation Code Error - Invalid instruction",
225229
"Operand Error - Invalid operand value",
226230
"Invalid Page Fault - Page fault error",
231+
"Instruction Limit Exceeded - More than 10 instructions in a job",
227232
];
228233

229234
outputblock.innerHTML = `
@@ -288,7 +293,13 @@ class opsys {
288293
var row = this.rd;
289294
var dataArray = [];
290295

296+
if(datacount >= data.length){
297+
this.errmsg(1);
298+
await this.Terminate();
299+
throw new Error("Out of data");
300+
}
291301
addLog(`Reading data from input buffer: "${data[datacount]}"`, "log-data");
302+
292303
await sleep(executionDelay);
293304

294305
for (let i = 0; i < data[datacount].length; i++) {
@@ -751,11 +762,6 @@ class opsys {
751762

752763
addLog(`Job Card Loaded - PID: ${this.pcb.pid}, Time Limit: ${this.pcb.ttl}, Line Limit: ${this.pcb.tll}`, "log-success");
753764

754-
// const pcbItems = document.querySelectorAll(".job-details .pcb-item .pcb-value");
755-
// pcbItems[0].textContent = this.pcb.pid;
756-
// pcbItems[1].textContent = this.pcb.ttl;
757-
// pcbItems[2].textContent = this.pcb.tll;
758-
759765
await sleep(executionDelay);
760766
continue;
761767
} else if (cardID === "$DTA") {
@@ -815,7 +821,7 @@ class opsys {
815821
var inst = line;
816822
var row = progei * 10;
817823
var singleInstruction = [];
818-
824+
819825
addLog(`Loading instructions to memory blocks ${row}-${row + 9}`, "log-action");
820826
highlightMemoryBlock(row, row + 9);
821827
await sleep(executionDelay);
@@ -843,6 +849,7 @@ class opsys {
843849
}
844850
row++;
845851
singleInstruction = [];
852+
this.instructionCount++;
846853
} else {
847854
singleInstruction.push(inst.charAt(j));
848855

@@ -856,9 +863,16 @@ class opsys {
856863
}
857864
row++;
858865
singleInstruction = [];
866+
this.instructionCount++;
859867
}
860868
}
861869
}
870+
if(this.instructionCount>10){
871+
addLog(`Instruction limit exceeded: ${this.instructionCount} > 10`, "log-error");
872+
this.errmsg(7);
873+
await this.Terminate();
874+
throw new Error("Instruction limit exceeded");
875+
}
862876
addLog(`Instructions loaded: ${inst}`, "log-data");
863877
await sleep(executionDelay);
864878
}

0 commit comments

Comments
 (0)