Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

关于ticks心跳溢出问题

39 views
Skip to first unread message

长井

unread,
Sep 6, 2013, 5:46:31 AM9/6/13
to osfrom...@googlegroups.com
hi
如果ticks溢出了,会不会有问题 ,系统是怎么处理溢出引起的错误。因为代码有一个时间函数是用心跳实现的


xiaoyao

unread,
Sep 8, 2013, 11:56:12 PM9/8/13
to osfrom...@googlegroups.com
没那么容易溢出,linux/unix也是用一个长整型来表示tick,好几十年才溢出呢


2013/9/6 长井 <060...@163.com>
hi
如果ticks溢出了,会不会有问题 ,系统是怎么处理溢出引起的错误。因为代码有一个时间函数是用心跳实现的


--
--
You received this message because you are subscribed to the Google
Groups "自己动手写操作系统" group.
To post to this group, send email to osfrom...@googlegroups.com
To unsubscribe from this group, send email to
osfromscratc...@googlegroups.com
For more options, visit this group at
https://groups.google.com/group/osfromscratch?hl=en
 
---
You received this message because you are subscribed to the Google Groups "自己动手写操作系统" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osfromscratc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

长井

unread,
Sep 9, 2013, 6:35:11 AM9/9/13
to osfrom...@googlegroups.com

那long型是4个字节 我算了一下如果10ms一个计数,那就一年多就溢出了,还是挺危险的,想服务器基本开机就不能关机了,
就更有可能溢出了

For more options, visit this group at
https://groups.google.com/group/osfromscratch?hl=en
 
---
You received this message because you are subscribed to the Google Groups "自己动手写操作系统" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osfromscratch+unsub...@googlegroups.com.

GNU is not unix

unread,
Sep 9, 2013, 11:32:39 PM9/9/13
to osfrom...@googlegroups.com
没有溢出的说法,达到最大数之后又返回来。把它看成一个环。
使用ticks的时候,一般都是用tikcs的相对量差。


2013/9/9 长井 <060...@163.com>

长井

unread,
Sep 9, 2013, 11:45:11 PM9/9/13
to osfrom...@googlegroups.com
怎么会没有呢,溢出了 ,那差值不就错误了么,假如ticks是1个字节的话,如果当前的值是255,
然后又增加2个ticks变成0 ,这个时候的0减255的相对量差不就出问题了

GNU is not unix

unread,
Sep 10, 2013, 12:47:42 AM9/10/13
to osfrom...@googlegroups.com
变成0之后不就转一圈了么,0不就是256么。


2013/9/10 长井 <060...@163.com>

pingfan ren

unread,
Oct 24, 2017, 9:20:33 AM10/24/17
to 自己动手写操作系统
255 增加2个ticks变成0,和增加258个ticks变成0,是无法区分出来,都计算为差值为2ticks。但实际上,32位的表示,溢出两次的时间要挺长的,而人们一般计算差值时,都在一次溢出时间之内。
Reply all
Reply to author
Forward
0 new messages