设万维读者为首页 广告服务 技术服务 联系我们 关于万维
简体 繁体 手机版
分类广告
版主:
万维读者网 > 灵机一动 > 跟帖
我也许是世界唯一完成杨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: 联合国总部搬迁到上海