简体   繁体   English

重塑轮子:时间课

[英]Reinventing the Wheel: the time class

I am trying to reinvent the wheel and I want to create a time class in c++, I do want this class to be dependent of any c/c++ std libraries, why ? 我试图重新发明轮子,我想在c ++中创建一个时间类,但我确实希望此类依赖于任何c / c ++ std库,为什么? because I am writing a small OS for fun, but I can't seem to find to find information regarding how I would start. 因为我正在写一个小型OS,很有趣,但是我似乎找不到关于如何开始的信息。 can anyone lead me in the right direction ? 谁能把我引向正确的方向? most of the search I find are just how to use a std library to get time... 我发现的大部分搜索都只是如何使用性病库来获取时间...

Thanks 谢谢

Sorry let me fix that a small os that is x86 for now. 抱歉,我现在修复一个小的操作系统,即x86。

Older PCs have an RTC (Real Time Clock) the never ones use HPET (High Precision Event Timer). 较旧的PC具有RTC(实时时钟),而从未使用过HPET(高精度事件计时器)。

Dig into the linux kernel source if you want to see how to program them. 如果您想了解如何对它们进行编程,请挖掘linux内核源代码。 Unices also have a clock associated with the running process which is only ticking when the process is running, this is entirely an OS feature. Unices还具有与正在运行的进程关联的时钟,该时钟仅在进程运行时才滴答滴答,这完全是OS的功能。

Update: http://www.intel.com/hardwaredesign/hpetspec_1.pdf 更新: http : //www.intel.com/hardwaredesign/hpetspec_1.pdf

Can't you just look at the time class code? 您不能只看时间课程代码吗? You can easily view any code in the standard library. 您可以轻松查看标准库中的任何代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM