问题 问答题


阅读以下关于嵌入式操作系统软件编码优化的技术说明,根据要求回答问题1至问题5。
【说明】
由于嵌入式系统对实时性的要求较高,因此一般要求对代码的性能进行优化,使代码的执行速度越快越好。图6-22给出了两个算术运算的程序段(a)、(b)。

【问题4】
在嵌入式系统中,由于软/硬件资源有限,且系统对实时性和可靠性要求较高,因此在进行嵌入式软件开发时,要注意对执行时间、存储空间和开发/维护时间这三种资源的使用进行优化。请具体说明在编写代码时,需要做到哪几点编码准则

答案

参考答案:

解析:在编写代码时,需要做到以下6点编码准则: ①保持函数短小,以提高代码的可靠性和可维护性; ②封装代码,尽量消除代码之间的依赖性,提高对象的内聚性, ③消除冗余代码,避免出现类似一个变量初始化或设置一个变量后却从不使用的现象; ④减少实时代码,最好将对执行时间要求严格的代码转移到一个单独的任务或程序段中; ⑤编写优雅流畅的代码,例如使用Tab键为每个条件体或循环体进行有层次地缩进;将大括号放置在关键词下方的同列处等; ⑥遵守代码编写标准并借助自动检查工具,以捕捉通过传统测试检查不到的各种问题 这是一道要求读者掌握嵌入式系统软件平台选择的简答题。本题所涉及的知识点如下: 在进行嵌入式软件开发时,要注意对执行时间、存储空间和开发/维护时间这三种资源的使用进行优化。也就是说,代码的执行速度越快越好、系统占用的存储空间越小越好,软件开发和维护时间越少越好。具体来说,在编写代码时,需要做到以下六点编码准则: ①保持函数短小,以提高代码的可靠性和可维护性。 ②封装代码,尽量消除代码之间的依赖性,提高对象的内聚性。 ③消除冗余代码,避免出现类似一个变量初始化或设置一个变量后却从不使用的现象。 ④减少实时代码,最好将对执行时间要求严格的代码转移到一个单独的任务或程序段中。 ⑤编写优雅流畅的代码,例如使用Tab键为每个条件体或循环体进行有层次的缩进;将大括号放置在关键词下方的同列处;不要把小括号和关键词(if、while等)紧贴在一起,要用空格隔开它们;不要把小括号和函数名紧贴在一起;等等。 ⑥遵守代码编写标准并借助自动检查工具,以捕捉通过传统测试检查不到的各种问题。 另外,在嵌入式软件开发过程中,遵守编程规范,养成良好的编程习惯,将直接影响到所编写的代码的质量。编程规范主要涉及命名规则、编码格式及注释的书写这三方面的内容。

阅读理解

Talking to Teachers—Teachers are just people.Behind that desk, is a living, breathing human being.And just like any human being, they will probably be friendly to people who talk nicely to them.Teachers also seem to get along better with children who take schoolwork seriously and are prepared for class.And, just like any other human being, teachers like to be appreciated.The next time your teacher helps you solve a math problem or figure out a science project, say thank you with a smile.

Talking to Parents—Parents can be very supportive if their children ask for help.If you think there’s something your parents can do to help you socialize more or feel more comfortable around people, then ask them.Very often, parents want very much to help, but really don’t know what to do.Pick a quiet time of the day and ask to talk.Tell them how you feel.Maybe they had the same trouble when they were kids.

Talking to Stranger —This is always a tough one.How do you deal with a neighbor, the mail carrier, or someone walking down your street—situations that often seem to cause arguments between kids and parents.The answer to these questions will vary(变化) from kid to kid, from parent to parent because all cultures are different.Some folks live in small towns where a hello to everyone is “what’s done”.Then there are kids who live in the city who may have been taught not to speak to anyone they don’t know.If you’re having trouble with this and always feel awkward in these kinds of situations, you might want to talk to your parents or a teacher about it.Where do they think you should draw the line(线)? When is silence rude and when is it wise?

小题1:From the first paragraph we may learn that teachers dislike____ .

A.being talked to nicely

B.their students to be serious with the schoolwork

C.the students’ appreciation

D.the students who are not ready for classes小题2:If your parents are not supportive and you are not getting along quite well with your parents, who or what is to blame(该受责备)?

A.Your parents.        B Yourself.        

C.Lack of communication.   D .Your teachers.

小题3:The underlined word in the third paragraph is close in meaning to____.

A.fond

B.puzzled(困惑的)

C.frightened

D.willing小题4:The passage doesn’t say but it implies that in daily communication____.

A.arguments often happen between kids and parents

B.we should talk to the neighbors and other people according to different cultures

C.city people and country people greet in the same way

D.we should fit(使…符合) our words with proper situations

选择题