GithubHelp home page GithubHelp logo

itimer.c & itimer.h about asyncnet HOT 7 CLOSED

zhangyuchun avatar zhangyuchun commented on July 25, 2024
itimer.c & itimer.h

from asyncnet.

Comments (7)

skywind3000 avatar skywind3000 commented on July 25, 2024

up-to 0x7fffffff millisec (24 days) is enough for modern operation systems. longer period can be divided into sub periods.

from asyncnet.

zhangyuchun avatar zhangyuchun commented on July 25, 2024

我的意思是。这定时器,最多只能运行正常49天,因为保存当前时间的变量是uint32_t,一直在运行的话,这个值会一直增加,如果初值为0,正好可以运行49天,如果初值不为0, 运行不到49天。而不是定时器的时长49天或int32的24天是足够了。

from asyncnet.

skywind3000 avatar skywind3000 commented on July 25, 2024

你没看懂,你好好看看所有判断时间的地方是怎么写的

from asyncnet.

zhangyuchun avatar zhangyuchun commented on July 25, 2024

关于时间超过uint32的范围,我只看到以下地方,有一部分处理,但处理并不完善。
if (diff > ITIMER_MGR_LIMIT + limit) {
mgr->millisec = millisec;
}
else if (diff < -ITIMER_MGR_LIMIT - limit) {
mgr->millisec = millisec;
}

from asyncnet.

skywind3000 avatar skywind3000 commented on July 25, 2024

具体哪行有问题呢?你还是没理解,关键处是求时间差并非直接相减,而都是itimediff函数,由于负数在计算机内是补码方式存在,-1是0xffffffff不是0x80000001。刚好范围就是循环的,itimediff(1,0xffffffff)的值为2,并非-0xfffffffe。这样的循环效果只要前后不超过0x7fffffff,有什么问题呢?tcp协议实现中sn照样是是uint32的,用的同样的循环计算法,每次链接建立时初始sn还都是随机值,照你的理解,每次tcp传文件如果内容大于或者接近4g时,链接不得断开重新来啊?

from asyncnet.

zhangyuchun avatar zhangyuchun commented on July 25, 2024

thanks . 实际测试了下。确实如此。

from asyncnet.

skywind3000 avatar skywind3000 commented on July 25, 2024

基础知识啊。。。。。

from asyncnet.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.