設萬維讀者為首頁 廣告服務 技術服務 聯繫我們 關於萬維
簡體 繁體 手機版
分類廣告
版主:
萬維讀者網 > 靈機一動 > 跟帖
我也許是世界唯一完成楊X偉交給的不可能的任務的人:用“信號燈
送交者: 姚夭夭 2015月05月06日15:41:57 於 [靈機一動] 發送悄悄話
回  答: 路是單行的山路,還指望有計算機?哈哈。我將這個問題說清楚點。姚夭夭 於 2015-05-05 14:26:05


我也許是世界唯一完成楊X偉交給的不可能的任務的人:用“信號燈演示父子進程在UnixV6上同步”。



我用了昨天討論的“過山車協議”來實現“信號燈”。不需要特權態的“屏蔽中斷”,但利用了父子進程共享打開文件這個事,共享了打開文件內存緩衝塊,再加上“過山車協議”就能實現“信號燈”了。



楊老師要是沒死的話,現在已經官至教授博導了吧。



傻屄憨鳩們不用記筆記,這個方法效率很低,沒啥實用價值。只是作為學習演示用。





程序在“我的新屎坑:https://groups.google.com/forum/#!topic/chanzhaiming/EGjzJAXab_I”三個附件。



我的新屎坑:https://groups.google.com/d/forum/chanzhaiming”。





輸出結果如下所示。



 

 

 


# fork
the file discriptor is 3
the parent99 process is running!
the parent98 process is running!
CHILD_99
CHILD_98
CHILD_97
CHILD_96
CHILD_95
CHILD_94
CHILD_93
CHILD_92
CHILD_91
CHILD_90
CHILD_89
CHILD_88
CHILD_87
CHILD_86
CHILD_85
the parent97 process is running!
the parent96 process is running!
the parent95 process is running!
the parent94 process is running!
the parent93 process is running!
the parent92 process is running!
the parent91 process is running!
the parent90 process is running!
the parent89 process is running!
the parent88 process is running!
the parent87 process is running!
the parent86 process is running!
the parent85 process is running!
the parent84 process is running!
the parent83 process is running!
the parent82 process is running!
the parent81 process is running!
the parent80 process is running!
the parent79 process is running!
the parent78 process is running!
CHILD_84
CHILD_83
CHILD_82
CHILD_81
CHILD_80
CHILD_79
CHILD_78
CHILD_77
CHILD_76
CHILD_75
CHILD_74
CHILD_73
CHILD_72
CHILD_71
CHILD_70
CHILD_69
CHILD_68
CHILD_67
CHILD_66
CHILD_65
CHILD_64
the parent77 process is running!
the parent76 process is running!
the parent75 process is running!
the parent74 process is running!
the parent73 process is running!
the parent72 process is running!
the parent71 process is running!
the parent70 process is running!
the parent69 process is running!
the parent68 process is running!
the parent67 process is running!
the parent66 process is running!
the parent65 process is running!
the parent64 process is running!
the parent63 process is running!
CHILD_63
CHILD_62
CHILD_61
CHILD_60
CHILD_59
CHILD_58
CHILD_57
CHILD_56
CHILD_55
CHILD_54
CHILD_53
CHILD_52
CHILD_51
CHILD_50
CHILD_49
CHILD_48
CHILD_47
CHILD_46
CHILD_45
CHILD_44
CHILD_43
CHILD_42
CHILD_41
CHILD_40
CHILD_39
CHILD_38
CHILD_37
the parent62 process is running!
the parent61 process is running!
the parent60 process is running!
the parent59 process is running!
the parent58 process is running!
the parent57 process is running!
the parent56 process is running!
the parent55 process is running!
the parent54 process is running!
the parent53 process is running!
the parent52 process is running!
the parent51 process is running!
the parent50 process is running!
the parent49 process is running!
the parent48 process is running!
the parent47 process is running!
the parent46 process is running!
the parent45 process is running!
the parent44 process is running!
the parent43 process is running!
CHILD_36
CHILD_35
CHILD_34
CHILD_33
CHILD_32
CHILD_31
CHILD_30
CHILD_29
CHILD_28
CHILD_27
CHILD_26
CHILD_25
CHILD_24
CHILD_23
CHILD_22
CHILD_21
CHILD_20
the parent42 process is running!
the parent41 process is running!
the parent40 process is running!
the parent39 process is running!
the parent38 process is running!
the parent37 process is running!
the parent36 process is running!
the parent35 process is running!
the parent34 process is running!
the parent33 process is running!
the parent32 process is running!
the parent31 process is running!
the parent30 process is running!
the parent29 process is running!
the parent28 process is running!
the parent27 process is running!
the parent26 process is running!
the parent25 process is running!
the parent24 process is running!
the parent23 process is running!
CHILD_19
CHILD_18
CHILD_17
CHILD_16
CHILD_15
CHILD_14
CHILD_13
CHILD_12
CHILD_11
CHILD_10
CHILD_9
CHILD_8
CHILD_7
CHILD_6
CHILD_5
CHILD_4
CHILD_3
CHILD_2
CHILD_1
CHILD_0
the parent22 process is running!
the parent21 process is running!
the parent20 process is running!
the parent19 process is running!
the parent18 process is running!
the parent17 process is running!
the parent16 process is running!
the parent15 process is running!
the parent14 process is running!
the parent13 process is running!
the parent12 process is running!
the parent11 process is running!
the parent10 process is running!
the parent9 process is running!
the parent8 process is running!
the parent7 process is running!
the parent6 process is running!
the parent5 process is running!
the parent4 process is running!
the parent3 process is running!
the parent2 process is running!
the parent1 process is running!
the parent0 process is running!
#
0%(0)
0%(0)
    這個是上次沒有同步的輸出 - 姚夭夭 05/06/15 (1627)
標  題 (必選項):
內  容 (選填項):
實用資訊
回國機票$360起 | 商務艙省$200 | 全球最佳航空公司出爐:海航獲五星
海外華人福利!在線看陳建斌《三叉戟》熱血歸回 豪情築夢 高清免費看 無地區限制
一周點擊熱帖 更多>>
一周回復熱帖
歷史上的今天:回復熱帖
2014: 求四維球體積
2013: 有沒有同學當年曾做過這個噩夢?現在有
2011: 趣味幾何問題
2010: 聯合國總部搬遷到上海