看板Programming
标 题Re: 请问:用C写一小闹钟程式!
发信站中央大学松涛风情资讯站 (Sun Aug 6 19:00:59 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!news.cis.nctu!net
> ==>发信人: [email protected] (ptsback), 信区: programming
> ※ 引述《[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内
======
资讯本科系怎麽会不知道:
1. Timer Hardware
2. Timer Interrupt Service Routing
3. System Delay Wait & Signal
--
◎ Origin: 中央松涛站□bbs.csie.ncu.edu.tw From: 140.115.6.234
1F:推 meltice:我不知道耶 教授没有敎203.204.133.140 08/06 23:58
2F:推 rightson:楼上的不知道大部分的东西教授都没教吗? 140.113.90.104 12/16 22:30