Title: Linux????
1Linux????
2????
- Linux?????????????
- ??????????
- ????time(), ftime()??gettimeofday()
- ?????
- settimer(), alarm()
- ?????????????????????????????
3????
- ???????
- Linux???????????
- ???????????
4???
- 80x86?????,???????????????
- ????Real time clock,RTC
- ??????Time stamp counter,TSC
- ????????Programmable interval timer, PIT
- SMP??????APIC???
???? ????
?????????
5????RTC
- ??????PC???????
- ???CPU???????
- ????????????
- ????PC??,??????
- ?CMOS RAM??????????
- ??Motorala 146818
- ??IRQ8?????????,???2HZ8192??
- ????????????
6- Linux???RTC???????
- ????????/dev/rtc
- ????????????
- ????0x70?0x71??????RTC
- ???????????????????
7??????TSC
- ??80x86??????
- ?pentium???
- 64?????
- rdtsc?????????
- ???????,???????????1
- ??,????400MHz?????,TSC?2.5ns1
8- ????????????????,TSC??????????
- ??,Linux??????????????????
- calibrate_tsc
- ???????????????(?50ms)????TSC?????????
- ???????????????
- ????????????????,?????????????,???????
9????????PIT
- ???????,??????????
- ???8254 CMOS??
- ??I/O??0x400x43
- Linux?PIT???
- 100Hz
- ??IRQ0??????
- ?10ms????????,???tick
10- Linux???????,????????????CPU???
- ??calibrate_tsc()
11Tick???
- ?
- ??????
- ???????CPU????,???????????
- ??????????,???????????????
- Tick????????,??
- ???????Alpha?Intel?IA-64??1ms????tick(??1024?????)
- Rawhide Alpha???????(1200tick/?)
12??????????,???tick???
8254??????????
?8254??,??HZ?????
13??,??10ms??????tick
14Linux???????
- ????????,????????IRQ0????????,??
- ???????????,?
- ?????????????
15????????
- Linux?????time_init()??IRQ0?????????
?irq0??irq_desc???? ???????
16???TSC,?????????????, ????????????
??????do_timer?????
17do_timer
????,??????? ???????? 32? ?497????(???0)
????????????? ??
??????
??tq_timer??,?????????????
18update_process_times
??????? CPU????? ??
????? ???????
19TIMER_BH????
- ?????????????????,?????????
?????????,?????????
????????
20???????
???1970?1?1???0? ?????????
???????????? ????0999999
21- ??????,time_init()????????
- ??get_cmos_time()
??coms?? ????,Linux????RTC,????????xtime
22??xtime
23????
- ??????????,?????????????????
- ??????????????????????
- ?????????????????????????
- ????????????????????
24- Linux????????
- ?????
- ????
- ?????
- ?????????
- ???????????????,??????????????????????,?????,????
????
25?????
- ??????????????,????????????????
- ????
- ????512????????????
????
???????
????????????
26????????????
- ??????timer_list??
- ??init_timer???,???????????????
- ??????
- ??add_timer?????????
- ???????????,?????????,??????????
27????????
- ?????????????,????????,??????????
- Linux??expires??,?????????
2864, 64?????,???????????? ????? index?????????????
??????
(256),256?????,?????? ????????????? Index????????
?????
????????????? ???????????
??220-1???????? ?214?????????1??? ?64?
??226-1???????? ?220?????????1??? ?64?
??232-1???????? ?226?????????1??? ?64?
??214-1???????? ?256?????????1??? ?64?
29run_timer_list
- ????timer_bh()??run_timer_list()??????????,??
- ???????
- ????
- ??run_timer_list()
30????????
- ??schedule_timeout()????????(??????)
- ??schedule_timeout()??????????
31????????????
- time()
- ???1970?1?1???0??????
- ftime()
- ???1970?1?1???0????????????????
- ?????timeb
- gettimeofday()
- ???1970?1?1???0??????
- ???sys_gettimeofday()
32- settimer()
- ?????
- ???????????(??0,?????)
- alarm()
- ??SIGALARM??
33????????(??)
- date??????????
- ??time????
- ??ctime??????