中断处理实习报告.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
中断处理实习报告

中断处理 实习报告 一、实习内容 模拟中断事件的处理。 二、实习目的 现代计算机系统的硬件部分都设有中断机构,它是实现多道程序设计的基础。中断机构能发现中断事件,且当发现中断事件后迫使正在处理器上执行的进程暂时停止执行,而让操作系统的中断处理程序占有处理器去处理出现的中断事件。对不同的中断事件,由于它们的性质不同,所以操作系统应采用不同的处理。通过实习了解中断及中断处理程序的作用。本实习模拟“时钟中断事件”的处理,对其它中断事件的模拟处理,可根据各中断事件的性质确定处理原则,制定算法,然后依照本实习,自行设计。 三、实习题目 模拟时钟中断的产生及设计一个对时钟中断事件进行处理的模拟程序。 四、结构及说明 本程序模拟时钟中断,在每次的执行周期后进行中断检测。程序中具体表现在周期为一秒的中断检测中,如果检测到已经到达预订时间,则进行显示提示。 五、源代码 // interrupt.cpp : Defines the entry point for the console application. #include stdafx.h #include iostream #include time.h using namespace std; //-------------------------------- time_t timep; int i; //-------------------------------- char name[3]; time_t target_time[3]; int pointer=-1; //-------------------------------- int set_timer(); int set_alarm(); int set_countdown_timer(); int display(int); //-------------------------------- long current_time,last_time; int main(int argc, char* argv[]) { time(timep); cout系统开机时间:ctime(timep)endl; set_timer(); last_time = time(NULL); while (1) { current_time = time(timep); if (current_time - last_time = 1) { coutctime(timep); for (i=0;i3;i++) { if (target_time[i] == current_time) { display(i); } } } last_time = current_time; } printf(Hello GHouan!\n); return 0; } int set_timer() { int k; int type; for (k=0;k3;k++) { printf(No%d:输入定时器类别(闹钟 0/倒计时 1),k+1); scanf(%d,type); if (0 == type) { set_alarm(); } if (1 == type) { set_countdown_timer(); } } return 0; } int set_alarm() { struct tm temp_tm; int yy,mn,dd,hh,mm,ss; pointer++; printf(闹钟名称:); cinname[pointer]; printf(闹响时间:(年,月,日,时,分,秒)); cinyymnddhhmmss; temp_tm.tm_year = yy - 1900; temp_tm.tm_mon = mn - 1; temp_tm.tm_mday = dd; temp_tm.tm_hour = hh; temp_tm.tm_min = mm; temp_tm.tm_sec = ss; temp_tm.tm_isdst = 0; target_time[pointer] = mktime(temp_tm); return 0; } int set_countdown_timer() { time_t timec; int hh,mm,ss; pointer++; printf(倒计时名称:); cinname[pointer]; printf(倒计时时间:(时,分,秒)); c

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档