设万维读者为首页 广告服务 技术服务 联系我们 关于万维
简体 繁体 手机版
分类广告
版主:白夫长
万维读者网 > 军事天地 > 帖子
重走傻屄憨鸠路
送交者: 姚夭夭 2015年05月04日15:10:19 于 [军事天地] 发送悄悄话

重走傻屄憨鸠路。当年杨X伟让我们在Unix(用IBM-PC/AT机上的Xinex冒充)
演示进程间用“信号灯”进行同步。当时就做不出来。当时连C语言都不理解,全局变
量是什么意思都不懂。做条毛啊。计算机系的一群傻屄憨鸠拿着纱纸还真以为自己学
习成绩“很”好。还是岑某文书记利害,根本不用学计算机,凭马克思主义“放猪四海
皆准”的宇宙真理一眼就看穿你们这帮孙子学习成绩都不是“很”好。不但你们学习
成绩不是“很”好,你们的学校的水平还“很”不高。杨X伟还狗屁“很”不通。

现在还是做不出来。因为Unixv6根本不提供“信号灯”,我们的用户程序的逻辑空间
是相互独立的,我们的用户程序运行在非特权处理机状态,不能屏蔽中断。总之,这题
在Unixv6上根本做不出来。

现在想了想,应当可以用两个pipe来同步两个进程。

当然如果用个很高级的技巧,利用文件缓冲块是共享的这一点,可以有没有屏蔽中断
的非特权处理机状态下实现信号灯的。这个是我当年在美国上学时从一本日本人写
的操作系统的书上学到的。不过效率极低,没啥实用价值。可以用来玩一玩。这个技
巧,我小时候坐车到县城过盘山公路时发现司机都懂(有一段路每次只能过一辆车,
其他车只能在山下等,否则对向的车开到山顶斗牛,谁都过不了,其中一辆车要倒车
下山,更加危险)。毛主席说过:高贵者最愚蠢,我敢说,这里的电民,学位一堆,要是
没看过日本人的那本书或者看过没留神,多数不会。哈哈。

有些军事五毛要跳出来装神弄鬼,说我上学的学校在中国是最差的,别的学校满柜都
是“土楞奖”的奖章我没机会看而已。中国做不出CPU和OS是故意不做,不是水平低
做不出来。哈哈。


以下是两个进程竟争电传打字机的结果。很奇怪,为何父进程的优先权比子进程高得
多。父进程每次能打一行,而子进程每次只能打一个字符。想不通。看来Unixv6的
优先级设定还是很谎谬的。同样的两个进程,争用同一个资源,为什么差别这么大呢。


main()
{
    if(fork())
    {
        execl("parent",0);
    }
    execl("child",0);
}

main()
{
    int count;
    count=100;
    while(count--)
        printf("the parent%d process is running! ",count);
}

main()
{
    int count;
    count=100;
    while(count--)
        printf("CHILD_%d ",count);
}

# fork
the parent99 process is running!
the parent98 proCcess is running!
the parent97 prHocess is running!
the parent96 prIocess is running!
the parent95 prLocess is running!
the parent94 prDocess is running!
the parent93 pr_ocess is running!
the parent92 pr9ocess is running!
the parent91 pr9ocess is running!
the parent90 pr
ocess is running!
the parent89 Cprocess is running!
the parent88 prHocess is running!
the parent87 prIocess is running!
the parent86 prLocess is running!
the parent85 prDocess is running!
the parent84 pr_ocess is running!
the parent83 pr9ocess is running!
the parent82 pr8ocess is running!
the parent81 pr
ocess is running!
the parent80 Cprocess is running!
the parent79 prHocess is running!
the parent78 prIocess is running!
the parent77 prLocess is running!
the parent76 prDocess is running!
the parent75 pr_ocess is running!
the parent74 pr9ocess is running!
the parent73 pr7ocess is running!
the parent72 pr
ocess is running!
the parent71 Cprocess is running!
the parent70 prHocess is running!
the parent69 prIocess is running!
the parent68 prLocess is running!
the parent67 prDocess is running!
the parent66 pr_ocess is running!
the parent65 pr9ocess is running!
the parent64 pr6ocess is running!
the parent63 pr
ocess is running!
the parent62 Cprocess is running!
the parent61 prHocess is running!
the parent60 prIocess is running!
the parent59 prLocess is running!
the parent58 prDocess is running!
the parent57 pr_ocess is running!
the parent56 pr9ocess is running!
the parent55 pr5ocess is running!
the parent54 pr
ocess is running!
the parent53 Cprocess is running!
the parent52 prHocess is running!
the parent51 prIocess is running!
the parent50 prLocess is running!
the parent49 prDocess is running!
the parent48 pr_ocess is running!
the parent47 pr9ocess is running!
the parent46 pr4ocess is running!
the parent45 pr
ocess is running!
the parent44 Cprocess is running!
the parent43 prHocess is running!
the parent42 prIocess is running!
the parent41 prLocess is running!
the parent40 prDocess is running!
the parent39 pr_ocess is running!
the parent38 pr9ocess is running!
the parent37 pr3ocess is running!
the parent36 pr
ocess is running!
the parent35 Cprocess is running!
the parent34 prHocess is running!
the parent33 prIocess is running!
the parent32 prLocess is running!
the parent31 prDocess is running!
the parent30 pr_ocess is running!
the parent29 pr9ocess is running!
the parent28 pr2ocess is running!
the parent27 pr
ocess is running!
the parent26 Cprocess is running!
the parent25 prHocess is running!
the parent24 prIocess is running!
the parent23 prLocess is running!
the parent22 prDocess is running!
the parent21 pr_ocess is running!
the parent20 pr9ocess is running!
the parent19 pr1ocess is running!
the parent18 pr
ocess is running!
the parent17 Cprocess is running!
the parent16 prHocess is running!
the parent15 prIocess is running!
the parent14 prLocess is running!
the parent13 prDocess is running!
the parent12 pr_ocess is running!
the parent11 pr9ocess is running!
the parent10 pr0ocess is running!
the parent9 pro
cess is running!
the parent8 prCocess is running!
the parent7 procHess is running!
the parent6 procIess is running!
the parent5 procLess is running!
the parent4 procDess is running!
the parent3 proc_ess is running!
the parent2 proc8ess is running!
the parent1 proc9ess is running!
the parent0 proc
ess is running!
CHILD_88
CH#I LD_87
CHILD_86
CHILD_85
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
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
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
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

#

 

0%(0)
0%(0)
标 题 (必选项):
内 容 (选填项):
实用资讯
回国机票$360起 | 商务舱省$200 | 全球最佳航空公司出炉:海航获五星
海外华人福利!在线看陈建斌《三叉戟》热血归回 豪情筑梦 高清免费看 无地区限制
一周点击热帖 更多>>
一周回复热帖
历史上的今天:回复热帖
2014: 日媒:中国无人机制造十年后领先全球 
2014: 崔哥:犹太人誓死感恩大上海!唯一不记
2013: 号外:日本钓鱼岛作战指挥官被干掉
2013: 热烈祝贺王师X51A高超音速项目圆满成功
2012: 英媒评价:被中国军舰炮口吓坏 菲律宾
2012: 我在美军航母上的八年(3)---志愿参军
2011: 一根毛,力挽狂浪,三把刀都表态拉登没
2011: 奥巴马彻底傻眼:本拉登发出录音,死的是
2010: 毛主席超暴语录,苏联外长吓得屁滚尿流
2010: 从油耗看中国99坦克和西方主战坦克的差