看板Programming
标 题Re: 请问:用C写一小闹钟程式!
发信站清华资讯(枫桥驿站) (Sun Aug 6 13:27:10 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!news.cis.nctu!new
※ 引述《[email protected] (chemistry)》之铭言:
> ※ 引述《[email protected] (ptsback)》之铭言:
> > 如果我是用一个loop一直去check系统时间
> > cpu根本就被我绑死了! 系统就会变得很没效率!
> > 而且变数要一读再读 因为内容不会自己改变!
> > 要如何做?
> 每计时一秒或数秒再check一次.
tClock:是用来存系统的时间;
tMorningCall:是叫床设定的时间;
tLen:叫床要叫多长的时间;
iFlag:整个程存是否完成;
RingTheBell():是呼叫闹铃的函数;
GetSystemTimeClock():是将系统时间设到tClock上;
iFlag=Flase;
while(!iFlag) {
if(tClock >= tMorningCall && tClock <= tMorningCall + tLen){
RingTheBell();
}
GetSystemTimeClock(&tClock);
}
问题:
cpu就卡死在while-loop内
--
※ Origin: 枫桥驿站<bbs.cs.nthu.edu.tw> ◆ From: 59-115-227-201.dynamic.hinet.net