-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm_visual.html
More file actions
2614 lines (2401 loc) · 118 KB
/
vm_visual.html
File metadata and controls
2614 lines (2401 loc) · 118 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
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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Virtual Memory — Interactive Visualization</title>
<style>
/* ── Reset & tokens ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d1117;
--s1: #161b22;
--s2: #21262d;
--border: #30363d;
--b2: #21262d;
--blue: #58a6ff;
--blue-bg: #0d2443;
--green: #3fb950;
--grn-bg: #0a2218;
--amber: #d29922;
--amb-bg: #271d06;
--red: #f85149;
--red-bg: #2a0d0d;
--purple: #bc8cff;
--pur-bg: #1a0d2e;
--text: #e6edf3;
--tsec: #8b949e;
--tdim: #484f58;
}
body {
background: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-size: 12px;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
min-width: 1100px;
}
/* ── Header ─────────────────────────────────────────────────────────────────── */
#hdr {
flex-shrink: 0;
background: #010409;
border-bottom: 1px solid var(--border);
padding: 0 10px;
height: 40px;
display: flex;
align-items: center;
gap: 7px;
overflow-x: auto;
}
#hdr-logo {
font-size: 12px;
font-weight: 600;
color: var(--text);
white-space: nowrap;
display: flex;
align-items: center;
gap: 6px;
}
.hdr-div { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }
.ctrl-row { display: flex; align-items: center; gap: 4px; }
.ctrl-lbl { color: var(--tsec); font-size: 10px; white-space: nowrap; }
select, .btn {
background: var(--s1);
border: 1px solid var(--border);
color: var(--text);
font-family: inherit;
font-size: 11px;
padding: 2px 6px;
border-radius: 5px;
cursor: pointer;
transition: border-color 0.15s, background 0.15s;
}
select:hover, .btn:hover { border-color: var(--tsec); }
.btn:disabled { color: var(--tdim); cursor: default; }
.btn.primary { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.btn.primary:hover { background: #1a3a6e; }
.btn.primary.playing { background: #270d0d; border-color: var(--red); color: var(--red); }
/* Narrative header */
#nar-title {
font-size: 10px; font-weight: 600;
color: var(--tsec);
letter-spacing: 0.06em;
text-transform: uppercase;
margin-bottom: 5px;
}
.step-badge {
background: var(--s2);
border: 1px solid var(--border);
border-radius: 5px;
padding: 2px 7px;
font-size: 10px;
color: var(--tsec);
white-space: nowrap;
}
.step-badge span { color: var(--text); font-weight: 600; }
#speed-wrap { display: flex; align-items: center; gap: 4px; }
#speed { width: 55px; accent-color: var(--blue); }
.kbd { margin-left: auto; color: var(--tdim); font-size: 9px; white-space: nowrap; }
.kbd kbd {
background: var(--s2); border: 1px solid var(--border);
border-radius: 3px; padding: 1px 3px; font-size: 9px;
font-family: inherit;
}
/* ── Main area ───────────────────────────────────────────────────────────────── */
#main {
flex: 1;
display: grid;
grid-template-columns: 175px 1fr 205px 185px;
overflow: hidden;
position: relative;
min-height: 0;
}
/* ── Arrow SVG overlay ──────────────────────────────────────────────────────── */
#arrows {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 20;
overflow: visible;
}
/* ── Column chrome ───────────────────────────────────────────────────────────── */
.col {
display: flex;
flex-direction: column;
border-right: 1px solid var(--border);
overflow: hidden;
min-height: 0;
}
.col:last-child { border-right: none; }
.col-hdr {
flex-shrink: 0;
padding: 10px 12px 8px;
border-bottom: 1px solid var(--border);
background: #0c1117;
}
.col-hdr h3 {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--tsec);
}
.col-hdr p {
font-size: 10px;
color: var(--tdim);
margin-top: 2px;
line-height: 1.4;
}
.col-body {
flex: 1;
overflow-y: auto;
overflow-x: hidden;
padding: 8px;
}
.col-body::-webkit-scrollbar { width: 4px; }
.col-body::-webkit-scrollbar-track { background: transparent; }
.col-body::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }
/* ── Virtual Address Space ───────────────────────────────────────────────────── */
#col-vas .col-hdr h3 { color: var(--blue); }
.vas-proc-tabs { display: flex; gap: 0; margin-bottom: 6px; }
.vas-tab {
flex: 1; padding: 3px 6px; text-align: center;
font-size: 10px; cursor: pointer; color: var(--tdim);
border: 1px solid var(--border); border-right: none; background: var(--s2);
}
.vas-tab:last-child { border-right: 1px solid var(--border); }
.vas-tab.active { color: var(--blue); background: var(--blue-bg); border-color: var(--blue); }
.vas-tab:first-child { border-radius: 4px 0 0 4px; }
.vas-tab:last-child { border-radius: 0 4px 4px 0; }
.vma-legend { margin-bottom: 8px; }
.vma-leg-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--tsec); margin-bottom: 2px; }
.vma-leg-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.vp-list { display: flex; flex-direction: column; gap: 1px; }
.vp-row {
display: flex;
align-items: center;
gap: 6px;
padding: 3px 6px;
border-radius: 4px;
border: 1px solid transparent;
transition: background 0.12s, border-color 0.12s;
cursor: default;
min-height: 26px;
position: relative;
}
.vp-row .vp-num { font-family: monospace; font-size: 11px; color: var(--tdim); min-width: 18px; text-align: right; }
.vp-row .vp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.vp-row .vp-addr { font-family: monospace; font-size: 10px; color: var(--tdim); }
.vp-row .vp-fl { font-size: 9px; color: var(--tdim); margin-left: auto; }
.vp-novma { }
.vp-novma .vp-dot { background: var(--b2); }
.vp-miss { }
.vp-miss .vp-dot { background: var(--s2); border: 1px solid var(--border); }
.vp-miss .vp-num, .vp-miss .vp-addr { color: var(--tdim); }
.vp-present .vp-dot { background: var(--green); }
.vp-present .vp-num { color: var(--text); }
.vp-present .vp-addr { color: var(--tsec); }
.vp-dirty .vp-dot { background: var(--amber); }
.vp-dirty .vp-num { color: var(--text); }
.vp-dirty .vp-addr { color: var(--tsec); }
.vp-swap .vp-dot { background: var(--amber); }
.vp-swap .vp-num { color: var(--amber); }
.vp-swap .vp-addr { color: var(--tdim); }
.vp-active {
background: var(--blue-bg) !important;
border-color: var(--blue) !important;
}
.vp-active .vp-num { color: var(--blue) !important; }
.vp-active .vp-addr { color: var(--blue) !important; }
/* VMA left-border stripe */
.vma-stripe {
position: absolute; left: 0; top: 2px; bottom: 2px;
width: 3px; border-radius: 2px;
}
/* ── Page Table ───────────────────────────────────────────────────────────────── */
#col-pt .col-hdr h3 { color: var(--tsec); }
.pt-proc-hdr {
font-size: 10px; font-weight: 600; color: var(--tsec);
display: flex; align-items: center; gap: 5px;
padding-bottom: 4px; margin-bottom: 4px;
border-bottom: 1px solid var(--border);
}
.pt-proc-hdr::before {
content: '';
display: inline-block;
width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0;
background: linear-gradient(135deg, #1a3a20, #2e6040);
}
#pt-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
font-size: 11px;
}
#pt-table thead th {
padding: 4px 6px;
text-align: left;
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--tdim);
border-bottom: 1px solid var(--border);
white-space: nowrap;
position: sticky;
top: 0;
background: #0d1117;
z-index: 2;
}
#pt-table tbody tr {
border-bottom: 1px solid var(--b2);
transition: background 0.1s;
}
#pt-table tbody tr:hover { background: var(--s2); }
#pt-table td {
padding: 3px 6px;
vertical-align: middle;
white-space: nowrap;
}
.pt-vpn { font-family: monospace; font-weight: 600; color: var(--blue); }
.pt-addr { font-family: monospace; color: var(--tdim); font-size: 10px; }
.pt-frame { font-family: monospace; font-weight: 600; }
.pt-frame.present { color: var(--green); }
.pt-frame.swapped { color: var(--amber); }
.pt-frame.fault { color: var(--tdim); }
.status-pill {
display: inline-flex; align-items: center; gap: 3px;
padding: 1px 6px;
border-radius: 10px;
font-size: 10px;
font-weight: 500;
white-space: nowrap;
}
.pill-ram { background: var(--grn-bg); color: var(--green); border: 1px solid #1a5c28; }
.pill-fault { background: #1a0808; color: var(--tsec); border: 1px solid var(--b2); }
.pill-swap { background: var(--amb-bg); color: var(--amber); border: 1px solid #4a3008; }
.pill-novma { background: var(--s2); color: var(--tdim); border: 1px solid var(--b2); }
.pill-segv { background: var(--red-bg); color: var(--red); border: 1px solid #5a1a1a; }
.pill-wp { background: var(--blue-bg); color: var(--blue); border: 1px solid #1a3a6e; }
.pill-fm { background: var(--pur-bg); color: var(--purple); border: 1px solid #3a1a6e; }
.bit-dot {
display: inline-block;
width: 10px; height: 10px;
border-radius: 50%;
vertical-align: middle;
}
.bit-on-R { background: var(--green); }
.bit-on-M { background: var(--amber); }
.bit-off { background: var(--b2); border: 1px solid var(--border); }
.pt-row-active {
background: var(--blue-bg) !important;
}
.pt-row-active .pt-vpn, .pt-row-active .pt-addr { color: var(--blue) !important; }
/* ── Physical Memory — single RAM chip ───────────────────────────────────────── */
#col-ram .col-hdr h3 { color: var(--green); }
.ram-util {
font-size: 10px; color: var(--tsec); margin-bottom: 6px;
display: flex; gap: 6px; align-items: center;
}
.ram-bar-bg { flex: 1; height: 4px; background: var(--s2); border-radius: 2px; }
.ram-bar-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.2s; }
/* One chip housing wrapping all frame rows */
.ram-chip {
border: 1px solid #2a4830;
border-radius: 5px;
background: linear-gradient(175deg, #0b1c0e 0%, #070f08 100%);
padding: 6px 5px 5px;
position: relative;
overflow: hidden;
}
/* subtle IC-chip label across the top of the housing */
.ram-chip::before {
content: 'DRAM 64-BIT 4 KiB / FRAME';
display: block;
font-family: monospace;
font-size: 8px;
letter-spacing: 0.15em;
color: #253e28;
text-align: center;
margin-bottom: 5px;
border-bottom: 1px solid #162019;
padding-bottom: 4px;
}
/* pin-row decorations along left and right edges */
.ram-chip::after {
content: '';
position: absolute;
top: 28px; bottom: 5px; left: 0; right: 0;
background:
repeating-linear-gradient(180deg, #1a2e1c 0px, #1a2e1c 3px, transparent 3px, transparent 6px) 0 0 / 5px 100% no-repeat,
repeating-linear-gradient(180deg, #1a2e1c 0px, #1a2e1c 3px, transparent 3px, transparent 6px) 100% 0 / 5px 100% no-repeat;
pointer-events: none;
}
.frame-list { display: flex; flex-direction: column; gap: 1px; }
/* Individual address row inside the chip */
.frame-cell {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 6px 4px 8px;
border-radius: 2px;
border: 1px solid #0e1c10;
border-left: 2px solid #162419;
background: #060d07;
transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
min-height: 30px;
position: relative;
}
.frame-cell.free {
opacity: 0.45;
}
/* Process color — left accent */
.frame-cell.p0 { border-left: 2px solid var(--green); background: #060e07; }
.frame-cell.p1 { border-left: 2px solid var(--blue); background: #05090f; }
.frame-cell.p2 { border-left: 2px solid var(--purple); background: #080610; }
.frame-cell.p3 { border-left: 2px solid var(--red); background: #0c0606; }
.frame-num {
font-family: monospace; font-size: 9px; color: #2e4a30;
min-width: 26px;
letter-spacing: 0.03em;
}
.frame-content { flex: 1; }
.frame-pid-vp { font-family: monospace; font-size: 11px; font-weight: 600; }
.frame-cell.p0 .frame-pid-vp { color: var(--green); }
.frame-cell.p1 .frame-pid-vp { color: var(--blue); }
.frame-cell.p2 .frame-pid-vp { color: var(--purple); }
.frame-cell.p3 .frame-pid-vp { color: var(--red); }
.frame-free-lbl { font-size: 10px; color: #1e3020; }
.frame-vaddr { font-family: monospace; font-size: 9px; color: #253a27; }
/* Dirty-bit LED */
.frame-dirty-dot {
width: 6px; height: 6px; border-radius: 50%;
flex-shrink: 0;
}
.frame-dirty-dot.dirty {
background: var(--amber);
box-shadow: 0 0 4px rgba(210,153,34,0.7);
}
.frame-dirty-dot.clean {
background: #0c1a0e;
border: 1px solid #182c1a;
}
/* Highlight states */
.frame-cell.frame-active {
border-left-color: var(--blue) !important;
background: #040c18 !important;
box-shadow: inset 0 0 8px rgba(88,166,255,0.08) !important;
}
.frame-cell.frame-mapped {
border-left-color: var(--green) !important;
background: #051008 !important;
box-shadow: inset 0 0 8px rgba(63,185,80,0.07) !important;
}
.frame-cell.frame-evicted {
border-left-color: var(--amber) !important;
background: #100c04 !important;
box-shadow: inset 0 0 8px rgba(210,153,34,0.06) !important;
}
/* ── Disk — realistic HDD SVG ────────────────────────────────────────────────── */
#col-disk .col-hdr h3 { color: var(--amber); }
/* Groups the HDD graphic + swap/file sections to show they share the same disk */
.disk-storage-group {
position: relative;
border: 1px solid #222228;
border-radius: 6px;
padding: 6px 5px 5px;
}
.disk-storage-group::before {
content: 'on-disk storage';
position: absolute;
top: -7px; left: 8px;
font-size: 8px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
color: var(--tdim); background: var(--s1); padding: 0 4px;
}
.disk-visual { margin-bottom: 8px; }
.hdd-svg { display: block; margin: 0 auto; border-radius: 8px; overflow: visible; }
/* HDD arm seek is driven by JS (animateArm) — see script section */
@keyframes head-pulse {
0%, 100% { opacity: 0.65; }
50% { opacity: 1; }
}
@keyframes platter-sheen {
0%, 100% { opacity: 0.04; }
50% { opacity: 0.10; }
}
.disk-active .hdd-head-glow { animation: head-pulse 0.4s ease-in-out infinite; }
.disk-active .hdd-arm-body { stroke: #b07820; }
.disk-active .hdd-sheen { animation: platter-sheen 0.4s ease-in-out infinite; }
.disk-sec-title {
font-size: 10px;
font-weight: 600;
color: var(--tsec);
padding-left: 6px;
border-left: 2px solid transparent;
margin-bottom: 5px;
padding-bottom: 4px;
border-bottom: 1px solid var(--border);
display: flex;
justify-content: space-between;
}
.disk-sec-title .cnt { color: var(--tdim); font-weight: 400; }
.disk-sec-title.swap-title { color: var(--amber); border-left-color: var(--amber); }
.disk-sec-title.file-title { color: var(--purple); border-left-color: var(--purple); }
.disk-legend {
display: flex;
justify-content: center;
gap: 10px;
font-size: 9px;
font-weight: 600;
letter-spacing: 0.04em;
margin: 4px 0 8px;
}
.disk-legend-swap { color: var(--amber); }
.disk-legend-file { color: var(--purple); }
.swap-grid, .file-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 3px;
margin-bottom: 10px;
}
/* ── Disk block / sector cards ── */
.swap-slot, .file-slot {
position: relative;
padding: 5px 6px 9px;
border-radius: 3px;
font-family: monospace;
overflow: hidden;
transition: border-color 0.15s, box-shadow 0.15s;
cursor: default;
}
/* Binary data stripe at bottom (simulates sector data density) */
.swap-slot::after, .file-slot::after {
content: '';
position: absolute;
bottom: 2px; left: 4px; right: 4px; height: 3px;
border-radius: 1px;
}
.slot-addr {
font-size: 7.5px;
letter-spacing: 0.06em;
margin-bottom: 2px;
opacity: 0.65;
}
.slot-content {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.02em;
}
.slot-type {
position: absolute;
top: 4px; right: 5px;
font-size: 6.5px;
letter-spacing: 0.08em;
opacity: 0.45;
}
/* Swap (anonymous dirty pages) */
.swap-slot {
border: 1px solid #3a2608;
background: linear-gradient(160deg, #1a0e04 0%, #0e0802 100%);
}
.swap-slot::after {
background: repeating-linear-gradient(90deg,
rgba(210,153,34,0.55) 0px, rgba(210,153,34,0.55) 2px,
rgba(210,153,34,0.12) 2px, rgba(210,153,34,0.12) 3.5px,
rgba(210,153,34,0.40) 3.5px, rgba(210,153,34,0.40) 5px,
rgba(210,153,34,0.08) 5px, rgba(210,153,34,0.08) 7px
);
}
.swap-slot .slot-addr { color: #8a6018; }
.swap-slot .slot-content { color: var(--amber); }
.swap-slot .slot-type { color: var(--amber); }
.swap-slot.new {
border-color: var(--amber) !important;
box-shadow: 0 0 0 1px rgba(210,153,34,0.3), inset 0 0 12px rgba(210,153,34,0.08) !important;
animation: blk-in 0.45s ease;
}
.swap-slot.read {
border-color: var(--blue) !important;
box-shadow: 0 0 0 1px rgba(88,166,255,0.3) !important;
animation: blk-out 0.45s ease;
}
/* File store (file-mapped dirty pages) */
.file-slot {
border: 1px solid #321670;
background: linear-gradient(160deg, #180a2e 0%, #0e0620 100%);
}
.file-slot::after {
background: repeating-linear-gradient(90deg,
rgba(188,140,255,0.50) 0px, rgba(188,140,255,0.50) 2px,
rgba(188,140,255,0.10) 2px, rgba(188,140,255,0.10) 3.5px,
rgba(188,140,255,0.35) 3.5px, rgba(188,140,255,0.35) 5px,
rgba(188,140,255,0.07) 5px, rgba(188,140,255,0.07) 7px
);
}
.file-slot .slot-addr { color: #7a4ab0; }
.file-slot .slot-content { color: var(--purple); }
.file-slot .slot-type { color: var(--purple); }
.file-slot.new {
border-color: var(--purple) !important;
box-shadow: 0 0 0 1px rgba(188,140,255,0.3), inset 0 0 12px rgba(188,140,255,0.08) !important;
animation: blk-in 0.45s ease;
}
.file-slot.read {
border-color: var(--blue) !important;
box-shadow: 0 0 0 1px rgba(88,166,255,0.3) !important;
animation: blk-out 0.45s ease;
}
.disk-empty-msg { font-size: 10px; color: var(--tdim); font-style: italic; padding: 4px 0 8px; }
@keyframes blk-in { from { opacity:0; transform:translateY(-4px) scale(0.92); } to { opacity:1; transform:none; } }
@keyframes blk-out { from { opacity:0.6; } to { opacity:1; } }
/* ── Footer: Narrative + Stats ───────────────────────────────────────────────── */
#footer {
flex-shrink: 0;
border-top: 1px solid var(--border);
background: #0c1017;
display: grid;
grid-template-columns: 1fr auto;
gap: 0;
max-height: 140px;
}
#narrative-area {
padding: 10px 14px;
border-right: 1px solid var(--border);
overflow-y: auto;
}
#narrative-area::-webkit-scrollbar { width: 3px; }
#narrative-area::-webkit-scrollbar-thumb { background: var(--b2); }
#narrative-text {
font-size: 12px;
line-height: 1.6;
color: #c9d1d9;
}
#narrative-text b { color: var(--text); }
#narrative-text .dim { opacity: .55; }
/* Inline narrative labels — colored text only, no box */
.nl { font-weight: 600; margin-right: 2px; }
.nl.hit { color: var(--green); }
.nl.fault { color: var(--amber); }
.nl.bad { color: var(--red); }
.nl.info { color: var(--blue); }
.nl.file { color: var(--purple); }
#stats-area {
padding: 10px 14px;
display: flex;
flex-direction: column;
gap: 4px;
min-width: 310px;
}
.stats-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.st-pid { font-size: 10px; font-weight: 600; color: var(--tsec); min-width: 46px; }
.st-k { font-size: 10px; color: var(--tdim); }
.st-v { font-size: 11px; font-weight: 600; color: var(--text); font-family: monospace; }
.st-v.maps { color: var(--green); }
.st-v.outs { color: var(--amber); }
.st-v.segv { color: var(--red); }
.st-v.segprot { color: var(--red); }
.stats-total {
margin-top: 2px;
padding-top: 4px;
border-top: 1px solid var(--border);
display: flex; gap: 10px; align-items: center;
}
.cost-val { font-family: monospace; font-size: 12px; font-weight: 700; color: var(--blue); }
/* ── Arrow animations (dash length set dynamically in JS via getTotalLength) ─── */
/* ── Misc ─────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }
.tag {
display: inline-block;
font-size: 9px;
padding: 0 4px;
border-radius: 3px;
font-weight: 600;
vertical-align: middle;
}
.tag-wp { background: var(--blue-bg); color: var(--blue); }
.tag-fm { background: var(--pur-bg); color: var(--purple); }
/* ── CPU / MMU Panel ─────────────────────────────────────────────────────────── */
#cpu-panel {
background: linear-gradient(160deg, #090e1c 0%, #060810 100%);
border: 1px solid #18263e;
border-radius: 6px;
padding: 8px 10px;
margin-bottom: 8px;
flex-shrink: 0;
}
.cpu-panel-hdr {
font-size: 9px; font-weight: 600; color: #3a5a88;
text-transform: uppercase; letter-spacing: 0.09em;
margin-bottom: 7px;
display: flex; align-items: center; gap: 5px;
}
.cpu-panel-hdr::before {
content: ''; display: inline-block;
width: 5px; height: 5px; border-radius: 50%;
background: #3a5a88;
}
.cpu-row { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.cpu-lbl { font-size: 9px; color: var(--tdim); min-width: 36px; padding-top: 1px; }
.cpu-val { font-family: monospace; font-size: 11px; font-weight: 600; color: var(--text); }
.cpu-val.v-proc { color: var(--green); }
.cpu-val.v-instr { color: var(--blue); }
.xlate-status {
display: inline-flex; align-items: center; gap: 4px;
padding: 2px 8px; border-radius: 10px; margin-top: 5px;
font-size: 10px; font-weight: 600; white-space: nowrap;
}
.xlate-hit { background: var(--grn-bg); color: var(--green); border: 1px solid #1a5c28; }
.xlate-miss { background: var(--amb-bg); color: var(--amber); border: 1px solid #4a3008; }
.xlate-fault { background: var(--red-bg); color: var(--red); border: 1px solid #5a1a1a; }
.xlate-ctx { background: var(--blue-bg); color: var(--blue); border: 1px solid #1a3a6e; }
.xlate-idle { background: var(--s2); color: var(--tdim); border: 1px solid var(--border); }
/* ── Address Translation Diagram ─────────────────────────────────────────────── */
#xlate-diagram {
margin: 6px 0 5px;
padding: 7px 8px;
background: #07080f;
border: 1px solid #1a1e30;
border-radius: 5px;
}
.xlate-addr-row {
display: flex; align-items: center; gap: 6px; margin-bottom: 5px;
}
.xlate-addr-tag {
font-size: 8px; font-weight: 700; letter-spacing: 0.1em;
padding: 1px 4px; border-radius: 3px;
}
.xlate-tag-v { background: var(--blue-bg); color: var(--blue); border: 1px solid #1a3a6e; }
.xlate-tag-p { background: var(--grn-bg); color: var(--green); border: 1px solid #1a5c28; }
.xlate-addr-hex {
font-family: monospace; font-size: 12px; font-weight: 700; color: var(--text);
letter-spacing: 0.05em;
}
.xlate-paddr { color: var(--green); }
.xlate-fields {
display: flex; align-items: stretch; border-radius: 4px;
overflow: hidden; border: 1px solid #1e2240; margin-bottom: 5px;
}
.xlate-field {
display: flex; flex-direction: column; align-items: center; justify-content: center;
padding: 4px 6px; gap: 2px;
}
.xlate-vpn { background: #0a1028; border-right: 1px solid #1e2240; flex: 0 0 auto; min-width: 42px; }
.xlate-pfn { background: #081a0a; border-right: 1px solid #1e2240; flex: 0 0 auto; min-width: 42px; }
.xlate-off { background: #0c0c14; flex: 1; }
.xlate-field-val {
font-family: monospace; font-size: 13px; font-weight: 700; color: var(--text);
}
.xlate-vpn .xlate-field-val { color: var(--blue); }
.xlate-pfn .xlate-field-val { color: var(--green); }
.xlate-off .xlate-field-val { color: var(--tsec); }
.xlate-field-lbl {
font-size: 8px; color: var(--tdim); text-align: center; line-height: 1.3;
}
.xlate-bits { color: #303848; font-size: 7.5px; }
.xlate-field-sep { width: 0; }
.xlate-path-row {
display: flex; align-items: center; gap: 4px; margin: 2px 0 6px;
}
.xlate-path-line {
flex: 1; height: 1px; background: #1e2240;
}
.xlate-lookup-badge {
font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 8px;
white-space: nowrap;
}
.xlate-lookup-hit { background: var(--grn-bg); color: var(--green); border: 1px solid #1a5c28; }
.xlate-lookup-miss { background: var(--amb-bg); color: var(--amber); border: 1px solid #4a3008; }
.xlate-lookup-fault { background: var(--red-bg); color: var(--red); border: 1px solid #5a1a1a; }
.xlate-lookup-segv { background: #1a0808; color: var(--red); border: 1px solid #5a1010; }
.xlate-lookup-idle { background: var(--s2); color: var(--tdim); border: 1px solid var(--border); }
/* ── PT fixed top (TLB + proc label, never scrolls) ─────────────────────────── */
#pt-top {
flex-shrink: 0;
padding: 8px 8px 0;
border-bottom: 1px solid var(--border);
}
/* Remove padding so the table starts flush at the scroll container edge —
this prevents any gap above the sticky thead where rows could bleed through */
#pt-body { padding: 0; }
/* ── TLB Panel ────────────────────────────────────────────────────────────────── */
#tlb-panel { margin-bottom: 8px; flex-shrink: 0; }
.tlb-hdr {
font-size: 10px; font-weight: 600; color: var(--tsec);
display: flex; align-items: center; justify-content: space-between;
margin-bottom: 4px; padding-bottom: 4px;
border-bottom: 1px solid var(--border);
}
.tlb-title-txt { display: flex; align-items: center; gap: 5px; }
.tlb-chip {
width: 8px; height: 8px; border-radius: 1px;
background: linear-gradient(135deg, #1f3050, #3a6090);
display: inline-block; flex-shrink: 0;
}
.tlb-badge {
font-size: 9px; background: var(--s2); border: 1px solid var(--border);
border-radius: 4px; padding: 1px 6px; color: var(--tdim); font-family: monospace;
}
.tlb-badge.is-hit { background: var(--grn-bg); color: var(--green); border-color: #1a5c28; }
.tlb-badge.is-miss { background: var(--amb-bg); color: var(--amber); border-color: #4a3008; }
#tlb-table { width: 100%; border-collapse: collapse; font-size: 10px; }
#tlb-table thead th {
padding: 2px 5px; text-align: left; font-size: 9px; font-weight: 600;
text-transform: uppercase; letter-spacing: 0.05em;
color: var(--tdim); border-bottom: 1px solid var(--border); white-space: nowrap;
}
#tlb-table tbody tr { border-bottom: 1px solid rgba(48,54,61,0.4); }
#tlb-table tbody tr:hover { background: var(--s2); }
#tlb-table td { padding: 2px 5px; font-family: monospace; vertical-align: middle; }
.tlb-v-on { color: var(--green); font-weight: 700; }
.tlb-v-off { color: var(--tdim); }
.tlb-row-hit {
background: var(--grn-bg) !important;
outline: 1px solid rgba(63,185,80,0.35);
}
.tlb-row-hit td { color: var(--green) !important; }
.tlb-row-new {
background: rgba(210,153,34,0.06) !important;
outline: 1px solid rgba(210,153,34,0.3);
}
.tlb-row-new td { color: var(--amber) !important; }
.tlb-row-invalid td { color: var(--tdim); opacity: 0.45; }
</style>
</head>
<body>
<!-- ── Header ────────────────────────────────────────────────────────────────── -->
<header id="hdr">
<div id="hdr-logo">
Virtual Memory Simulation
</div>
<div class="hdr-div"></div>
<div class="ctrl-row">
<span class="ctrl-lbl">Input</span>
<select id="sel-input">
<option value="in1">in1 (1 process, 30 instructions)</option>
<option value="in3">in3 (1 process, 100 instructions, 4 VMAs)</option>
<option value="in4">in4 (1 process, 100 instructions, write-protected and file-mapped VMAs)</option>
<option value="in7">in7 (2 processes, 200 instructions)</option>
<option value="in8">in8 (2 processes, 200 instructions, mixed VMAs)</option>
</select>
</div>
<div class="ctrl-row">
<span class="ctrl-lbl">Frames</span>
<select id="sel-frames">
<option value="8">8</option>
<option value="16" selected>16</option>
<option value="32">32</option>
</select>
</div>
<div class="ctrl-row">
<span class="ctrl-lbl">Algorithm</span>
<select id="sel-algo">
<option value="f">FIFO</option>
<option value="r">Random</option>
<option value="c">Clock</option>
<option value="e">ESC / NRU</option>
<option value="a">Aging</option>
<option value="w">Working Set</option>
</select>
</div>
<button class="btn primary" id="btn-load">Load</button>
<span id="sim-source" style="font-size:10px;color:var(--tdim)" title="Start server.py to use the real C++ binary">JS fallback</span>
<div class="hdr-div"></div>
<button class="btn" id="btn-first" disabled title="First">⏮</button>
<button class="btn" id="btn-prev" disabled title="Back">◀</button>
<button class="btn primary" id="btn-play" disabled>▶ Play</button>
<button class="btn" id="btn-next" disabled title="Forward">▶</button>
<button class="btn" id="btn-last" disabled title="Last">⏭</button>
<div class="hdr-div"></div>
<div class="step-badge" id="step-badge"><span id="sb-cur">—</span> / <span id="sb-tot">—</span></div>
<div id="speed-wrap">
<span class="ctrl-lbl">Speed</span>
<input type="range" id="speed" min="1" max="10" value="5">
</div>
<div class="kbd">
<kbd>←</kbd><kbd>→</kbd> step <kbd>Space</kbd> play
</div>
</header>
<!-- ── Main ──────────────────────────────────────────────────────────────────── -->
<div id="main">
<!-- SVG arrow overlay -->
<svg id="arrows" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="ah-green" markerWidth="7" markerHeight="7" refX="6" refY="3.5" orient="auto">
<polyline points="0,0 6,3.5 0,7" fill="none" stroke="#3fb950" stroke-width="1.5"/>
</marker>
<marker id="ah-amber" markerWidth="7" markerHeight="7" refX="6" refY="3.5" orient="auto">
<polyline points="0,0 6,3.5 0,7" fill="none" stroke="#d29922" stroke-width="1.5"/>
</marker>
<marker id="ah-blue" markerWidth="7" markerHeight="7" refX="6" refY="3.5" orient="auto">
<polyline points="0,0 6,3.5 0,7" fill="none" stroke="#58a6ff" stroke-width="1.5"/>
</marker>
<marker id="ah-red" markerWidth="7" markerHeight="7" refX="6" refY="3.5" orient="auto">
<polyline points="0,0 6,3.5 0,7" fill="none" stroke="#f85149" stroke-width="1.5"/>
</marker>
<marker id="ah-purple" markerWidth="7" markerHeight="7" refX="6" refY="3.5" orient="auto">
<polyline points="0,0 6,3.5 0,7" fill="none" stroke="#bc8cff" stroke-width="1.5"/>
</marker>
</defs>
</svg>
<!-- Column 1: Virtual Address Space -->
<div class="col" id="col-vas">
<div class="col-hdr">
<h3>Virtual Address Space</h3>
<p>What the process thinks it owns (64 pages × 4 KiB)</p>
</div>
<div class="col-body" id="vas-body">
<!-- CPU / MMU panel -->
<div id="cpu-panel">
<div class="cpu-panel-hdr">CPU & MMU</div>
<div class="cpu-row">
<span class="cpu-lbl">Process</span>
<span class="cpu-val v-proc" id="cpu-pid">—</span>
</div>
<div class="cpu-row">
<span class="cpu-lbl">Instr</span>
<span class="cpu-val v-instr" id="cpu-instr">—</span>
</div>
<!-- Address translation diagram — shown only on r/w -->
<div id="xlate-diagram" style="display:none">
<!-- Virtual address row -->
<div class="xlate-addr-row">
<span class="xlate-addr-tag xlate-tag-v">VA</span>
<span class="xlate-addr-hex" id="xlate-vaddr">0x00000</span>
</div>
<!-- Bit-field split -->
<div class="xlate-fields">
<div class="xlate-field xlate-vpn">
<div class="xlate-field-val" id="xlate-vpn">00</div>
<div class="xlate-field-lbl">VPN<br><span class="xlate-bits">6 bits</span></div>
</div>
<div class="xlate-field-sep"></div>
<div class="xlate-field xlate-off">
<div class="xlate-field-val" id="xlate-off">000</div>
<div class="xlate-field-lbl">offset<br><span class="xlate-bits">12 bits</span></div>
</div>
</div>
<!-- Lookup path indicator -->
<div class="xlate-path-row">
<div class="xlate-path-line"></div>
<div id="xlate-lookup" class="xlate-lookup-badge">—</div>
<div class="xlate-path-line"></div>
</div>
<!-- Physical address fields — hidden on fault/segv -->
<div id="xlate-phys" style="display:none">
<div class="xlate-fields">
<div class="xlate-field xlate-pfn">
<div class="xlate-field-val" id="xlate-pfn">00</div>
<div class="xlate-field-lbl">PFN<br><span class="xlate-bits">4 bits</span></div>
</div>
<div class="xlate-field-sep"></div>
<div class="xlate-field xlate-off">
<div class="xlate-field-val" id="xlate-poff">000</div>
<div class="xlate-field-lbl">offset<br><span class="xlate-bits">12 bits</span></div>
</div>
</div>
<div class="xlate-addr-row">
<span class="xlate-addr-tag xlate-tag-p">PA</span>
<span class="xlate-addr-hex xlate-paddr" id="xlate-paddr">0x00000</span>
</div>
</div>
</div>
<div id="cpu-xlate" class="xlate-status xlate-idle">— idle —</div>
</div>
<div id="vas-proc-tabs" class="vas-proc-tabs"></div>
<div id="vma-legend" class="vma-legend"></div>
<div id="vp-list" class="vp-list"></div>
</div>
</div>
<!-- Column 2: Page Table -->
<div class="col" id="col-pt">
<div class="col-hdr">
<h3>Page Table</h3>
<p>The OS mapping from virtual pages → Physical frames (or disk)</p>
</div>
<!-- Fixed top area: TLB panel + process label (does NOT scroll) -->
<div id="pt-top">