-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiningPhilosophersProblem
744 lines (484 loc) · 71.7 KB
/
DiningPhilosophersProblem
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
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<!--[if lt IE 9]>
<style>body {display: none; background: none !important} </style>
<meta http-equiv="Refresh" Content="0; url=//browsehappy.com/" />
<![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="卮客" />
<meta name="description" content="问题描述哲学家就餐问题(Dining philosophers problem)是在计算机科学中的一个经典问题,用来演示在并发计算中多线程同步(Synchronization)时产生的问题。 在1971年,著名的计算机科学家Edsger Wybe Dijkstra(艾兹格·迪科斯彻)提出了一个同步问题,即假设有五台计算机都试图访问五份共享的磁带驱动器。稍后,这个问题被托尼·霍尔重新表述为哲学家就餐">
<meta property="og:type" content="article">
<meta property="og:title" content="哲学家就餐问题">
<meta property="og:url" content="https://www.zhiiker.com/DiningPhilosophersProblem">
<meta property="og:site_name" content="卮客杂俎">
<meta property="og:description" content="问题描述哲学家就餐问题(Dining philosophers problem)是在计算机科学中的一个经典问题,用来演示在并发计算中多线程同步(Synchronization)时产生的问题。 在1971年,著名的计算机科学家Edsger Wybe Dijkstra(艾兹格·迪科斯彻)提出了一个同步问题,即假设有五台计算机都试图访问五份共享的磁带驱动器。稍后,这个问题被托尼·霍尔重新表述为哲学家就餐">
<meta property="og:locale">
<meta property="article:published_time" content="2016-09-22T08:46:06.000Z">
<meta property="article:modified_time" content="2017-03-05T09:15:03.000Z">
<meta property="article:author" content="卮客">
<meta property="article:tag" content="操作系统">
<meta property="article:tag" content="并发">
<meta name="twitter:card" content="summary">
<link rel="apple-touch-icon" href= "/apple-touch-icon.png">
<link rel="alternate" href="/atom.xml" title="卮客杂俎" type="application/atom+xml">
<link rel="shortcut icon" href="/images/favicon.png">
<link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css">
<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<title>哲学家就餐问题 | 卮客杂俎</title>
<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
<script>
var yiliaConfig = {
fancybox: true,
animate: true,
isHome: false,
isPost: true,
isArchive: false,
isTag: false,
isCategory: false,
fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
search: true
}
</script>
<script>
yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
</script>
<script> yiliaConfig.rootUrl = "\/";</script>
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-579834e01a3c7cec"></script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?cb203f30c887d436558853df2a128830";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<meta name="generator" content="Hexo 5.4.0"></head>
<body>
<div id="container">
<div class="left-col">
<div class="overlay"></div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="/images/avatar.png" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/">undefined</a></h1>
</hgroup>
<form id="search-form">
<input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="true" />
<i class="fa fa-times" onclick="resetSearch()"></i>
</form>
<div id="local-search-result"></div>
<p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
<div id="switch-btn" class="switch-btn">
<div class="icon">
<div class="icon-ctn">
<div class="icon-wrap icon-house" data-idx="0">
<div class="birdhouse"></div>
<div class="birdhouse_holes"></div>
</div>
<div class="icon-wrap icon-ribbon hide" data-idx="1">
<div class="ribbon"></div>
</div>
<div class="icon-wrap icon-link hide" data-idx="2">
<div class="loopback_l"></div>
<div class="loopback_r"></div>
</div>
<div class="icon-wrap icon-me hide" data-idx="3">
<div class="user"></div>
<div class="shoulder"></div>
</div>
</div>
</div>
<div class="tips-box hide">
<div class="tips-arrow"></div>
<ul class="tips-inner">
<li>菜单</li>
<li>标签</li>
<li>友情链接</li>
<li>关于我</li>
</ul>
</div>
</div>
<div id="switch-area" class="switch-area">
<div class="switch-wrap">
<section class="switch-part switch-part1">
<nav class="header-menu">
<ul>
<li><a href="/archives/">所有文章</a></li>
<li><a href="/tags/">分类&标签</a></li>
<li><a target="_blank" rel="noopener" href="https://www.bitcook.org">BitCook</a></li>
<li><a href="/about/">关于我</a></li>
</ul>
</nav>
<nav class="header-nav">
<ul class="social">
<a class="fa Email" href="mailto:im@zhiiker.com" title="Email"></a>
<a class="fa RSS" href="http://www.zhiiker.com/atom.xml" title="RSS"></a>
<a class="fa GitHub" target="_blank" rel="noopener" href="https://github.com/zhiiker" title="GitHub"></a>
<a class="fa Quora" target="_blank" rel="noopener" href="https://www.quora.com/profile/Shichao-Liang-1" title="Quora"></a>
<a class="fa Medium" target="_blank" rel="noopener" href="https://medium.com/@zhiiker" title="Medium"></a>
<a class="fa Coding" target="_blank" rel="noopener" href="https://dev.tencent.com/u/zhiiker" title="Coding"></a>
<a class="fa V2EX" target="_blank" rel="noopener" href="https://www.v2ex.com/member/zhiiker" title="V2EX"></a>
<a class="fa 新浪微博" target="_blank" rel="noopener" href="http://weibo.com/tobechaos" title="新浪微博"></a>
<a class="fa 知乎" target="_blank" rel="noopener" href="https://www.zhihu.com/people/liangshichao" title="知乎"></a>
<a class="fa 豆瓣" target="_blank" rel="noopener" href="https://www.douban.com/people/tobechaos/" title="豆瓣"></a>
<a class="fa 简书" target="_blank" rel="noopener" href="http://www.jianshu.com/u/d5add3cb2d34" title="简书"></a>
<a class="fa SegmentFault" target="_blank" rel="noopener" href="https://segmentfault.com/u/zhiiker" title="SegmentFault"></a>
<a class="fa 博客园" target="_blank" rel="noopener" href="https://www.cnblogs.com/zhiiker" title="博客园"></a>
<a class="fa CSDN" target="_blank" rel="noopener" href="http://my.csdn.net/zhiiker" title="CSDN"></a>
<a class="fa 网易云音乐" target="_blank" rel="noopener" href="http://music.163.com/#/user/home?id=72587395" title="网易云音乐"></a>
<a class="fa bilibili" target="_blank" rel="noopener" href="https://space.bilibili.com/953543/" title="bilibili"></a>
<a class="fa Facebook" target="_blank" rel="noopener" href="https://www.facebook.com/realshichao" title="Facebook"></a>
<a class="fa Twitter" target="_blank" rel="noopener" href="https://twitter.com/zhiiker" title="Twitter"></a>
<a class="fa LinkedIn" target="_blank" rel="noopener" href="https://cn.linkedin.com/in/liangshichao" title="LinkedIn"></a>
<a class="fa QQ" target="_blank" rel="noopener" href="https://images.liangs.me/avatars/qrcode_1521369601487.jpg" title="QQ"></a>
<a class="fa PayPal" target="_blank" rel="noopener" href="https://paypal.me/realshichao" title="PayPal"></a>
<a class="fa StackOverflow" target="_blank" rel="noopener" href="https://stackoverflow.com/users/4978576/zhiiker" title="StackOverflow"></a>
<a class="fa reddit" target="_blank" rel="noopener" href="https://www.reddit.com/user/zhiiker/" title="reddit"></a>
</ul>
</nav>
</section>
<section class="switch-part switch-part2">
<div class="widget tagcloud" id="js-tagcloud">
<ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/CPU/" rel="tag">CPU</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Dropbox/" rel="tag">Dropbox</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/" rel="tag">Git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Gitbub/" rel="tag">Gitbub</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/" rel="tag">Hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ICPC/" rel="tag">ICPC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Incrond/" rel="tag">Incrond</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/J2EE/" rel="tag">J2EE</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JSP/" rel="tag">JSP</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Markdown/" rel="tag">Markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Oracle/" rel="tag">Oracle</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Python/" rel="tag">Python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Servlet/" rel="tag">Servlet</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Shadowsocks/" rel="tag">Shadowsocks</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Ubuntu/" rel="tag">Ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Windows/" rel="tag">Windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/" rel="tag">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cmd/" rel="tag">cmd</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crontab/" rel="tag">crontab</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dropbox/" rel="tag">dropbox</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/" rel="tag">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/incron/" rel="tag">incron</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/" rel="tag">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/markdown/" rel="tag">markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/oss/" rel="tag">oss</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ossfs/" rel="tag">ossfs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/seafile/" rel="tag">seafile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/supervisor/" rel="tag">supervisor</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vps/" rel="tag">vps</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%B9%A6%E9%98%81/" rel="tag">书阁</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%BA%91%E7%9B%98/" rel="tag">云盘</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%86%99%E4%BD%9C/" rel="tag">写作</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8C%BA%E5%9D%97%E9%93%BE/" rel="tag">区块链</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%AE%E5%AE%A2/" rel="tag">卮客</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%AE%E8%A8%80/" rel="tag">卮言</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%90%8C%E4%BD%99/" rel="tag">同余</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%90%8D%E5%8F%B7/" rel="tag">名号</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%90%8D%E5%AD%97/" rel="tag">名字</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%87%E5%BF%98/" rel="tag">备忘</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%8D%E5%88%B6%E7%B2%98%E8%B4%B4/" rel="tag">复制粘贴</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%B9%B6%E5%8F%91/" rel="tag">并发</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99/" rel="tag">建站</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/" rel="tag">建站日志</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/" rel="tag">开机启动</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" rel="tag">操作系统</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9C%8D%E5%8A%A1%E5%99%A8/" rel="tag">服务器</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%B5%8B%E8%AF%95/" rel="tag">测试</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%AB%AF%E5%8F%A3/" rel="tag">端口</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%AC%94%E8%AE%B0/" rel="tag">笔记</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%B4%A0%E6%8B%93%E7%BD%91/" rel="tag">素拓网</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AF%84%E8%AE%BA/" rel="tag">评论</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AF%BB%E4%B9%A6/" rel="tag">读书</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%B4%A8%E6%95%B0/" rel="tag">质数</a></li></ul>
</div>
</section>
<section class="switch-part switch-part3">
<div id="js-friends">
<a class="main-nav-link switch-friends-link" target="_blank" rel="noopener" href="https://hexo.io">Hexo</a>
<a class="main-nav-link switch-friends-link" target="_blank" rel="noopener" href="https://pages.github.com">GitHub</a>
<a class="main-nav-link switch-friends-link" target="_blank" rel="noopener" href="http://moxfive.xyz">MOxFIVE</a>
<a class="main-nav-link switch-friends-link" target="_blank" rel="noopener" href="https://feigong.tech">非工科技</a>
</div>
</section>
<section class="switch-part switch-part4">
<div id="js-aboutme">Explorer Developer Innovator Cypherpunk Cosmopolitan Transhumanist Neuroexistentialist Extropist Philosophy-Enthusiast NeuroScience-Fancier me@zkr.pub</div>
</section>
</div>
</div>
</header>
</div>
</div>
<div class="mid-col">
<nav id="mobile-nav">
<div class="overlay">
<div class="slider-trigger"></div>
<h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">undefined</a></h1>
</div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="/images/avatar.png" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/" title="回到主页">undefined</a></h1>
</hgroup>
<nav class="header-menu">
<ul>
<li><a href="/archives/">所有文章</a></li>
<li><a href="/tags/">分类&标签</a></li>
<li><a target="_blank" rel="noopener" href="https://www.bitcook.org">BitCook</a></li>
<li><a href="/about/">关于我</a></li>
<div class="clearfix"></div>
</ul>
</nav>
<nav class="header-nav">
<ul class="social">
<a class="fa Email" target="_blank" href="mailto:im@zhiiker.com" title="Email"></a>
<a class="fa RSS" target="_blank" href="http://www.zhiiker.com/atom.xml" title="RSS"></a>
<a class="fa GitHub" target="_blank" href="https://github.com/zhiiker" title="GitHub"></a>
<a class="fa Quora" target="_blank" href="https://www.quora.com/profile/Shichao-Liang-1" title="Quora"></a>
<a class="fa Medium" target="_blank" href="https://medium.com/@zhiiker" title="Medium"></a>
<a class="fa Coding" target="_blank" href="https://dev.tencent.com/u/zhiiker" title="Coding"></a>
<a class="fa V2EX" target="_blank" href="https://www.v2ex.com/member/zhiiker" title="V2EX"></a>
<a class="fa 新浪微博" target="_blank" href="http://weibo.com/tobechaos" title="新浪微博"></a>
<a class="fa 知乎" target="_blank" href="https://www.zhihu.com/people/liangshichao" title="知乎"></a>
<a class="fa 豆瓣" target="_blank" href="https://www.douban.com/people/tobechaos/" title="豆瓣"></a>
<a class="fa 简书" target="_blank" href="http://www.jianshu.com/u/d5add3cb2d34" title="简书"></a>
<a class="fa SegmentFault" target="_blank" href="https://segmentfault.com/u/zhiiker" title="SegmentFault"></a>
<a class="fa 博客园" target="_blank" href="https://www.cnblogs.com/zhiiker" title="博客园"></a>
<a class="fa CSDN" target="_blank" href="http://my.csdn.net/zhiiker" title="CSDN"></a>
<a class="fa 网易云音乐" target="_blank" href="http://music.163.com/#/user/home?id=72587395" title="网易云音乐"></a>
<a class="fa bilibili" target="_blank" href="https://space.bilibili.com/953543/" title="bilibili"></a>
<a class="fa Facebook" target="_blank" href="https://www.facebook.com/realshichao" title="Facebook"></a>
<a class="fa Twitter" target="_blank" href="https://twitter.com/zhiiker" title="Twitter"></a>
<a class="fa LinkedIn" target="_blank" href="https://cn.linkedin.com/in/liangshichao" title="LinkedIn"></a>
<a class="fa QQ" target="_blank" href="https://images.liangs.me/avatars/qrcode_1521369601487.jpg" title="QQ"></a>
<a class="fa PayPal" target="_blank" href="https://paypal.me/realshichao" title="PayPal"></a>
<a class="fa StackOverflow" target="_blank" href="https://stackoverflow.com/users/4978576/zhiiker" title="StackOverflow"></a>
<a class="fa reddit" target="_blank" href="https://www.reddit.com/user/zhiiker/" title="reddit"></a>
</ul>
</nav>
</header>
</div>
<link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
<div class="body-wrap"><article id="post-笔记/2016-09-22.哲学家就餐问题" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/DiningPhilosophersProblem" class="article-date">
<time datetime="2016-09-22T08:46:06.000Z" itemprop="datePublished">2016-09-22</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy" />
<header class="article-header">
<h1 class="article-title" itemprop="name">
哲学家就餐问题
</h1>
</header>
<div class="article-info article-info-post">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/%E7%AC%94%E8%AE%B0/">笔记</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%B9%B6%E5%8F%91/" rel="tag">并发</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" rel="tag">操作系统</a></li></ul>
</div>
<div class="clearfix"></div>
</div>
<div class="article-entry" itemprop="articleBody">
<h2 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h2><p>哲学家就餐问题(Dining philosophers problem)是在计算机科学中的一个经典问题,用来演示在并发计算中多线程同步(Synchronization)时产生的问题。</p>
<p>在1971年,著名的计算机科学家Edsger Wybe Dijkstra(艾兹格·迪科斯彻)提出了一个同步问题,即假设有五台计算机都试图访问五份共享的磁带驱动器。稍后,这个问题被托尼·霍尔重新表述为哲学家就餐问题。这个问题可以用来解释死锁和资源耗尽。</p>
<span id="more"></span>
<p>专门在Github搞了个Repo写课程代码</p>
<div class="github-widget" data-repo="wmwwmv/OSCourse"></div>
<p>哲学家就餐问题可以这样表述,假设有五位哲学家围坐在一张圆形餐桌旁,做以下两件事情之一:吃饭,或者思考。吃东西的时候,他们就停止思考,思考的时候也停止吃东西。餐桌中间有一大碗意大利面,每两个哲学家之间有一只餐叉。因为用一只餐叉很难吃到意大利面,所以假设哲学家必须用两只餐叉吃东西。他们只能使用自己左右手边的那两只餐叉。哲学家就餐问题有时也用米饭和筷子而不是意大利面和餐叉来描述,因为很明显,吃米饭必须用两根筷子。</p>
<p>哲学家从来不交谈,这就很危险,可能产生死锁,每个哲学家都拿着左手的餐叉,永远都在等右边的餐叉(或者相反)。</p>
<p>即使没有死锁,也有可能发生资源耗尽。例如,假设规定当哲学家等待另一只餐叉超过五分钟后就放下自己手里的那一只餐叉,并且再等五分钟后进行下一次尝试。这个策略消除了死锁(系统总会进入到下一个状态),但仍然有可能发生“活锁”。如果五位哲学家在完全相同的时刻进入餐厅,并同时拿起左边的餐叉,那么这些哲学家就会等待五分钟,同时放下手中的餐叉,再等五分钟,又同时拿起这些餐叉。</p>
<h2 id="解决办法"><a href="#解决办法" class="headerlink" title="解决办法"></a>解决办法</h2><p>一、只有当哲学接的左右两只筷子均处于可用状态时,才允许他拿起筷子。这样就可以避免他们同时拿起筷子就餐,导致死锁。</p>
<h3 id="实现代码"><a href="#实现代码" class="headerlink" title="实现代码"></a>实现代码</h3><figure class="highlight java"><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><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Philosopher</span> <span class="keyword">extends</span> <span class="title">Thread</span></span></span><br><span class="line"><span class="class"></span>{</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">int</span> thinkingtimes = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">int</span> eatingtimes = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">int</span> id;</span><br><span class="line"> <span class="keyword">static</span> <span class="keyword">int</span> currentid = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">private</span> Forks fork;</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="title">Philosopher</span><span class="params">(Forks fork)</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> <span class="keyword">super</span>();</span><br><span class="line"> id = currentid;</span><br><span class="line"> currentid++;</span><br><span class="line"> <span class="keyword">this</span>.fork = fork;</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> <span class="keyword">while</span>(<span class="keyword">true</span>)</span><br><span class="line"> {</span><br><span class="line"> thinking();</span><br><span class="line"> fork.takeFork();</span><br><span class="line"> eating();</span><br><span class="line"> fork.putFork();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">thinking</span><span class="params">()</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> thinkingtimes++;</span><br><span class="line"> System.out.println(<span class="string">"Philosopher "</span> + id + <span class="string">" : thinking start! Times : "</span> + thinkingtimes);</span><br><span class="line"> <span class="keyword">try</span> {</span><br><span class="line"> sleep(<span class="number">1000</span>);</span><br><span class="line"> } <span class="keyword">catch</span> (InterruptedException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">eating</span><span class="params">()</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> eatingtimes++;</span><br><span class="line"> System.out.println(<span class="string">"Philosopher "</span> + id + <span class="string">" : eating start! Times : "</span> + eatingtimes);</span><br><span class="line"> <span class="keyword">try</span> {</span><br><span class="line"> sleep(<span class="number">1000</span>);</span><br><span class="line"> } <span class="keyword">catch</span> (InterruptedException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Forks</span></span></span><br><span class="line"><span class="class"></span>{</span><br><span class="line"> <span class="keyword">private</span> <span class="keyword">boolean</span>[] used = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>};</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> <span class="title">takeFork</span><span class="params">()</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> Philosopher p = (Philosopher) Thread.currentThread();</span><br><span class="line"> <span class="keyword">int</span> id = p.id;</span><br><span class="line"> <span class="keyword">while</span>(used[id] || used[(id + <span class="number">1</span>) % <span class="number">5</span>])</span><br><span class="line"> {</span><br><span class="line"> <span class="keyword">try</span> {</span><br><span class="line"> wait();</span><br><span class="line"> } <span class="keyword">catch</span> (InterruptedException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> System.out.println(<span class="string">"Philosopher "</span> + id + <span class="string">" : takeFork!"</span>);</span><br><span class="line"> used[id] = <span class="keyword">true</span>;</span><br><span class="line"> used[(id + <span class="number">1</span>) % <span class="number">5</span>] = <span class="keyword">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> <span class="title">putFork</span><span class="params">()</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> Philosopher p = (Philosopher) Thread.currentThread();</span><br><span class="line"> <span class="keyword">int</span> id = p.id;</span><br><span class="line"> System.out.println(<span class="string">"Philosopher "</span> + id + <span class="string">" : putFork!"</span>);</span><br><span class="line"> used[id] = <span class="keyword">false</span>;</span><br><span class="line"> used[(id + <span class="number">1</span>) % <span class="number">5</span>] = <span class="keyword">false</span>;</span><br><span class="line"> notifyAll();</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DiningPhilosophers</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span></span></span><br><span class="line"><span class="function"> </span>{</span><br><span class="line"> Forks f = <span class="keyword">new</span> Forks();</span><br><span class="line"> <span class="keyword">new</span> Philosopher(f).start();</span><br><span class="line"> <span class="keyword">new</span> Philosopher(f).start();</span><br><span class="line"> <span class="keyword">new</span> Philosopher(f).start();</span><br><span class="line"> <span class="keyword">new</span> Philosopher(f).start();</span><br><span class="line"> <span class="keyword">new</span> Philosopher(f).start();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>二、最多允许4个哲学家同时坐在桌子周围</p>
<figure class="highlight cpp"><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><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">semaphore fork[<span class="number">5</span>] = {<span class="number">1</span>};</span><br><span class="line">semaphore room = {<span class="number">4</span>};</span><br><span class="line"><span class="keyword">int</span> i; <span class="function"><span class="keyword">void</span> <span class="title">philosopher</span> <span class="params">(<span class="keyword">int</span> i)</span> </span>{</span><br><span class="line"> <span class="keyword">while</span> (<span class="literal">true</span>) {</span><br><span class="line"> <span class="built_in">think</span>();</span><br><span class="line"> <span class="built_in">P</span> (room);</span><br><span class="line"> <span class="built_in">P</span> (fork[i]);</span><br><span class="line"> <span class="built_in">P</span> (fork [(i + <span class="number">1</span>) mod <span class="number">5</span>]);</span><br><span class="line"> <span class="built_in">eat</span>();</span><br><span class="line"> <span class="built_in">V</span> (fork [(i + <span class="number">1</span>) mod <span class="number">5</span>]);</span><br><span class="line"> <span class="built_in">V</span> (fork[i]);</span><br><span class="line"> <span class="built_in">V</span> (room);</span><br><span class="line"> }</span><br><span class="line">} <span class="function"><span class="keyword">void</span> <span class="title">main</span><span class="params">()</span> </span>{</span><br><span class="line"> <span class="built_in">parbegin</span> ( <span class="built_in">philosopher</span> (<span class="number">0</span>), <span class="built_in">philosopher</span> (<span class="number">1</span>),</span><br><span class="line"> <span class="built_in">philosopher</span> (<span class="number">2</span>), <span class="built_in">philosopher</span>(<span class="number">3</span>), <span class="built_in">philosopher</span> (<span class="number">4</span>) );</span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>三、给所有哲学家编号,奇数号的哲学家必须首先拿左边的筷子,偶数号的哲学家则反之<br>使用管程解决哲学家就餐问题</p>
<figure class="highlight cpp"><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><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">void</span> philosopher[k=<span class="number">0</span> to <span class="number">4</span>]</span><br><span class="line"><span class="comment">/* the five philosopher clients */</span></span><br><span class="line">{</span><br><span class="line"><span class="keyword">while</span> (<span class="literal">true</span>) {</span><br><span class="line"><think>;</span><br><span class="line"><span class="built_in">get_forks</span>(k);</span><br><span class="line"><span class="comment">/* client requests two forks via monitor */</span></span><br><span class="line"><eat spaghetti>;</span><br><span class="line"><span class="built_in">release_forks</span>(k);</span><br><span class="line"> <span class="comment">/* client releases forks via the monitor */</span></span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">monitor dining_controller;</span><br><span class="line">cond ForkReady[<span class="number">5</span>];</span><br><span class="line">boolean fork[<span class="number">5</span>] = {<span class="literal">true</span>};</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">get_forks</span><span class="params">(<span class="keyword">int</span> pid)</span> </span>{</span><br><span class="line"> <span class="keyword">int</span> left = pid;</span><br><span class="line"> <span class="keyword">int</span> right = (++pid) % <span class="number">5</span>;</span><br><span class="line"> <span class="comment">/*grant the left fork*/</span></span><br><span class="line"> <span class="keyword">if</span> (!fork(left)</span><br><span class="line"> <span class="built_in">cwait</span>(ForkReady[left]);</span><br><span class="line"> <span class="comment">/* queue on condition variable */</span></span><br><span class="line"> fork(left) = <span class="literal">false</span>;</span><br><span class="line"> <span class="comment">/*grant the right fork*/</span></span><br><span class="line"> <span class="keyword">if</span> (!fork(right)</span><br><span class="line"> <span class="built_in">cwait</span>(<span class="built_in">ForkReady</span>(right);</span><br><span class="line"> <span class="comment">/* queue on condition variable */</span></span><br><span class="line"> fork(right) = <span class="literal">false</span>:</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"><span class="keyword">void</span> <span class="built_in">release_forks</span>(<span class="keyword">int</span> pid) {</span><br><span class="line"> <span class="keyword">int</span> left = pid;</span><br><span class="line"> <span class="keyword">int</span> right = (++pid) % <span class="number">5</span>;</span><br><span class="line"> <span class="comment">/*release the left fork*/</span></span><br><span class="line"> <span class="keyword">if</span> (<span class="built_in">empty</span>(ForkReady[left])</span><br><span class="line"> <span class="comment">/*no one is waiting for this fork */</span></span><br><span class="line"> fork(left) = <span class="literal">true</span>;</span><br><span class="line"> <span class="keyword">else</span> <span class="comment">/* awaken a process waiting on this fork */</span></span><br><span class="line"> <span class="built_in">csignal</span>(ForkReady[left]);</span><br><span class="line"> <span class="comment">/*release the right fork*/</span></span><br><span class="line"> <span class="keyword">if</span> (<span class="built_in">empty</span>(ForkReady[right])</span><br><span class="line"> <span class="comment">/*no one is waiting for this fork */</span></span><br><span class="line"> fork(right) = <span class="literal">true</span>;</span><br><span class="line"> <span class="keyword">else</span> <span class="comment">/* awaken a process waiting on this fork */</span></span><br><span class="line"> <span class="built_in">csignal</span>(ForkReady[right]);</span><br><span class="line"> }</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>四、其他解法:服务生解法 资源分级解法 Chandy/Misra解法</p>
</div>
</div>
<div class="copyright">
<p><span>本文标题:</span><a href="/DiningPhilosophersProblem">哲学家就餐问题</a></p>
<p><span>文章作者:</span><a href="/" title="回到主页">undefined</a></p>
<p><span>发布时间:</span>2016-09-22, 16:46:06</p>
<p><span>最后更新:</span>2017-03-05, 17:15:03</p>
<!-- 不设置 backup: false 则默认显示 -->
<p>
<span>更新历史:</span><i class="fa fa-github"></i>
<!-- 不同功能替换前面超链接即可,文件名不变 -->
<!-- 文件名生成: 2016-09-22.笔记/2016-09-22.哲学家就餐问题 -->
<a target="_blank" rel="noopener" href="https://github.com/wmwwmv/BlogBackup/blame/master/_posts/笔记/2016-09-22.哲学家就餐问题.md" title="顺序查看文章各部分修改记录" target = "_blank">Blame</a>,
<a target="_blank" rel="noopener" href="https://github.com/wmwwmv/BlogBackup/commits/master/_posts/笔记/2016-09-22.哲学家就餐问题.md" title="查看文章有关更新记录" target = "_blank">History</a><span class="raw">文本模式:</span><i class="fa fa-file-text-o"></i>
<a target="_blank" rel="noopener" href="https://raw.githubusercontent.com/wmwwmv/BlogBackup/master/_posts/笔记/2016-09-22.哲学家就餐问题.md" title="查看 & 下载文章 Markdown 原始文本" target = "_blank"> .md Raw</a>
</p>
<p>
<span>原始链接:</span><a class="post-url" href="/DiningPhilosophersProblem" title="哲学家就餐问题">https://www.zhiiker.com/DiningPhilosophersProblem</a>
<span class="copy-path" data-clipboard-text="原文: https://www.zhiiker.com/DiningPhilosophersProblem 作者: undefined" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
<script> var clipboard = new Clipboard('.copy-path'); </script>
</p>
<p>
<span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
</p>
</div>
<nav id="article-nav">
<div id="article-nav-newer" class="article-nav-title">
<a href="/2016/09/23/%E7%AC%94%E8%AE%B0/2016-09-23.%E5%9F%BA%E7%A1%80Git%E6%8A%80%E8%83%BD/">
基础Git技能
</a>
</div>
<div id="article-nav-older" class="article-nav-title">
<a href="/2016/09/21/AC++/2016-09-21.%E5%A4%A7%E6%95%B4%E6%95%B0.%E5%90%8C%E4%BD%99%E5%85%B3%E7%B3%BB/">
大整数、同余关系
</a>
</div>
</nav>
</article>
<div id="toc" class="toc-article">
<strong class="toc-title">文章目录</strong>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%97%AE%E9%A2%98%E6%8F%8F%E8%BF%B0"><span class="toc-number">1.</span> <span class="toc-text">问题描述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95"><span class="toc-number">2.</span> <span class="toc-text">解决办法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81"><span class="toc-number">2.1.</span> <span class="toc-text">实现代码</span></a></li></ol></li></ol>
</div>
<style>
.left-col .switch-btn,
.left-col .switch-area {
display: none;
}
.toc-level-6 i,
.toc-level-6 ol {
display: none !important;
}
</style>
<input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">
<script>
yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
</script>
<div class="share">
<div class="addthis_sharing_toolbox"></div>
</div>
<section id="comments" style="margin: 2em; padding: 2em; background: rgba(255, 255, 255, 0.5)">
<div id="vcomment" class="comment"></div>
<!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC80NTk1Ny8yMjQ2OA==">
<script type="text/javascript">
(function (d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
<noscript> 为正常使用来必力评论功能请激活JavaScript</noscript>
</div>
<!-- City版安装代码已完成 -->
</section>
<div class="scroll" id="post-nav-button">
<a href="/2016/09/23/%E7%AC%94%E8%AE%B0/2016-09-23.%E5%9F%BA%E7%A1%80Git%E6%8A%80%E8%83%BD/" title="上一篇: 基础Git技能">
<i class="fa fa-angle-left"></i>
</a>
<a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>
<a href="/2016/09/21/AC++/2016-09-21.%E5%A4%A7%E6%95%B4%E6%95%B0.%E5%90%8C%E4%BD%99%E5%85%B3%E7%B3%BB/" title="下一篇: 大整数、同余关系">
<i class="fa fa-angle-right"></i>
</a>
</div>
<ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2021/03/28/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/2019-08-10.%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F%E6%9B%B4%E6%8D%A2%E4%B8%BAlivere/">评论系统更换为livere</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/08/30/%E7%AC%94%E8%AE%B0/2019-08-30.%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%B5%8B%E8%AF%95%E8%84%9A%E6%9C%AC%E9%9B%86%E5%90%88/">服务器测试脚本集合</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/06/18/%E6%8B%BE%E6%91%98/2019-06-18.%E5%8D%AE%E8%A8%80%E6%97%A5%E5%87%BA%EF%BC%8C%E5%92%8C%E4%BB%A5%E5%A4%A9%E5%80%AA%E4%B8%A8%E3%80%8A%E5%AF%93%E8%A8%80%E3%80%8B%E7%AB%A0%E4%B8%80/">卮言日出,和以天倪丨《寓言》章一</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/04/22/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/2019-04-22.%E5%8D%AE%E5%AE%A2%E6%9D%82%E4%BF%8E%E7%9A%84%E5%90%AB%E4%B9%89/">卮客杂俎的含义</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/02/17/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/Press.one%20%E6%8E%88%E6%9D%83/">Press.one 授权</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/30/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/2018-12-30.%E5%8D%9A%E5%AE%A2%E4%BF%AE%E5%A4%8D/">博客修复</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/13/%E7%AC%94%E8%AE%B0/2018-12-12.Seafile%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AEv3/">Seafile安装与配置v3</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/09/%E7%AC%94%E8%AE%B0/2018-12-09.Hexo%E5%8D%9A%E5%AE%A2%E5%8D%87%E7%BA%A7%E5%B0%8F%E8%AE%B0/">Hexo博客升级小记</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/11/18/%E7%AC%94%E8%AE%B0/2018-11-18.Atom%E4%B8%80%E4%BA%9B%E9%97%AE%E9%A2%98/">Atom的一些问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/11/04/%E7%AC%94%E8%AE%B0/2018-11-04.%E7%94%A8Atom%E5%86%99LaTeX%E6%96%87%E6%A1%A3/">用Atom写LaTeX文档</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/11/03/%E7%AC%94%E8%AE%B0/2018-11-03.%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/11/%E7%BB%93%E7%BB%B3%E7%BA%AA/2018-08-11.%E6%96%B0%E7%9A%84%E5%90%8D%E5%AD%97%E2%80%94%E8%B1%A1%E7%BD%94%E5%8D%AE%E4%BA%BA/">新的名号—象罔卮人(卮客)</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/07/%E7%AC%94%E8%AE%B0/2018-08-07.%E9%85%8D%E7%BD%AEIPython%20Notebook%E6%8F%90%E4%BE%9B%E9%9D%9E%E6%9C%AC%E5%9C%B0%E8%AE%BF%E9%97%AE/">配置IPython Notebook提供非本地访问</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/07/%E7%AC%94%E8%AE%B0/2018-08-06.Ubuntu%E4%B8%8B%E5%AE%89%E8%A3%85pyenv%E3%80%81IPython%20Notebook%E5%92%8C%E7%A7%91%E5%AD%A6%E8%AE%A1%E7%AE%97%E5%8C%85%E7%9A%84%E8%BF%87%E7%A8%8B%E6%80%BB%E7%BB%93/">Ubuntu下安装pyenv、IPython Notebook和科学计算包的过程总结</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/11/%E7%AC%94%E8%AE%B0/2018-04-11.%E4%B8%AA%E4%BA%BA%E8%AF%BB%E4%B9%A6%E7%BB%8F%E5%8E%86/">个人读书经历</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/02/%E7%AC%94%E8%AE%B0/2017-08-02.%E5%90%8C%E6%97%B6%E6%8A%8A%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E5%88%B0%E4%B8%A4%E4%B8%AAgit%E4%BB%A3%E7%A0%81%E6%89%98%E7%AE%A1%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A/">同时把代码提交到两个git代码托管的服务器上</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/01/%E7%AC%94%E8%AE%B0/2017-08-01.%E4%BD%BF%E7%94%A8cpuminer%E5%9C%A8Linux%E7%8E%AF%E5%A2%83%E4%B8%8B%E7%94%A8CPU%E6%8C%96%E7%9F%BF/">使用cpuminer在Linux环境下用CPU挖矿</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/27/%E7%AC%94%E8%AE%B0/2017-07-27.%E8%A7%A3%E5%86%B3Hexo%20deploy%E5%A4%B1%E8%B4%A5/">解决Hexo deploy失败</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/19/%E7%AC%94%E8%AE%B0/2017-07-19.Dropbox%20+%20VPS%20+%20Incrond+Hexo%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2%E5%B0%8F%E8%AE%B0/">Dropbox + VPS + Incrond+Hexo搭建博客小记</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/17/%E7%AC%94%E8%AE%B0/2017-07-17.%E5%B0%86%E4%B8%8D%E5%90%8C%E5%9C%B0%E6%96%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E5%90%8C%E6%AD%A5%E5%88%B0Dropbox/">将不同地方文件夹同步到Dropbox</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/17/%E7%AC%94%E8%AE%B0/2017-07-17.fs.SyncWriteStream%20is%20deprecated/">fs.SyncWriteStream is deprecated</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/12/%E7%AC%94%E8%AE%B0/2017-07-11.%E4%BD%BF%E7%94%A8Seafile+ossfs+oss%E6%90%AD%E5%BB%BA%E5%B1%9E%E4%BA%8E%E8%87%AA%E5%B7%B1%E7%9A%84%E7%A7%81%E6%9C%89%E4%BA%91%E7%9B%98/">使用Seafile+ossfs+oss搭建属于自己的私有云盘</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/11/%E7%AC%94%E8%AE%B0/2017-07-11.%E5%8D%87%E7%BA%A7Seafile%E5%88%B0%E4%B8%93%E4%B8%9A%E7%89%88/">升级Seafile到专业版,更换端口,开机启动</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/20/%E7%AC%94%E8%AE%B0/2017-03-20.JSP%E4%B8%8EServlet%E4%B9%8B%E9%97%B4%E4%BC%A0%E5%80%BC/">JSP与Servlet之间传值</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/19/%E7%AC%94%E8%AE%B0/2017-03-19.Linux%20%E4%B8%8B%E6%89%A7%E8%A1%8C%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%20crontab%20%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/">Linux 下执行定时任务 crontab 命令详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/02/22/%E7%AC%94%E8%AE%B0/2017-02-22.%E4%B8%AA%E4%BA%BA%E5%90%8D%E7%A7%B0-%E5%BC%95%E7%94%A8%E7%9A%84%E4%B8%80%E4%BA%9B%E5%87%BA%E5%A4%84/">个人名称、引用的一些出处</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/11/23/%E7%AC%94%E8%AE%B0/2016-11-23.oracle%E4%B8%AD%E5%85%B3%E4%BA%8E%E5%8D%95%E5%BC%95%E5%8F%B7%E5%92%8C%E5%8F%8C%E5%BC%95%E5%8F%B7%E7%9A%84%E9%97%AE%E9%A2%98/">oracle中关于单引号和双引号的问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/11/16/%E7%AC%94%E8%AE%B0/2016-11-16.%E7%AC%94%E8%AE%B0%E7%BC%96%E8%BE%91%E5%B7%A5%E5%85%B7%E7%9A%84%E6%9C%80%E5%90%8E%E9%80%89%E6%8B%A9/">最终的写作解决方案</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/11/16/%E7%AC%94%E8%AE%B0/2016-11-16.use_case-when_implement_if-then-else_logic/">使用case-when实现if-then-else逻辑</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/29/%E7%AC%94%E8%AE%B0/2016-09-29.%E5%A6%82%E4%BD%95%E5%9C%A8Linux%E4%B8%AD%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E4%BA%A4%E6%8D%A2%E6%96%87%E4%BB%B6/">如何在Linux中创建一个交换文件</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/28/%E7%AC%94%E8%AE%B0/2016-09-28.Python%E4%B8%AD%E7%9A%84%E6%B3%A8%E9%87%8A/">Python中的注释</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/28/%E7%AC%94%E8%AE%B0/2016-09-28.%E6%9C%89%E5%85%B3%E7%AC%94%E8%AE%B0%E7%9A%84%E7%AE%A1%E7%90%86/">有关笔记管理</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/23/%E7%AC%94%E8%AE%B0/2016-09-23.Hexo%E5%B0%8F%E6%8A%80%E5%B7%A7/">Hexo小技巧</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/23/%E7%AC%94%E8%AE%B0/2016-09-23.CMD%E5%91%BD%E4%BB%A4%E8%A1%8C/">CMD命令行</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/23/%E7%AC%94%E8%AE%B0/2016-09-23.%E5%9F%BA%E7%A1%80Git%E6%8A%80%E8%83%BD/">基础Git技能</a></li><li class="post-list-item"><a class="post-list-link" href="/DiningPhilosophersProblem">哲学家就餐问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/21/AC++/2016-09-21.%E5%A4%A7%E6%95%B4%E6%95%B0.%E5%90%8C%E4%BD%99%E5%85%B3%E7%B3%BB/">大整数、同余关系</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/18/AC++/2016-09-18.ICPC2016%E6%B2%88%E9%98%B3%E5%8C%BA%E5%9F%9F%E7%BD%91%E7%BB%9C%E8%B5%9B/">ICPC2016沈阳区域网络赛</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/17/AC++/2016-09-17.ICPC2016%E9%9D%92%E5%B2%9B%E5%8C%BA%E5%9F%9F%E7%BD%91%E7%BB%9C%E8%B5%9B/">ICPC2016青岛区域网络赛</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/05/%E7%AC%94%E8%AE%B0/2016-09-05.Linux%E4%B8%8B%E4%BD%BF%E7%94%A8SSH%E8%BF%9E%E6%8E%A5Windows/">Linux下使用SSH连接Windows</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/09/04/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/%E4%B9%A6%E9%98%81/">书阁</a></li><li class="post-list-item"><a class="post-list-link" href="/Hexo%E6%8F%90%E4%BA%A4%E5%88%B0Github%E9%94%99%E8%AF%AF">Hexo提交到Github错误</a></li><li class="post-list-item"><a class="post-list-link" href="/%E7%B4%A0%E6%8B%93%E7%BD%91%E7%AB%99%E7%9A%84%E4%B8%80%E4%BA%9B%E6%8A%80%E5%B7%A7">素拓网站的一些技巧</a></li><li class="post-list-item"><a class="post-list-link" href="/Oracle%E5%AE%89%E8%A3%85%E4%B8%8E%E5%8D%B8%E8%BD%BD">Oracle安装与卸载</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/30/%E7%BB%93%E7%BB%B3%E7%BA%AA/2016-07-30.%E5%8E%BB%E7%94%9F%E6%B4%BB%EF%BC%8C%E5%8E%BB%E7%8A%AF%E9%94%99%EF%BC%8C%E5%8E%BB%E8%B7%8C%E5%80%92%EF%BC%8C%E5%8E%BB%E8%83%9C%E5%88%A9%EF%BC%8C%E5%8E%BB%E7%94%A8%E7%94%9F%E5%91%BD%E5%86%8D%E5%88%9B%E7%94%9F%E5%91%BD/">去生活,去犯错,去跌倒,去胜利,去用生命再创生命</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/30/%E7%AC%94%E8%AE%B0/2016-07-30.Hexo%E4%B8%80%E4%BA%9B%E8%AF%AD%E6%B3%95/">Hexo一些语法</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/30/%E7%AC%94%E8%AE%B0/2016-07-30.%E9%AB%98%E5%88%86%E5%B1%8F%E4%B8%8B%E5%AD%97%E4%BD%93%E6%98%BE%E7%A4%BA%E7%9A%84%E6%9C%80%E7%BB%88%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/">高分屏下字体显示的最终解决方案</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/28/%E7%AC%94%E8%AE%B0/2016-07-28.Ubuntu%E4%B8%8BAnaconda%E5%AE%89%E8%A3%85/">Ubuntu下Anaconda安装</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/27/%E7%AC%94%E8%AE%B0/2016-07-07.Sublime%E4%BE%A7%E8%BE%B9%E6%A0%8F%E4%B9%B1%E7%A0%81%E5%92%8C%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0%E6%98%BE%E7%A4%BA%E4%B8%8D%E6%B8%85%E6%99%B0/">Sublime侧边栏乱码和有道云笔记显示不清晰</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/27/AC++/2016-07-27.Ubuntu%E4%B8%8BSublimeC%E5%92%8CCpp%E9%85%8D%E7%BD%AE/">Ubuntu下SublimeC&C++配置</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/27/AC++/2016-07-27.%E5%90%AB%E4%B9%89/">含义</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/26/%E5%BB%BA%E7%AB%99%E6%97%A5%E5%BF%97/%E7%AB%99%E7%82%B9%E8%BF%81%E7%A7%BB/">站点迁移</a></li><li class="post-list-item"><a class="post-list-link" href="/site-building-log">建站日志</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/07/%E6%8B%BE%E6%91%98/2016-07-07.%E5%B9%BF%E7%94%B5%E6%80%BB%E5%B1%80,%E4%B8%AD%E6%96%87%E5%9F%9F%E5%90%8D/">广电总局 中文域名</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/07/%E6%8B%BE%E6%91%98/2016-07-07.%E5%A4%A7%E5%9B%BD%E5%9B%BD%E6%B0%91%E7%9A%84%E6%83%85%E6%80%80/">大国国民的情怀</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/07/06/%E6%8B%BE%E6%91%98/2016-07-06.%E6%B0%B8%E8%BF%9C%E4%BF%9D%E6%8C%81%E5%A5%BD%E5%A5%87%E5%BF%83/">永远保持好奇心</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/06/27/%E7%AC%94%E8%AE%B0/2016-06-27.%E5%90%84%E7%A7%8D%E5%A5%87%E8%91%A9%E4%B8%AD%E6%96%87%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/">各种奇葩中文编程语言</a></li><li class="post-list-item"><a class="post-list-link" href="/ShadowsocksIPV4n6">Shadowsocks IPV4&IPV6服务器端配置</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/06/13/%E6%8B%BE%E6%91%98/2016-06-13.%E7%AC%AC%E4%B8%80%E9%83%A8%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD%E5%86%99%E7%9A%84%E7%94%B5%E5%BD%B1/">第一部人工智能写的电影</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/11/%E7%AC%94%E8%AE%B0/2016-05-11.EclipseChe/">EclipseChe</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/11/%E7%AC%94%E8%AE%B0/2016-05-11.%E4%BA%91%E6%95%B0%E6%8D%AE%E5%BA%93/">云数据库</a></li><li class="post-list-item"><a class="post-list-link" href="/the-solution-for-writing">写作需求的解决方案</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/10/11/%E6%8B%BE%E6%91%98/2015-10-11.%E6%96%87%E8%A8%80%E6%96%87Perl%E7%BC%96%E7%A8%8B%E5%86%99%E8%AF%97by%E5%94%90%E5%87%A4(%E5%94%90%E5%AE%97%E6%B1%89)/">唐凤(唐宗汉)文言文Perl编程</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/10/10/%E6%8B%BE%E6%91%98/2015-10-10.The%20Secret%20World%20of%20WDMA%20Sites/">The Secret World of WDMA Sites</a></li></ul>
<script>
</script>
<script>
(function () {
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script></div>
<footer id="footer">
<div class="outer">
<div id="footer-info">
<div class="footer-left">
<i class="fa fa-copyright"></i>
2014-2021 卮客
<a target="_blank" rel="noopener" href="http://beian.miit.gov.cn">辽ICP备15012582-16</a>
</div>
<div class="footer-right">
<a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a> Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题 v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
</div>
</div>
<div class="visit">
<span id="busuanzi_container_site_pv" style='display:none'>
<span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
</span>
</span>
<span>| </span>
<span id="busuanzi_container_page_pv" style='display:none'>
<span id="page-visit" title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
</span>
</span>
</div>
<div class="footer">
<a target="_blank" rel="noopener" href="https://www.upyun.com">
<img src="./images/upyun-logo-60.png" />
</a>
<br/>提供支持
</div>
</div>
</footer>
</div>
<script src="/js/GithubRepoWidget.js"></script>
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>
<script>
$(document).ready(function() {
var iPad = window.navigator.userAgent.indexOf('iPad');
if (iPad > -1 || $(".left-col").css("display") === "none") {
var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
$("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
}
else {
var backgroundnum = 6;
var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
$("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
}
})
</script>
<!-- Google Analytics -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-131531271-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<div class="scroll" id="scroll">
<a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
<a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
<a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
// Open in New Window
var oOpenInNew = {
github: ".github-widget a",
archives: ".archive-article-title",
miniArchives: "a.post-list-link",
friends: "#js-friends a",
socail: ".social a"
}
for (var x in oOpenInNew) {
$(oOpenInNew[x]).attr("target", "_blank");
}
</script>
<script>
var originTitle = document.title;
var titleTime;
document.addEventListener("visibilitychange", function() {
if (document.hidden) {
document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
clearTimeout(titleTime);
}
else {
document.title = "(*´∇`*) 被你发现啦~ " + originTitle;
titleTime = setTimeout(function() {
document.title = originTitle;
}, 2000);
}
})
</script>
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
</div>
</body>
</html>