文件操作引发的血案

来源:互联网 发布:apache2.4 php7 mysql 编辑:程序博客网 时间:2024/05/16 02:17

case1:

    lTemp=DateFormat;
    _WriteCfgInt(OsdRunCfg,"stream1_osd","TimeFormat",lTemp);
    _WriteCfgInt(OsdRunCfg,"stream2_osd","TimeFormat",lTemp);

    sleep(1);        //wait for file operation complete! 如果不加延迟1s,就会发生进度已经收到消息通知,去读入配置文件,结果发现实际上配置文件还未有更新完毕。所以,我怀疑_WriteCfgInt()函数里有sleep动作,会导致迟滞写入。

 

    ret=_SimpleSendMsg(OSD_QUEUE,OSD_MSG_TYPE);    //send notification to osd thread(AVserver process)

 

case2:

            Byte1 = 0;
            Byte2 = ucTemp+1;
            ret=I2C_WriteByte(MOTOR_I2C_ADDR,&Byte1,&Byte2,1);    //why we can not call this func? libdrv.so is not right??

            ret=_WriteCfgInt("/mnt/mtd/general.conf","Optical","zoomnow",ucTemp);

这个结果是正确的。I2C写入无误。但如果这样写:

            Byte1 = 0;
            Byte2 = ucTemp+1;
            ret=_WriteCfgInt("/mnt/mtd/general.conf","Optical","zoomnow",ucTemp);

            ret=I2C_WriteByte(MOTOR_I2C_ADDR,&Byte1,&Byte2,1);    //why we can not call this func? libdrv.so is not right??

这样写的话,I2C将无法正确写入!

 

原创粉丝点击