📄 嵌入式365:提升您的价值.htm
字号:
to<BR> use binary semaphore instead of<BR> *
counting semaphore in this demonstration,<BR> for
comparision between the two<BR> *
semaphores.<BR> *<BR> * RETURNS: OK or
ERROR<BR> *<BR> */</P>
<P>STATUS countingSemDemo (<BR> char semType
/* counting semaphore
type<BR>
'c' or binary
semaphore<BR>
* type
'b'<BR>
*/)<BR>{<BR> switch
(semType)<BR>
{<BR> case
'c':<BR> case
'C':<BR> if
((semId =
semCCreate(SEM_Q_PRIORITY,<BR>
0)) ==
NULL)<BR>
{<BR>
perror
("semCCreate");<BR>
return
(ERROR);<BR>
}<BR>
break;</P>
<P> case
'b':<BR> case
'B':<BR>
if ((semId =
semBCreate(SEM_Q_PRIORITY,<BR>
SEM_EMPTY)) ==
NULL)<BR>
{<BR>
perror
("semBCreate");<BR>
return
(ERROR);<BR>
}<BR>
break;</P>
<P>
default:<BR>
printf ("Unknown semType-- must be 'c' or
'b'\n");<BR>
return (ERROR);<BR> }</P>
<P> if ((wdId = wdCreate()) ==
NULL)<BR>
{<BR> perror
("wdCreate");<BR> cleanUp
();<BR> return
(ERROR);<BR> }</P>
<P><BR> if ((syncTaskTid = taskSpawn ("tsyncTask",
TASK_PRIORITY,0,<BR>
TASK_STACK_SIZE,(FUNCPTR)
syncTask,<BR>
0,0,0,0,0,0,0,0,0,0)) ==
ERROR)<BR>
{<BR> perror
("taskSpawn");<BR> cleanUp();<BR> return
(ERROR);<BR> }</P>
<P> /* watchdog simulates hardware interrupts
*/<BR> if (wdStart (wdId,
TIME_BETWEEN_INTERRUPTS,<BR>
(FUNCPTR) syncISR,
numToGive)<BR>
== ERROR)<BR>
{<BR> perror
("wdStart");<BR> cleanUp
();<BR> return
(ERROR);<BR> }</P>
<P> /* arbitrary delay to
allow<BR> program to complete
before clean up */<BR> taskDelay (sysClkRateGet()
+<BR> ((TASK_WORK_TIME + 2) *
numToGive));<BR> <BR>
cleanUp();<BR> return (OK);<BR>}<BR> </P>
<P>/*************************************************<BR> *
syncTask - synchronizes with interrupts using<BR> *
counting or binarysemaphores.<BR> */</P>
<P>void syncTask (void)<BR>{<BR> int eventCount =
0;</P>
<P> FOREVER<BR> {<BR> if (semTake (semId,
WAIT_FOREVER) == ERROR)<BR> {<BR>
perror ("syncTask semTake");<BR>
return;<BR> }</P>
<P> /* Do "work" */<BR> taskDelay
(TASK_WORK_TIME);<BR> semShow (semId,1);</P>
<P> eventCount++;<BR> printf ("semaphore taken %d
times\n", eventCount);<BR> }</P>
<P>}</P>
<P>/************************************************<BR> *
syncISR - simulates a hardware device<BR> which
generates interrupts very<BR> * quickly and synchronizes
with<BR> syncTask using semaphores.<BR> */<BR>void
syncISR(int times)<BR>{<BR> semGive
(semId);<BR> times--;<BR> if
(times > 0)<BR> wdStart
(wdId,
TIME_BETWEEN_INTERRUPTS,<BR>
(FUNCPTR) syncISR, times);<BR>}</P>
<P>/********************************************<BR> * cleanUP
- deletes the syncTask, deletes the<BR> * semaphore and the
watchdog timer previously created<BR> * by
countingSemDemo./<BR>void cleanUp ()<BR>{<BR> if
(syncTaskTid)<BR>
taskDelete (syncTaskTid);<BR> if
(semId)<BR> semDelete
(semId);<BR> if
(wdId)<BR> wdDelete
(wdId);</P>
<P>}<BR>(注:休息15分钟,准备上机环境)<BR>二. 开卷部分</P>
<P>(一)上机参考解答题(45分钟内独立完成)<BR>1.怎样加入外部.o文件</P>
<P>2.如何获取函数wdStart的帮助</P>
<P>3.怎样生成bootrom</P>
<P>4.有如下的bootline 定义:<BR>"fei(0,0)host:vxWorks h=10.100.62.35
e=10.100.62.88 u=target pw=target"<BR>另外:VxWorks
image在d:\user_project\vxworks 如何配置ftp服务器</P>
<P>5.Attach的功能是什么,Auto Attach是什么含义,怎样设置Auto Attach?</P>
<P>6. 如何进入system调试模式</P>
<P>7.给出0x220102 Errno的意义</P>
<P>8.填图,内存布局</P>
<P>9.编程序,实现100次以20 ticks为周期的对函数 void test(void)的调用</P>
<P><BR>(二)上机实验题(30分钟)</P>
<P>1.创建一个有target server file system 的<BR>
Simulator和相应的支持target server file system 的WDB连接</P>
<P>2.载入<demo>\start\cobble.c到 Simulator,<BR>
理解并调试dataSemId与crunch任务的关系<BR> </P>
<P><STRONG><FONT
color=#ff0000>---------------------------------------------------------</FONT></STRONG></P>
<P>答案<BR>一.<BR>(一)<BR>1. C:\tornado\target\config\Pentium <BR> Config.h<BR>2. “tffs=0,0(0,0)host:/tffs0/vxworks
h=90.0.0.3 e=90.0.0.50
u=target”<BR>3. c:\tornado\target\proj\testProject\<BR> c:\tornado\target\config\ads8260<BR> c:\tornado\target\proj\testProject\default<BR>4. 配置冲突、缺少需要的模块或有模块参数没有设置<BR>5. sp
demo(10)<BR>6. browser<BR>7. 系统调试<BR>8. shared
memory、semaphore、message queue、pipe、signal</P>
<P>(二)<BR>1.A<BR>2. B,B,A,B,A<BR>3. D<BR>4. A,B,B<BR>5. B<BR>6. B,C,D,F<BR>7. A<BR>(三)<BR>1. 先用lkup
“buffer”查找字符串的准确名称,同时也可以得到字符串的地址;<BR> 然后用 d
字符串名称 或 d 字符串地址来观察字符串内容</P>
<P>2. tPhil1因为执行了semTake,tPhil3因为执行了taskDelay</P>
<P>3. 不同优先级是基于优先级的抢占调度,相同优先级是基于时间片的轮巡调度</P>
<P>4. taskSpawn ( “test_task”, 100, 0, (FUNCPTR) test,
2000, <BR> (int) pointer1, 200, 0, 0, 0, 0,
0, 0, 0, 0);</P>
<P>5. 以’c’为参数最后显示的eventCount比以’b’为参数最后显示的eventCount要 大,这是因为syncISR作为数据源发送的速度比syncTask处理数据的速度快,<BR>
binary semaphore 会被重置而不能正确反映数据的个数;<BR> counting
semaphore则不会被重置。</P>
<P>二.<BR>(一)<BR>1. 在工程管理窗口的builds页面,打开工程的default选项窗口,<BR>
在Macros中定义出EXTRA_MODULES为外部.o文件;<BR>
或在makefile中定义出EXTRA_MODULES。</P>
<P>2. 打开Tornado 帮助系统,选择Manuals Index ,<BR>
再选择Index页面,在输入框中键入wdStart,然后确认显示,<BR>
即可以打开该函数的html帮助。</P>
<P>3. 在build菜单中选择 build boot rom ,<BR>
然后在弹出窗口中选择BSP和Image 类型,然后确认;<BR>
或在相应BSP目录中直接键入make CPU=CPU类型 Image类型</P>
<P>4. 在ftp服务器的Security菜单中选择Users/Rights ,然后new user
,<BR> 输入用户名和密码后,再把Home directory
置为d:\user_project\vxworks</P>
<P>5. Attach 用于多任务调试时,进入某个任务调试;<BR> Auto
Attach在某个任务遇到断点时,会自动进入该任务调试;<BR> Auto Attach
在tools-options-debugger-“Auto attach to task”中设置。</P>
<P>6. 使用debug菜单的Attach功能,在弹出的窗口中选择system;<BR>
或进入GDB窗口,键入attach system命令。</P>
<P>7. 先在vxModNum.h中找出0x22的定义M_semLib,然后打开semLib.h,<BR>
查找0x102的定义,得出为S_semLib_INVALID_OPTION</P>
<P>8. RAM_LOW_ADRS RAM_HIGH_ADRS</P>
<P
align=left>9. 要点:<BR>(1) 用taskDelay的定时精度不够,只能算及格;<BR>(2) 用watch
dog时,一定要注意在watch dog的实现体内再启动该watch
dog;<BR>
控制100次调用可以使用全局变量,或包装test函数后传递函数参数。<BR></P></TD></TR>
<TR>
<TD vAlign=top width=580 height=50>
<HR color=#0066ff>
<P
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px; LINE-HEIGHT: 100%"
align=left>免责声明:</P>
<P
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px; LINE-HEIGHT: 100%"
align=left>1、本站文章中心绝大部分文章均来自互联网,只为嵌入式爱好者提供学习参考,提高我们嵌入式整体水平,版权属原作者所有,文中观点与本站无关,读者阅读前请自行判断。
<P
style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px; LINE-HEIGHT: 100%"
align=left>2、本站在转载文章时,努力搜索原作者与原始出处,并根据原始出处页面信息判断是否可以转载,尽管我们努力去做,但不免有漏网之鱼。另外一些优秀文章久经转载,原始出处与作者等信息丢失,如果侵犯了您的权益,请来信告之,本站立即加上相关信息或应要求即刻删除,并表示最大歉意,同时替广大嵌入式学习者向您表示十分敬意与感谢。
</P></TD></TR>
<TR>
<TD vAlign=top width=580 height=18>
<P align=right>【<A
href="http://www.emb365.com/print.asp?flag=article&id=503">打印</A>】</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV><!--以上是通栏2-->
<SCRIPT language=javascript src="嵌入式365:提升您的价值.files/floating.js"></SCRIPT>
<SCRIPT language=javascript>//floatads('','ad/images/zp.gif)</SCRIPT>
<TABLE cellSpacing=0 cellPadding=0 width=760 align=center bgColor=#ffffff
border=0>
<TBODY>
<TR>
<TD background=嵌入式365:提升您的价值.files/bg_td.gif>
<DIV align=center>
<P align=center><A href="http://www.emb365.com/index.asp"><FONT
color=#ffffff>网站首页</FONT></A> <FONT color=#ffffff>|</FONT> <FONT
color=#ff0000><A href="http://www.emb365.com/law.asp"
target=_blank></A></FONT><A href="http://www.emb365.com/law.asp"
target=_blank><FONT color=#ffffff>法律声明</FONT></A> <FONT
color=#ffffff>|</FONT> <FONT color=#ff0000><A
href="http://www.emb365.com/buy.asp" target=_blank></A></FONT><A
href="http://www.emb365.com/buy.asp" target=_blank><FONT
color=#ffffff>购买方式</FONT></A> <FONT color=#ffffff>|</FONT> <FONT
color=#ff0000><A href="http://www.emb365.com/link.asp"
target=_blank></A></FONT><A href="http://www.emb365.com/link.asp"
target=_blank><FONT color=#ffffff>欢迎链接</FONT></A> </P></DIV></TD></TR>
<TR>
<TD height=21>
<P align=center>Copyright © 2005-2008 Emb365.com All rights reserved.
</P></TD></TR></TBODY></TABLE></CENTER></FORM></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -