-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1230 lines (522 loc) · 31.7 KB
/
index.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
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 class="theme-next mist use-motion" lang="zh-Hans">
<head>
<!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />
<meta name="keywords" content="Hexo, NexT" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />
<meta name="description" content="In a Nut-Universe">
<meta property="og:type" content="website">
<meta property="og:title" content="Chestnut">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Chestnut">
<meta property="og:description" content="In a Nut-Universe">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Chestnut">
<meta name="twitter:description" content="In a Nut-Universe">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Mist',
sidebar: {"position":"right","display":"always","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
fancybox: true,
motion: true,
duoshuo: {
userId: '0',
author: '博主'
},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<link rel="canonical" href="http://yoursite.com/"/>
<title> Chestnut </title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-right
page-home
">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Chestnut</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle"></p>
</div>
<div class="site-nav-toggle">
<button>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />
首页
</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />
分类
</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
归档
</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
标签
</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/05/31/go internal: memory model/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Chestnutme">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Chestnut">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2018/05/31/go internal: memory model/" itemprop="url">
go internal - memory model
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2018-05-31T00:00:00+08:00">
2018-05-31
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="what-is-memory-model"><a href="#what-is-memory-model" class="headerlink" title="what is memory model"></a>what is memory model</h2><p>From Wiki[3], the memory model is defined as follows:</p>
<blockquote>
<p>In computing, a memory model describes the interactions of threads through memory and their shared use of the data.</p>
</blockquote>
<p>The context is <strong>multi-thread</strong>, which is sth about concurrency/synchronization.</p>
<p>At the time when a computer only has one core/cpu, memory is owned by the single thread, in which instructions has a well-defined order. As time goes by, we have multi-cpus/multi-cores-one-cpu allowing us to executing more than one thread at the same time.The problem is that we only have one memory, and the set of threads are always cooperating with each other to cope with a whole task instead of being independent.They need communication(known as <strong>IPC: inter-process communicaiton</strong>), which have two methods:</p>
<ul>
<li>share memory</li>
<li>message passing</li>
</ul>
<p>The latter is used in the network/distributed system, we will leave it aside.The formmer defines a n-to-1 model, which we need to deal with the logic of the program - the execution order of threads happening at the same time.That’s when we need the memory model:</p>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2018/05/31/go internal: memory model/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/18/CLRS-notes6/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Chestnutme">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Chestnut">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/05/18/CLRS-notes6/" itemprop="url">
introduction to algorithms notes6
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-18T00:00:00+08:00">
2017-05-18
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="<Introduction-to-algorithms>笔记"><a href="#<Introduction-to-algorithms>笔记" class="headerlink" title="<Introduction to algorithms>笔记"></a><Introduction to algorithms>笔记</h1><h2 id="Part7-高级算法问题"><a href="#Part7-高级算法问题" class="headerlink" title="Part7 高级算法问题"></a>Part7 高级算法问题</h2><p>在part1-6学习基本的数据结构和算法问题后, part7不再集中于对一个算法问题专题进行学习, 而是就不同的高级算法问题进行基本的介绍,其其覆盖的内容十分全面,涉及一下几个领域:</p>
<ul>
<li>排序网络</li>
<li>矩阵运算</li>
<li>线性规划</li>
<li>字符串匹配</li>
</ul>
<h3 id="Chapter26-如何利用多核来并行排序"><a href="#Chapter26-如何利用多核来并行排序" class="headerlink" title="Chapter26 如何利用多核来并行排序?"></a>Chapter26 如何利用多核来并行排序?</h3><p>在part2中学习了基本的排序算法,包括插入,快排,归并,堆排序等,它们都是在串行计算机上线性执行的算法.随着硬件的发展,多处理器的进步,如何利用多核来进行并行排序?如何推而广之到多核并行算法?这一章就套路基于计算的一种比较网络模型,同时进行多个比较操作.</p>
<p>比较网络与串行排序算法的区别:</p>
<ul>
<li>比较网络只能执行比较操作, 即只能执行基于比较操作的算法.因此part2中学习的计数排序就无法再比较网络中实现</li>
<li>比较网络中比较操作可以并行的执行, 而串行排序算法各操作是依次执行的.故前者拥有更好的算法效率- 更小的算法复杂度</li>
</ul>
<p>1.比较网络定义</p>
<ul>
<li>组成:<br>基本构件:线路和比较器<br><img src="/images/comparsion.png" alt="comparsion"></li>
</ul>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2017/05/18/CLRS-notes6/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/13/lab4_part23/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Chestnutme">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Chestnut">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/05/13/lab4_part23/" itemprop="url">
lab4-Preemptive Multitasking part23
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-13T00:00:00+08:00">
2017-05-13
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Lab4-抢占式多进程"><a href="#Lab4-抢占式多进程" class="headerlink" title="Lab4 抢占式多进程"></a>Lab4 抢占式多进程</h1><h2 id="Part2-写入时复制-copy-on-write-fork"><a href="#Part2-写入时复制-copy-on-write-fork" class="headerlink" title="Part2 写入时复制 copy-on-write fork"></a>Part2 写入时复制 copy-on-write fork</h2><p>如前所述,Unix将fork()系统调用作为进程创建原语.fork()系统调用将调用进程的地址空间(父进程)创建一个新的进程(子进程).<br>xv6 Unix <code>fork()</code>通过将父进程页面中的所有数据复制到为子进程分配的新页面中,这个机制基本和<code>dumbfork()</code>相同.复制父进程的地址空间到子进程是<code>fork()</code>中代价最大的操作.<br>但是,调用<code>fork()</code>后经常在子进程中跟随<code>exec()</code>调用, 其会用加载新程序到子进程的内存.例如, 这是shell的常用机制.在这种情况下,复制父进程地址空间的时间大部分被浪费,因为子进程在调用<code>exec()</code>之前只使用很少的内存.</p>
<p>因此,Unix的更高版本利用虚拟内存硬件,允许父子进程<strong>共享</strong>映射到其各自地址空间的内存,直到其中一个进程实际修改这段内存.这种技术被称为<strong>写时复制(copy-on-fork)</strong>.为了做到这一点,调用<code>fork()</code>时,内核上将复制父进程的地址空间映射到进程,而不是复制映射页的内容,同时标记现在共享的页面为只读.当两个进程中的一个尝试写入其中一个共享页面时,该进程将出现页面错误.在这一点上,Unix内核意识到该页面真的是一个“虚拟”或“写时复制”的副本,因此它创建一个新的/私有的故障页面的可写副本.这样,单个页面的内容在实际写入之前实际上并不被复制.<code>fork()</code>的这种优化使随后的<code>exec()</code>代价小很多:在子进程调用<code>exec()</code>之前,可能只需要复制一个页面(它的堆栈的当前页面).</p>
<p>在part2,实现一个 Unix <code>fork()</code>,其具有写时复制功能,并作为一个用户空间库例程来.另外,使得单个用户模式程序定义自己的<code>fork()</code>:一个程序想要一个稍微不同的<code>fork()</code>(如总是复制的<code>dumbfork()</code>,或者父子进程共享内存)可以很容易修改而实现.</p>
<h3 id="用户级页面错误处理"><a href="#用户级页面错误处理" class="headerlink" title="用户级页面错误处理"></a>用户级页面错误处理</h3><p>用户级的写时复制<code>fork()</code>首先需要知道发生在写保护页面上的页面错误,这是首先要实现的.写时复制只是用户级页面故障处理的许多可能用途之一.<br>一般实现方式是:设置一个地址空间,以便页面错误指示出何时需要执行操作.例如,大多数Unix内核最初仅在新进程的堆栈区域中映射单个页面,并且随着进程的堆栈增加而随后分配和映射额外的堆栈页面,并导致尚未映射的堆栈地址发生页面错误,对此典型的Unix内核必须跟踪在进程空间的每个区域中出现页面错误时要执行的操作.又例如,堆栈区域中的故障通常会导致分配和映射物理内存新页面.程序BSS区域的故障通常会分配一个新的页面,以0填充,并在进行映射.<br>以上是内核需要跟踪的信息.不采用传统的Unix方法,而更好地处理用户空间中的每个页面错误,使得bug破坏性更小.这种设计具有额外的优点,允许程序在定义其内存区域方面具有很大的灵活性.<br>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2017/05/13/lab4_part23/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/09/CLRS-notes5/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Chestnutme">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Chestnut">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/05/09/CLRS-notes5/" itemprop="url">
introduction to algorithms note5
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-09T00:00:00+08:00">
2017-05-09
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="<Introduction-to-algorithms>笔记"><a href="#<Introduction-to-algorithms>笔记" class="headerlink" title="<Introduction to algorithms>笔记"></a><Introduction to algorithms>笔记</h1><h2 id="Part6-图算法"><a href="#Part6-图算法" class="headerlink" title="Part6 图算法"></a>Part6 图算法</h2><p>在前面的部分学习了表示一对一关系的线性数据结构(数组, 链表, stack, queue), 表示一对多关系的树型数据结构(二叉树, 森林, 堆)后, 将其拓展到多对多关系-图.在part6主要是学习用图定义的计算问题和对应的算法,主要包括三个部分:</p>
<ul>
<li>图的表示,及广度/深度优先的图搜索算法</li>
<li>求解最小生成树问题</li>
<li>最短路径问题</li>
</ul>
<p>约定:以 $G = (V, E)$ 描述一个图G, 其顶点集为V[G], 顶点数为|V|;边集为E[G], 边数为|E|;故图问题的输入规模的参数有两个, |V|和|G|.例如,算法的复杂度为 $O(VE)$ 表示该算法的运行时间的 $O(|V||E|)$</p>
<h3 id="Chapter22-如何表示和遍历图"><a href="#Chapter22-如何表示和遍历图" class="headerlink" title="Chapter22 如何表示和遍历图?"></a>Chapter22 如何表示和遍历图?</h3><p>本章的图搜索技术是图算法领域的核心.分为五个部分:</p>
<ul>
<li>图的表示</li>
<li>广度优先搜索</li>
<li>深度优先搜索</li>
<li>有向无环图的拓扑排序</li>
<li>有向图的强连通子图</li>
</ul>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2017/05/09/CLRS-notes5/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/04/lab4/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Chestnutme">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/avatar.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Chestnut">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2017/05/04/lab4/" itemprop="url">
lab4-Preemptive Multitasking
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-04T00:00:00+08:00">
2017-05-04
</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Lab4-抢占式多进程"><a href="#Lab4-抢占式多进程" class="headerlink" title="Lab4 抢占式多进程"></a>Lab4 抢占式多进程</h1><h2 id="摘要"><a href="#摘要" class="headerlink" title="摘要"></a>摘要</h2><p>Lab4目标是在多用户环境下实现抢占式多进程的支持,分解为三个部分:</p>
<ul>
<li>part1: 在JOS中添加对多处理器的支持,实现循环调度算法,并添加基本的环境管理的系统调用(创建/销毁环境,分配/映射内存)</li>
<li>part2:实现类似Unix的<code>fork</code>机制,允许在用户模式下创建副本</li>
<li>part3:添加对进程间通信(IPC)的支持,允许不同的用户环境进行进程间的通信和同步。并添加对硬件时钟中断和进程抢占的支持。</li>
</ul>
<h2 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h2><p>下载实验代码:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git pull</span><br><span class="line">git chekout -b lab4 origin/lab4</span><br><span class="line">git merge Lab3</span><br></pre></td></tr></table></figure></p>
<p>Lab4 新增的文件:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">kern/cpu.h 多处理器支持的内核私有定义</span><br><span class="line">kern/mpconfig.c 读取多处理器配置的代码</span><br><span class="line">kern/lapic.c 驱动处理器中的本地APIC单元的内核代码</span><br><span class="line">kern/mpentry.S 非启动CPU的汇编代码入口</span><br><span class="line">kern/spinlock.h 包括大内核锁在内的自旋锁的内和私有定义</span><br><span class="line">kern/spinlock.c 自旋锁的内核代码实现</span><br><span class="line">kern/sched.c 调度器的代码框架</span><br></pre></td></tr></table></figure></p>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2017/05/04/lab4/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<div>
</div>
<div>
</div>
<div>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</section>
<nav class="pagination">
<span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><span class="space">…</span><a class="page-number" href="/page/5/">5</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a>
</nav>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<section class="site-overview sidebar-panel sidebar-panel-active">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image"
src="/images/avatar.jpg"
alt="Chestnutme" />
<p class="site-author-name" itemprop="name">Chestnutme</p>
<p class="site-description motion-element" itemprop="description">In a Nut-Universe</p>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives">
<span class="site-state-item-count">22</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/index.html">
<span class="site-state-item-count">8</span>
<span class="site-state-item-name">标签</span>
</a>
</div>
</nav>