-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch13.html
More file actions
1903 lines (1824 loc) · 80.6 KB
/
ch13.html
File metadata and controls
1903 lines (1824 loc) · 80.6 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="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ch.13 시스템 & 언어 | CS Visualizer</title>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<style>
/* ── CH13 LOCAL STYLES ── */
.pipeline-wrap {
display: flex;
align-items: center;
gap: 0;
flex-wrap: wrap;
margin: 24px 0;
justify-content: center;
}
.pipeline-box {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 14px;
text-align: center;
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
font-weight: 600;
min-width: 90px;
transition: all 0.3s;
position: relative;
}
.pipeline-box.active {
border-color: #ec4899;
background: rgba(236, 72, 153, 0.12);
color: #ec4899;
box-shadow: 0 0 16px rgba(236, 72, 153, 0.2);
}
.pipeline-box .pipe-sub {
font-size: 0.62rem;
color: var(--text-dim);
font-weight: 400;
margin-top: 3px;
}
.pipeline-arrow {
color: var(--text-dim);
font-size: 1rem;
padding: 0 4px;
flex-shrink: 0;
}
.compiler-compare {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 12px;
margin-top: 20px;
}
.compiler-card {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 10px;
padding: 16px;
}
.compiler-card-title {
font-family: 'JetBrains Mono', monospace;
font-size: 0.88rem;
font-weight: 700;
margin-bottom: 8px;
}
.compiler-card-desc {
font-size: 0.8rem;
color: var(--text-dim);
line-height: 1.6;
}
.token-area {
margin-top: 16px;
}
.token-input-row {
display: flex;
gap: 8px;
margin-bottom: 12px;
flex-wrap: wrap;
}
.token-input {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-family: 'JetBrains Mono', monospace;
font-size: 0.9rem;
padding: 8px 12px;
width: 220px;
outline: none;
}
.token-input:focus { border-color: #ec4899; }
.token-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
min-height: 36px;
margin-top: 8px;
}
.token-chip {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
padding: 4px 10px;
border-radius: 100px;
border: 1px solid var(--border);
background: var(--surface);
animation: fadeIn 0.2s;
}
.token-chip.IDENT { border-color: var(--accent); color: var(--accent); background: rgba(0,255,170,0.08); }
.token-chip.NUM { border-color: var(--accent3); color: var(--accent3); background: rgba(107,138,255,0.08); }
.token-chip.ASSIGN { border-color: var(--accent4); color: var(--accent4); background: rgba(255,170,0,0.08); }
.token-chip.PLUS { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.08); }
.token-chip.MINUS { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.08); }
.token-chip.STAR { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.08); }
.token-chip.SLASH { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.08); }
.token-chip.LPAREN,.token-chip.RPAREN { border-color: var(--text-dim); color: var(--text-dim); }
/* AST */
.ast-wrap {
font-family: 'JetBrains Mono', monospace;
font-size: 0.8rem;
margin-top: 8px;
padding: 16px;
background: var(--surface2);
border-radius: 8px;
border: 1px solid var(--border);
}
.ast-node {
display: inline-block;
padding: 4px 10px;
border-radius: 6px;
border: 1px solid var(--border);
background: var(--surface);
text-align: center;
min-width: 40px;
}
.ast-node.op { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.1); }
.ast-node.ident { border-color: var(--accent); color: var(--accent); background: rgba(0,255,170,0.08); }
.ast-node.num { border-color: var(--accent3); color: var(--accent3); background: rgba(107,138,255,0.08); }
.ast-tree { text-align: center; }
.ast-level { display: flex; justify-content: center; gap: 30px; margin: 8px 0; }
.ast-connector { text-align: center; color: var(--text-dim); font-size: 0.9rem; line-height: 0.8; }
/* lang table */
.lang-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.lang-table th, .lang-table td {
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
text-align: left;
}
.lang-table th { color: var(--text-dim); font-weight: 500; }
.lang-tag {
display: inline-block;
padding: 2px 8px;
border-radius: 100px;
font-size: 0.7rem;
margin: 1px;
}
/* syscall diagram */
.space-diagram {
display: grid;
grid-template-columns: 1fr auto 1fr;
gap: 16px;
align-items: stretch;
margin: 24px 0;
}
.space-box {
border-radius: 10px;
padding: 20px;
border: 2px solid var(--border);
}
.space-box.user-space {
border-color: var(--accent3);
background: rgba(107,138,255,0.06);
}
.space-box.kernel-space {
border-color: #ec4899;
background: rgba(236,72,153,0.06);
}
.space-title {
font-family: 'JetBrains Mono', monospace;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 2px;
margin-bottom: 12px;
}
.space-box.user-space .space-title { color: var(--accent3); }
.space-box.kernel-space .space-title { color: #ec4899; }
.space-item {
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
padding: 7px 10px;
border-radius: 6px;
background: var(--surface);
border: 1px solid var(--border);
margin-bottom: 6px;
color: var(--text-dim);
transition: all 0.25s;
}
.space-item.active {
border-color: var(--accent);
color: var(--text);
background: rgba(0,255,170,0.06);
}
.space-middle {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
padding: 10px 0;
}
.boundary-label {
font-family: 'JetBrains Mono', monospace;
font-size: 0.62rem;
color: var(--text-dim);
writing-mode: vertical-rl;
text-orientation: mixed;
letter-spacing: 2px;
border: 1px dashed var(--border);
padding: 14px 5px;
border-radius: 4px;
}
.syscall-flow {
display: flex;
align-items: center;
gap: 0;
flex-wrap: wrap;
margin: 16px 0;
justify-content: center;
}
.syscall-step {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
padding: 8px 12px;
border-radius: 8px;
border: 1px solid var(--border);
background: var(--surface2);
text-align: center;
min-width: 80px;
transition: all 0.3s;
}
.syscall-step.active {
border-color: #ec4899;
color: #ec4899;
background: rgba(236,72,153,0.1);
}
.syscall-arrow {
color: var(--text-dim);
padding: 0 4px;
font-size: 0.9rem;
}
/* syscall table */
.syscall-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.syscall-table th, .syscall-table td {
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
padding: 8px 10px;
border-bottom: 1px solid var(--border);
text-align: left;
}
.syscall-table th { color: var(--text-dim); font-weight: 400; font-size: 0.7rem; }
.syscall-table tr { cursor: pointer; transition: background 0.2s; }
.syscall-table tr:hover td { background: rgba(236,72,153,0.05); }
.syscall-table tr.selected td { background: rgba(236,72,153,0.1); }
.syscall-table tr.selected td:first-child { border-left: 3px solid #ec4899; }
.syscall-detail {
margin-top: 14px;
padding: 14px 16px;
background: var(--surface2);
border-radius: 8px;
border-left: 3px solid #ec4899;
font-family: 'JetBrains Mono', monospace;
font-size: 0.82rem;
color: var(--text-dim);
min-height: 60px;
line-height: 1.8;
}
/* ring levels */
.ring-diagram {
position: relative;
width: 320px;
height: 320px;
margin: 20px auto;
}
.ring-circle {
position: absolute;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
font-family: 'JetBrains Mono', monospace;
border: 2px solid;
}
.ring-label {
font-size: 0.72rem;
font-weight: 700;
margin-bottom: 2px;
}
.ring-desc {
font-size: 0.6rem;
opacity: 0.7;
}
/* IPC */
.ipc-tabs {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-bottom: 20px;
}
.ipc-tab {
font-family: 'JetBrains Mono', monospace;
font-size: 0.8rem;
padding: 8px 16px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--surface2);
color: var(--text-dim);
cursor: pointer;
transition: all 0.2s;
}
.ipc-tab:hover { border-color: #ec4899; color: #ec4899; }
.ipc-tab.active { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.1); }
.ipc-panel { display: none; }
.ipc-panel.active { display: block; }
.ipc-diagram {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 10px;
padding: 24px;
margin-bottom: 16px;
min-height: 140px;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 16px;
}
.process-box {
background: var(--surface);
border: 2px solid var(--accent3);
border-radius: 10px;
padding: 14px 20px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.82rem;
font-weight: 700;
color: var(--accent3);
text-align: center;
min-width: 90px;
}
.pipe-channel {
display: flex;
align-items: center;
gap: 0;
position: relative;
}
.pipe-byte {
width: 28px;
height: 28px;
background: rgba(236,72,153,0.15);
border: 1px solid rgba(236,72,153,0.4);
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-family: 'JetBrains Mono', monospace;
font-size: 0.65rem;
color: #ec4899;
margin: 0 1px;
animation: byteFlow 2s linear infinite;
}
.pipe-byte:nth-child(1) { animation-delay: 0s; }
.pipe-byte:nth-child(2) { animation-delay: 0.3s; }
.pipe-byte:nth-child(3) { animation-delay: 0.6s; }
.pipe-byte:nth-child(4) { animation-delay: 0.9s; }
.pipe-byte:nth-child(5) { animation-delay: 1.2s; }
@keyframes byteFlow {
0%,100% { opacity: 0.3; transform: scale(0.9); }
50% { opacity: 1; transform: scale(1); }
}
.ipc-pros-cons {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-top: 12px;
}
.pros-box, .cons-box {
padding: 12px 14px;
border-radius: 8px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
line-height: 1.8;
}
.pros-box {
background: rgba(0,255,170,0.06);
border: 1px solid rgba(0,255,170,0.2);
color: var(--accent);
}
.cons-box {
background: rgba(255,68,102,0.06);
border: 1px solid rgba(255,68,102,0.2);
color: var(--danger);
}
.pros-box .box-title, .cons-box .box-title {
font-weight: 700;
margin-bottom: 6px;
font-size: 0.72rem;
letter-spacing: 1px;
}
/* shared memory */
.shm-diagram {
display: flex;
gap: 0;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 12px;
}
.shm-region {
background: rgba(255,170,0,0.08);
border: 2px dashed var(--accent4);
border-radius: 8px;
padding: 12px 20px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
color: var(--accent4);
text-align: center;
min-width: 140px;
}
/* signals */
.signal-list {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-top: 12px;
}
.signal-chip {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
padding: 5px 12px;
border-radius: 6px;
border: 1px solid var(--border);
background: var(--surface2);
color: var(--text-dim);
cursor: pointer;
transition: all 0.2s;
}
.signal-chip:hover { border-color: var(--accent4); color: var(--accent4); }
.signal-chip.active { border-color: var(--danger); color: var(--danger); background: rgba(255,68,102,0.08); }
.signal-detail {
margin-top: 10px;
padding: 10px 14px;
background: var(--surface2);
border-radius: 8px;
border-left: 3px solid var(--danger);
font-family: 'JetBrains Mono', monospace;
font-size: 0.8rem;
color: var(--text-dim);
min-height: 40px;
line-height: 1.8;
}
/* GC section */
.gc-heap {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 20px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 10px;
min-height: 80px;
margin-bottom: 16px;
align-items: flex-start;
}
.heap-obj {
position: relative;
background: var(--surface);
border: 2px solid var(--border);
border-radius: 8px;
padding: 8px 12px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.72rem;
text-align: center;
transition: all 0.4s;
min-width: 64px;
cursor: pointer;
}
.heap-obj.live {
border-color: var(--accent);
color: var(--accent);
background: rgba(0,255,170,0.08);
}
.heap-obj.garbage {
border-color: var(--danger);
color: var(--danger);
background: rgba(255,68,102,0.08);
opacity: 0.7;
}
.heap-obj.marked {
border-color: var(--accent4);
color: var(--accent4);
background: rgba(255,170,0,0.1);
box-shadow: 0 0 10px rgba(255,170,0,0.2);
}
.heap-obj.swept {
opacity: 0;
transform: scale(0.5);
}
.heap-obj.root {
border-color: #ec4899;
color: #ec4899;
background: rgba(236,72,153,0.1);
}
.ref-count-badge {
position: absolute;
top: -8px;
right: -8px;
background: var(--accent3);
color: var(--bg);
border-radius: 50%;
width: 18px;
height: 18px;
font-size: 0.6rem;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
}
.ref-count-badge.zero { background: var(--danger); }
.gc-tabs {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-bottom: 16px;
}
.gc-tab {
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
padding: 7px 14px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--surface2);
color: var(--text-dim);
cursor: pointer;
transition: all 0.2s;
}
.gc-tab:hover { border-color: #ec4899; color: #ec4899; }
.gc-tab.active { border-color: #ec4899; color: #ec4899; background: rgba(236,72,153,0.1); }
.gc-panel { display: none; }
.gc-panel.active { display: block; }
/* generational GC */
.gen-diagram {
display: flex;
flex-direction: column;
gap: 10px;
margin: 16px 0;
}
.gen-row {
display: flex;
align-items: center;
gap: 12px;
}
.gen-label {
font-family: 'JetBrains Mono', monospace;
font-size: 0.72rem;
color: var(--text-dim);
width: 80px;
flex-shrink: 0;
}
.gen-bar-wrap {
flex: 1;
height: 40px;
background: var(--surface2);
border-radius: 6px;
border: 1px solid var(--border);
overflow: hidden;
position: relative;
display: flex;
align-items: center;
}
.gen-bar-fill {
height: 100%;
border-radius: 5px;
transition: width 0.5s ease;
display: flex;
align-items: center;
padding-left: 10px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.7rem;
font-weight: 600;
color: rgba(0,0,0,0.7);
}
/* rust ownership */
.ownership-demo {
font-family: 'JetBrains Mono', monospace;
font-size: 0.82rem;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 16px;
line-height: 2;
}
.own-box {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 3px 10px;
border-radius: 5px;
border: 1px solid;
margin: 2px;
font-size: 0.78rem;
transition: all 0.4s;
}
.own-box.owned { border-color: var(--accent); color: var(--accent); background: rgba(0,255,170,0.08); }
.own-box.moved { border-color: var(--text-dim); color: var(--text-dim); opacity: 0.35; }
.own-box.borrowed { border-color: var(--accent3); color: var(--accent3); background: rgba(107,138,255,0.08); }
.own-box.dropped { border-color: var(--danger); color: var(--danger); background: rgba(255,68,102,0.08); opacity: 0.5; }
/* fork diagram */
.fork-diagram {
display: flex;
align-items: flex-start;
justify-content: center;
gap: 0;
margin: 20px 0;
font-family: 'JetBrains Mono', monospace;
font-size: 0.78rem;
}
.fork-col {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
}
.fork-process {
padding: 8px 16px;
border-radius: 8px;
border: 2px solid;
text-align: center;
min-width: 100px;
}
.fork-process.parent { border-color: var(--accent3); color: var(--accent3); background: rgba(107,138,255,0.08); }
.fork-process.child { border-color: var(--accent); color: var(--accent); background: rgba(0,255,170,0.08); }
.fork-line {
width: 2px;
height: 20px;
background: var(--border);
}
.fork-branch {
display: flex;
align-items: flex-start;
gap: 40px;
}
.fork-connector {
display: flex;
align-items: center;
font-size: 1.2rem;
color: var(--text-dim);
padding: 0 4px;
margin-top: 30px;
}
/* socket diagram */
.socket-diagram {
display: flex;
align-items: center;
gap: 20px;
justify-content: center;
flex-wrap: wrap;
}
.socket-box {
background: var(--surface);
border: 2px solid;
border-radius: 10px;
padding: 14px 20px;
font-family: 'JetBrains Mono', monospace;
font-size: 0.82rem;
font-weight: 700;
text-align: center;
min-width: 100px;
}
.socket-box.client { border-color: var(--accent3); color: var(--accent3); }
.socket-box.server { border-color: #ec4899; color: #ec4899; }
.socket-channel {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
}
.socket-arrow {
font-family: 'JetBrains Mono', monospace;
font-size: 0.7rem;
color: var(--text-dim);
display: flex;
align-items: center;
gap: 4px;
}
.socket-arrow-line {
width: 80px;
height: 2px;
background: var(--border);
position: relative;
}
.socket-arrow-line.bidirectional::after {
content: '';
position: absolute;
top: -4px;
right: 0;
width: 0;
height: 0;
border-left: 7px solid var(--border);
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
}
.socket-arrow-line.bidirectional::before {
content: '';
position: absolute;
top: -4px;
left: 0;
width: 0;
height: 0;
border-right: 7px solid var(--border);
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
}
@media (max-width: 640px) {
.compiler-compare { grid-template-columns: 1fr; }
.space-diagram { grid-template-columns: 1fr; }
.ipc-pros-cons { grid-template-columns: 1fr; }
.ring-diagram { width: 250px; height: 250px; }
}
</style>
</head>
<body class="page-body">
<nav class="page-nav">
<a href="index.html" class="nav-back">← 홈</a>
<div class="nav-chapter-title" style="color:#ec4899">Ch.13 — 시스템 & 언어</div>
<div class="nav-sections">
<a href="#compiler" class="nav-sec-link">컴파일러</a>
<a href="#syscall" class="nav-sec-link">시스템콜</a>
<a href="#ipc" class="nav-sec-link">IPC</a>
<a href="#gc" class="nav-sec-link">가비지컬렉션</a>
</div>
</nav>
<!-- ═══════════════════════════════════════════════ -->
<!-- SECTION 1: 컴파일러 vs 인터프리터 -->
<!-- ═══════════════════════════════════════════════ -->
<section id="compiler">
<div class="section-header">
<div class="tag tag-ch13">01 — COMPILER & INTERPRETER</div>
<h2>컴파일러 vs 인터프리터</h2>
<p>소스 코드를 실행 가능한 기계어로 변환하는 방식은 크게 컴파일, 인터프리트, JIT 세 가지로 나뉩니다. 각 방식은 실행 속도와 유연성에서 서로 다른 트레이드오프를 가집니다.</p>
</div>
<div class="viz-box">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:12px;">컴파일 파이프라인</div>
<div class="pipeline-wrap" id="pipelineWrap">
<div class="pipeline-box" id="pipe0">
Source Code
<div class="pipe-sub">.c / .py / .js</div>
</div>
<div class="pipeline-arrow">→</div>
<div class="pipeline-box" id="pipe1">
Lexer
<div class="pipe-sub">토큰화</div>
</div>
<div class="pipeline-arrow">→</div>
<div class="pipeline-box" id="pipe2">
Parser
<div class="pipe-sub">구문 분석</div>
</div>
<div class="pipeline-arrow">→</div>
<div class="pipeline-box" id="pipe3">
AST
<div class="pipe-sub">추상 구문 트리</div>
</div>
<div class="pipeline-arrow">→</div>
<div class="pipeline-box" id="pipe4">
Code Gen
<div class="pipe-sub">코드 생성</div>
</div>
<div class="pipeline-arrow">→</div>
<div class="pipeline-box" id="pipe5">
Machine Code
<div class="pipe-sub">실행 가능</div>
</div>
</div>
<div style="text-align:center;margin-bottom:8px;">
<button class="btn" onclick="animatePipeline()">파이프라인 애니메이션</button>
</div>
<div class="compiler-compare">
<div class="compiler-card" style="border-color:rgba(0,255,170,0.3);">
<div class="compiler-card-title" style="color:var(--accent)">컴파일러</div>
<div class="compiler-card-desc">
전체 소스를 미리 기계어로 번역 후 실행.<br>
<span style="color:var(--accent)">빠른 실행 속도</span>, 느린 빌드.<br><br>
예: C, C++, Go, Rust
</div>
</div>
<div class="compiler-card" style="border-color:rgba(107,138,255,0.3);">
<div class="compiler-card-title" style="color:var(--accent3)">인터프리터</div>
<div class="compiler-card-desc">
소스 코드를 줄 단위로 읽어 즉시 실행.<br>
<span style="color:var(--accent3)">빠른 개발 사이클</span>, 느린 런타임.<br><br>
예: Python, Ruby
</div>
</div>
<div class="compiler-card" style="border-color:rgba(255,170,0,0.3);">
<div class="compiler-card-title" style="color:var(--accent4)">JIT 컴파일러</div>
<div class="compiler-card-desc">
바이트코드를 런타임에 기계어로 컴파일.<br>
<span style="color:var(--accent4)">컴파일 + 해석 혼합</span>.<br><br>
예: Java (JVM), C# (.NET), JS V8
</div>
</div>
</div>
</div>
<div class="viz-box" style="margin-top:20px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:14px;">인터랙티브 토큰화 / 파싱</div>
<div class="token-area">
<div class="token-input-row">
<input type="text" class="token-input" id="tokenInput" value="x = 2 + 3" oninput="onTokenInput()" placeholder="예: x = 2 + 3">
<button class="btn" onclick="runTokenize()">토큰화</button>
<button class="btn" onclick="runParse()">파싱 (AST)</button>
<button class="btn" id="btnReset" onclick="resetTokens()">초기화</button>
</div>
<div style="font-family:'JetBrains Mono',monospace;font-size:0.72rem;color:var(--text-dim);margin-bottom:6px;" id="tokenLabel" style="display:none;"></div>
<div class="token-list" id="tokenList"></div>
<div id="astOutput" style="display:none; margin-top:14px;"></div>
</div>
</div>
<div class="viz-box" style="margin-top:20px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:14px;">언어 분류표</div>
<table class="lang-table">
<thead>
<tr>
<th>유형</th>
<th>언어</th>
<th>메모리 관리</th>
<th>특징</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="lang-tag" style="background:rgba(0,255,170,0.1);border:1px solid rgba(0,255,170,0.3);color:var(--accent)">컴파일</span></td>
<td style="color:var(--accent)">C, C++, Go, Rust</td>
<td>수동 / GC / Ownership</td>
<td style="color:var(--text-dim)">빠른 실행, 시스템 프로그래밍</td>
</tr>
<tr>
<td><span class="lang-tag" style="background:rgba(107,138,255,0.1);border:1px solid rgba(107,138,255,0.3);color:var(--accent3)">인터프리트</span></td>
<td style="color:var(--accent3)">Python, JS, Ruby</td>
<td>GC (자동)</td>
<td style="color:var(--text-dim)">빠른 개발, 동적 타입</td>
</tr>
<tr>
<td><span class="lang-tag" style="background:rgba(255,170,0,0.1);border:1px solid rgba(255,170,0,0.3);color:var(--accent4)">JIT</span></td>
<td style="color:var(--accent4)">Java, C#, Kotlin</td>
<td>GC (JVM/.NET)</td>
<td style="color:var(--text-dim)">포터블 바이트코드, 크로스 플랫폼</td>
</tr>
</tbody>
</table>
<div style="margin-top:24px; font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:12px;">GC (가비지 컬렉션) 전략 비교</div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;">
<div style="padding:12px;background:var(--surface2);border:1px solid rgba(255,68,102,0.3);border-radius:8px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.8rem;color:var(--danger);margin-bottom:6px;">수동 관리 (C/C++)</div>
<div style="font-size:0.78rem;color:var(--text-dim);line-height:1.7;">malloc/free 직접 호출. 가장 빠르나 메모리 누수, dangling pointer 위험.</div>
</div>
<div style="padding:12px;background:var(--surface2);border:1px solid rgba(0,255,170,0.3);border-radius:8px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.8rem;color:var(--accent);margin-bottom:6px;">자동 GC (Java/Python)</div>
<div style="font-size:0.78rem;color:var(--text-dim);line-height:1.7;">런타임이 자동으로 메모리 회수. 편리하나 GC pause 발생 가능.</div>
</div>
<div style="padding:12px;background:var(--surface2);border:1px solid rgba(236,72,153,0.3);border-radius:8px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.8rem;color:#ec4899;margin-bottom:6px;">소유권 (Rust)</div>
<div style="font-size:0.78rem;color:var(--text-dim);line-height:1.7;">컴파일 타임에 소유권 검사. GC 없이 안전한 메모리 관리 보장.</div>
</div>
</div>
</div>
</section>
<div class="section-divider"></div>
<!-- ═══════════════════════════════════════════════ -->
<!-- SECTION 2: 시스템 콜 -->
<!-- ═══════════════════════════════════════════════ -->
<section id="syscall">
<div class="section-header">
<div class="tag tag-ch13">02 — SYSTEM CALL</div>
<h2>시스템 콜 (System Call)</h2>
<p>시스템 콜은 사용자 프로세스가 운영체제 커널의 서비스를 요청하는 인터페이스입니다. 하드웨어 보호를 위해 특권 모드 전환(trap)을 수반합니다.</p>
</div>
<div class="viz-box">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:16px;">유저 공간 ↔ 커널 공간</div>
<div class="space-diagram">
<div class="space-box user-space">
<div class="space-title">USER SPACE (Ring 3)</div>
<div class="space-item" id="ss-app">Application (프로세스)</div>
<div class="space-item" id="ss-lib">C 표준 라이브러리 (libc)</div>
<div class="space-item" id="ss-wrap">syscall() 래퍼 함수</div>
</div>
<div class="space-middle">
<div class="boundary-label">TRAP / INTERRUPT</div>
</div>
<div class="space-box kernel-space">
<div class="space-title">KERNEL SPACE (Ring 0)</div>
<div class="space-item" id="ss-kentry">커널 진입점 (syscall handler)</div>
<div class="space-item" id="ss-dispatch">syscall 번호 디스패치</div>
<div class="space-item" id="ss-hw">하드웨어 드라이버 / 서비스</div>
<div class="space-item" id="ss-ret">결과 반환 (iret)</div>
</div>
</div>
<div style="margin-top:20px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:10px;">시스템 콜 실행 흐름</div>
<div class="syscall-flow" id="scFlow">
<div class="syscall-step" id="sc0">앱 코드<br><span style="color:var(--text-dim);font-size:0.65rem;">write(1, buf, n)</span></div>
<div class="syscall-arrow">→</div>
<div class="syscall-step" id="sc1">trap<br><span style="color:var(--text-dim);font-size:0.65rem;">INT 0x80 / SYSCALL</span></div>
<div class="syscall-arrow">→</div>
<div class="syscall-step" id="sc2">커널 핸들러<br><span style="color:var(--text-dim);font-size:0.65rem;">번호 검증</span></div>
<div class="syscall-arrow">→</div>
<div class="syscall-step" id="sc3">하드웨어 I/O<br><span style="color:var(--text-dim);font-size:0.65rem;">드라이버 호출</span></div>
<div class="syscall-arrow">→</div>
<div class="syscall-step" id="sc4">결과 반환<br><span style="color:var(--text-dim);font-size:0.65rem;">레지스터 복원</span></div>
</div>
<div style="text-align:center;margin-top:10px;">
<button class="btn" onclick="animateSyscallFlow()">흐름 애니메이션</button>
</div>
</div>
<div style="margin-top:28px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:10px;">주요 시스템 콜 — 클릭하면 상세 설명</div>
<table class="syscall-table" id="syscallTable">
<thead>
<tr>
<th>syscall</th>
<th>번호 (Linux x86_64)</th>
<th>분류</th>
<th>간단 설명</th>
</tr>
</thead>
<tbody id="syscallTbody"></tbody>
</table>
<div class="syscall-detail" id="syscallDetail">위 표에서 시스템 콜을 클릭하면 상세 설명이 표시됩니다.</div>
</div>
</div>
<div class="viz-box" style="margin-top:20px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:16px;">프로세스 생성: fork() & exec()</div>
<div class="fork-diagram">
<div style="display:flex;flex-direction:column;align-items:center;gap:0;">
<div class="fork-process parent">Parent Process<br><span style="font-size:0.65rem;color:var(--text-dim)">PID: 1234</span></div>
<div style="width:2px;height:18px;background:var(--border);"></div>
<div style="font-family:'JetBrains Mono',monospace;font-size:0.72rem;color:var(--accent4);padding:4px 10px;background:rgba(255,170,0,0.08);border:1px solid rgba(255,170,0,0.3);border-radius:5px;">fork()</div>
<div style="display:flex;gap:60px;align-items:flex-start;">
<div style="display:flex;flex-direction:column;align-items:center;gap:0;">
<div style="width:2px;height:16px;background:var(--border);"></div>
<div class="fork-process parent" style="opacity:0.6">Parent 계속<br><span style="font-size:0.65rem;color:var(--text-dim)">pid=1234</span></div>
<div style="width:2px;height:16px;background:var(--border);"></div>
<div style="font-family:'JetBrains Mono',monospace;font-size:0.65rem;color:var(--text-dim);padding:4px 8px;background:var(--surface2);border-radius:4px;">wait(&status)</div>
</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:0;">
<div style="width:2px;height:16px;background:var(--border);"></div>
<div class="fork-process child">Child Process<br><span style="font-size:0.65rem;color:var(--text-dim)">pid=1235</span></div>
<div style="width:2px;height:16px;background:var(--border);"></div>
<div style="font-family:'JetBrains Mono',monospace;font-size:0.72rem;color:#ec4899;padding:4px 10px;background:rgba(236,72,153,0.08);border:1px solid rgba(236,72,153,0.3);border-radius:5px;">exec("/bin/ls")</div>
<div style="width:2px;height:16px;background:var(--border);"></div>
<div style="font-family:'JetBrains Mono',monospace;font-size:0.65rem;color:var(--text-dim);padding:4px 8px;background:var(--surface2);border-radius:4px;">exit(0)</div>
</div>
</div>
</div>
</div>
<div class="info-text" style="margin-top:16px;">
<span style="color:#ec4899">fork()</span>: 현재 프로세스를 복사하여 자식 프로세스 생성. 부모는 자식 PID, 자식은 0 반환.<br>
<span style="color:var(--accent4)">exec()</span>: 현재 프로세스 이미지를 새 프로그램으로 교체. fork 후 exec 패턴(fork-exec)이 일반적.<br>
<span style="color:var(--accent)">wait()</span>: 부모가 자식 종료를 기다림. 좀비 프로세스 방지.
</div>
</div>
<div class="viz-box" style="margin-top:20px;">
<div style="font-family:'JetBrains Mono',monospace;font-size:0.75rem;color:var(--text-dim);letter-spacing:1px;margin-bottom:16px;">CPU 특권 링 (Privilege Rings)</div>
<div class="ring-diagram" id="ringDiagram"></div>
<div style="display:flex;justify-content:center;gap:20px;flex-wrap:wrap;margin-top:10px;font-family:'JetBrains Mono',monospace;font-size:0.72rem;">
<span style="color:#ec4899">Ring 0: 커널 (최고 권한)</span>
<span style="color:var(--accent4)">Ring 1/2: 드라이버</span>
<span style="color:var(--accent3)">Ring 3: 사용자 앱 (최저 권한)</span>
</div>
</div>
</section>