<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[嵌入式软件开发笔试题目]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 04 Dec 2008 07:42:20 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	Embedded Software Design Engineer<br/><br/>1 读程序段，回答问题<br/>int main(int argc,char *argv[])<br/>{<br/>int c=9,d=0;<br/>c=c++%5;<br/>d=c;<br/>printf(&quot;d=%d&#92;n&quot;,d);<br/>return 0;<br/>}<br/>a) 写出程序输出<br/>b) 在一个可移植的系统中这种表达式是否存在风险？why?<br/><br/>#include &quot;stdio.h&quot;<br/>int a=0;<br/>int b;<br/>static char c;<br/>int main(int argc,char *argv[])<br/>{<br/>char d=4;<br/>static short e;<br/><br/>a++;<br/>b=100;<br/>c=(char)++a;<br/>e=(++d)++;<br/>printf(&quot;a=%d, b=%d, c=%d, d= %d, e=%d&quot;,a,b,c,d,e);<br/>return 0;<br/>}<br/>a) 写出程序输出<br/>b) 编译器如果安排各个变量(a,b,c,d)在内存中的布局(eg. stack,heap,data section,bss section),最好用图形方式描述。<br/><br/>2 中断是嵌入式系统中重要的组成部分，这导致了许多编译开发商提供一种扩展：让标准C支持中断，产生了一个新的关键字__interrupt。下面的代码就使用了__interrupt关键字去定义了一个中断服务子程序(ISR),请评论以下这段代码。<br/>__interrupt double compute_area(double radius)<br/>{<br/>double area = PI * radius *radius;<br/>printf(&quot;nArea = %f&quot;, area);<br/>return area;<br/>}<br/><br/>3 C/C++基础知识问题<br/>a) 关键字volatile在编译时有什么含义?并给出三个不同使用场景的例子(可以伪代码或者文字描述)。<br/>b) C语言中static关键字的具体作用有哪些 ?<br/>c) 请问下面三种变量声明有何区别?请给出具体含义<br/>int const *p;<br/>int* const p;<br/>int const* const p;<br/><br/>4 嵌入式系统相关问题<br/>a) 对于整形变量A=0x12345678,请画出在little endian及big endian的方式下在内存中是如何存储的。<br/>b) 在ARM系统中，函数调用的时候，参数是通过哪种方式传递的?<br/>c) 中断(interrupt,如键盘中断)与异常(exception,如除零异常)有何区别?<br/><br/>5 设周期性任务P1,P2,P3的周期为T1,T2,T3分别为100，150，400；执行时间分别为20，40，100。请设计一种调度算法进行任务调度，满足任务执行周期及任务周期。<br/><br/>6 优先级反转问题在嵌入式系统中是一中严重的问题，必须给与足够重视。<br/>a) 首先请解释优先级反转问题<br/>b) 很多RTOS提供优先级继承策略(Priority inheritance)和优先级天花板策略(Priority ceilings)用来解决优先级反转问题，请讨论这两种策略。<br/> <br/> <br/>参考答案:<br/>1 5<br/>&nbsp;&nbsp;存在风险，因为c=c++%5;这个表达式对c有两次修改，行为未定义，c的值不确定<br/>&nbsp;&nbsp;int a=0; // data section<br/>&nbsp;&nbsp;int b;&nbsp;&nbsp; // data section<br/>&nbsp;&nbsp;static char c; // BSS<br/>&nbsp;&nbsp;int main(int argc,char *argv[])<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;char d=4;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // stack<br/>&nbsp;&nbsp;&nbsp;&nbsp;static short e;&nbsp;&nbsp; // BSS<br/>&nbsp;&nbsp;&nbsp;&nbsp;a++;<br/>&nbsp;&nbsp;&nbsp;&nbsp;b=100;<br/>&nbsp;&nbsp;&nbsp;&nbsp;c=(char)++a;<br/>&nbsp;&nbsp;&nbsp;&nbsp;e=(++d)++;<br/>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;a=%d, b=%d, c=%d, d= %d, e=%d&quot;,a,b,c,d,e);<br/>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;a=2,b=100,c=2,d=6,e=5<br/> <br/>2 a)ISR不能返回一个值；<br/>&nbsp;&nbsp;b)ISR不能传递参数；<br/>&nbsp;&nbsp;c)浮点一般都是不可重入的；<br/>&nbsp;&nbsp;d)printf函数有重入和性能上的问题。<br/> <br/>3 a) 用volatile关键字定义变量，相当于告诉编译器，这个变量的值会随时发生变化，每次使用时都需要去内存里<br/>重新读取它的值，并不要随意针对它作优化。<br/>建议使用volatile变量的场所：<br/>(1) 并行设备的硬件寄存器<br/>(2) 一个中断服务子程序中会访问到的非自动变量（全局变量）<br/>(3) 多线程应用中被几个任务共享的变量<br/>&nbsp;&nbsp;b) 在函数体，一个被声明为静态的变量在这一函数被调用过程中维持其值不变。<br/>&nbsp;&nbsp;&nbsp;&nbsp; 在模块内（但在函数体外），一个被声明为静态的变量可以被模块内所用函数访问，但不能被模块外其它函数<br/>访问。它是一个本地的全局变量。<br/>&nbsp;&nbsp;&nbsp;&nbsp; 在模块内，一个被声明为静态的函数只可被这一模块内的其它函数调用。那就是，这个函数被限制在声明它的<br/>模块的本地范围内使用。<br/>&nbsp;&nbsp;&nbsp;&nbsp; static全局变量与普通的全局变量有什么区别：static全局变量只初使化一次，防止在其他文件单元中被引用;<br/>&nbsp;&nbsp;&nbsp;&nbsp; static局部变量和普通局部变量有什么区别：static局部变量只被初始化一次，下一次依据上一次结果值；<br/>&nbsp;&nbsp;&nbsp;&nbsp; static函数与普通函数有什么区别：static函数在内存中只有一份，普通函数在每个被调用中维持一份拷贝<br/>&nbsp;&nbsp;c) 一个指向常整型数的指针<br/>&nbsp;&nbsp;&nbsp;&nbsp; 一个指向整型数的常指针<br/>&nbsp;&nbsp;&nbsp;&nbsp; 一个指向常整型数的常指针<br/>4<br/> <br/>a) 0x12345678<br/> little endian&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;big endian 刚好反过来<br/>&nbsp;&nbsp;高地址--〉 0x12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;低地址--〉 0x12<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x34&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x34<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x56&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x56<br/>&nbsp;&nbsp;低地址--〉 0x78&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;高地址--〉 0x78<br/>b)参数&lt;=4时候，通过R0~R3传递，&gt;4的通过压栈方式传递<br/>c)&nbsp;&nbsp; 异常：在产生时必须考虑与处理器的时钟同步，实践上，异常也称为同步中断。在处理器执行到由于编程失误而导致的错误指令时，或者在执行期间出现特殊情况(如缺页)，必须靠内核处理的时候，处理器就会产生一个异常。<br/>所谓中断应该是指外部硬件产生的一个电信号，从cpu的中断引脚进入，打断cpu当前的运行；<br/>所谓异常，是指软件运行中发生了一些必须作出处理的事件，cpu自动产生一个陷入来打断当前运行，转入异常处理流程。<br/>异步与同步的区别`<br/>5<br/> <br/>6 高优先级任务需要等待低优先级任务释放资源，而低优先级任务又正在等待中等优先级任务的现象叫做优先级反转<br/>&nbsp;&nbsp;优先级继承策略(Priority inheritance):继承现有被阻塞任务的最高优先级作为其优先级，任务退出临界区，恢<br/>复初始优先级。<br/>&nbsp;&nbsp;优先级天花板策略(Priority ceilings):控制访问临界资源的信号量的优先级天花板。<br/>&nbsp;&nbsp;优先级继承策略对任务执行流程的影响相对教小，因为只有当高优先级任务申请已被低优先级任务占有的临界资源<br/>这一事实发生时，才抬升低优先级任务的优先级。
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 嵌入式软件开发笔试题目]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>