📄 初学vxworks,请高手对vxworks下的一个例子程序winddemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.htm
字号:
<BR>* <BR>* taskHighPri - high priority task <BR>* <BR>* This tasks exercises
various kernel functions. It will block if the <BR>* resource is not available
and relingish(放弃) the CPU to the next ready task. <BR>* <BR>*/ <BR><BR>LOCAL
void taskHighPri (int iteration /* number of iterations through loop */) <BR>{
<BR>int ix; /* loop counter */ <BR>MY_MSG msg; /* message to send */
<BR>MY_MSG newMsg; /* message to receive */ <BR><BR>for (ix = 0; ix <
iteration; ix++) <BR>{ <BR><BR>/* take and give a semaphore - no context
switch involved */ <BR><BR>semGive (semId); <BR>semTake (semId, 100); /*
semTake with timeout */ <BR><BR>/* <BR>* take semaphore - context switch will
occur since semaphore <BR>* is unavailable <BR>*/ <BR><BR>semTake (semId,
WAIT_FOREVER); /* semaphore not available */ <BR><BR>taskSuspend (0); /*
suspend itself */ <BR><BR>/* build message and send it */
<BR><BR>msg.childLoopCount = ix; <BR>msg.buffer = TASK_HIGHPRI_TEXT;
<BR><BR>msgQSend (msgQId, (char *) &msg, MSG_SIZE, 0, MSG_PRI_NORMAL);
<BR><BR>/* <BR>* read message that this task just sent and print it - no
context <BR>* switch will occur since there is a message already in the queue
<BR>*/ <BR><BR>msgQReceive (msgQId, (char *) &newMsg, MSG_SIZE, NO_WAIT);
<BR><BR>#ifdef STATUS_INFO <BR>printf ("%s\n Number of iterations is %d\n",
<BR>newMsg.buffer, newMsg.childLoopCount); <BR>#endif /* STATUS_INFO */
<BR><BR>/* <BR>* block on message queue waiting for message from low priority
task <BR>* context switch will occur since there is no message in the queue
<BR>* when message is received, print it <BR>*/ <BR><BR>msgQReceive (msgQId,
(char *) &newMsg, MSG_SIZE, WAIT_FOREVER); <BR><BR>#ifdef STATUS_INFO
<BR>printf ("%s\n Number of iterations by this task is: %d\n",
<BR>newMsg.buffer, newMsg.childLoopCount); <BR>#endif /* STATUS_INFO */
<BR><BR>/* test watchdog timer */ <BR><BR>wdStart (wdId, DELAY, (FUNCPTR)
tickGet, 1); <BR><BR>wdCancel (wdId); <BR>} <BR>}
<BR><BR>/*******************************************************************************
<BR>* <BR>* taskLowPri - low priority task <BR>* <BR>* This task runs at a
lower priority and is designed to make available <BR>* the resouces that the
high priority task is waiting for and subsequently(随后) <BR>* unblock the high
priority task. <BR>* <BR><BR>*/ <BR><BR>LOCAL void taskLowPri (int iteration
/* number of times through loop */) <BR>{ <BR>int ix; /* loop counter */
<BR>MY_MSG msg; /* message to send */ <BR><BR>for (ix = 0; ix < iteration;
ix++) <BR>{ <BR>semGive (semId); /* unblock tHighPri */ <BR><BR>taskResume
(highPriId); /* unblock tHighPri */ <BR><BR>/* build message and send it */
<BR><BR>msg.childLoopCount = ix; <BR>msg.buffer = TASK_LOWPRI_TEXT;
<BR>msgQSend (msgQId, (char *) &msg, MSG_SIZE, 0, MSG_PRI_NORMAL);
<BR>taskDelay (60); <BR>} <BR><BR>taskResume (windDemoId); /* wake up the
windDemo task */ <BR>} <BR></DIV></LI>
<LI>
<P class=descr_re>No.1 | | 358 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#1" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>我的理解如下:
<BR>一。建立主任务windDemo,在该主任务中分别建立高优先级、低优先级2个任务,任务创建后立
<BR>即运行,分别建立消息队列和二进制信号量(该信号量用于2个任务的互斥操作),然后主任务 <BR>挂起,等待低优先级的任务解除阻塞。
<BR>二。在高优先级taskHighPri的任务中,通过semTake (semId, 100);操作,实现对信号量控制
<BR>100个时间片的控制权,此时信号量的状态变为不可用,此时发生任务切换吗?在低优先级的任务中没有semTake操作,如何获得信号量?这个我不理解?
<BR>三。还有就算发送消息和接收消息的时候,发生任务切换吗?看门狗在本程序中起什么作用? <BR>请各位高手解答一下我的疑问,请帮忙,叩拜!
<BR></DIV></LI>
<LI>
<P class=descr_re>No.2 | | 10 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#2" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>顶,高手出来帮忙啊!</DIV></LI>
<LI>
<P class=descr_re>No.3 | | 269 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#3" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>一:此中的信号量应该是做同步用,而不是互斥; <BR>二:semTake(semId,
100)时,因为刚刚有个semGive动作,这taskHighPri会取得此信号量,并不会发送任务切换,会发生任务切换的是semTake (semId,
WAIT_FOREVER)。在vxworks中,此semId是全局可见的,低优先级任务可以不需要semTake而直接semGive;
<BR>三:发送消息本身不是阻塞动作,但因为唤醒的是高优先级任务,所以高优先级任务会抢占CPU <BR>看门狗好象没看出什么意义
<BR><BR></DIV></LI>
<LI>
<P class=descr_re>No.4 | | 65 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#4" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV
class=content_re>四少爷,你好,首先感谢你对本问题的关注,我想和你讨论一下,可以吗?我的MSN是:terry_jwf@hotmail.com,谢谢!</DIV></LI>
<LI>
<P class=descr_re>No.5 | | 31 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#5" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>我的msn:city_lovelace@hotmail.com</DIV></LI>
<LI>
<P class=descr_re>No.6 | | 26 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#6" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>老板让做vxwork tron 一点都不懂,来学一下</DIV></LI>
<LI>
<P class=descr_re>No.7 | | 587 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#7" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>刚学vxworks第三天,今天刚好看到了这个例子程序. <BR>根据注释,我的理解是:
<BR>1.windDemo spawn 出两个task: tHighPri, tLowPri .然后windDemo挂起. <BR>2.tHighPri
优先执行,在semTake(semId, WAIT_FOREVER)处被阻塞,等待semId <BR>3.tLowPri
然后执行,用semGive(semId)释放semId
<BR>4.这时,tHighPri因获得senId而进入ready状态,接着调用taskSuspend()将自己挂起
<BR>5.因此tLowPri得到调度,用taskResume(tHighPri)重新使tHighPri得到调度执行
<BR>6.tHighPri这时向消息队列msgQId发送一个消息,接着又从msgQId接收一个消息,然后第二次从msgQId接收一个消息,这次msgQId中没有消息,tHighPri被阻塞
<BR>7. tLowPri此时被调度,向消息队列发送一条消息,tHighPri被unpend <BR>8.
tHighPri又重新被调度,启动watchdog(wdog在这里不起作用,只是出来客串一下)
<BR><BR>大概就是这样,如果有什麽不对的地方请大家多指教! <BR></DIV></LI>
<LI>
<P class=descr_re>No.8 | | 24 bytes | <A
href="http://www.devdb.cn/cgi-bin/print/4135281.html#8" target=_blank><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/print_2.gif"
align=absMiddle border=0></A> | <A
href="http://www.devdb.cn/dev-archive/1281/4135281-908.html#top"><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/top_1.gif"
align=absMiddle border=0></A></P>
<DIV class=content_re>顶!我认为alpha说的很好!条理很清淅!支持!</DIV></LI></UL></DIV>
<DIV class=answer-area><A name=answer></A>
<P class=answer-title>Re:
初学VxWorks,请高手对vxworks下的一个例子程序windDemo.c做详细分析,附源程序,主要是我不理解调用过程.</P>
<FORM name=answerform action=/app/answer/ method=post><TEXTAREA class=answer-content onkeydown=checkLength(this); onkeyup=checkLength(this); name=StrContent></TEXTAREA><BR><SPAN
id=displayarea>max <B>4000</B> letters.</SPAN><BR>Your nickname that display:
<INPUT class=answer-nickname maxLength=50 name=nickname> <BR>In order to stop
the spam: <B>1 + 1</B> = <INPUT class=answer-spamchk maxLength=2 size=12
name=spamChk> <INPUT type=hidden value=4135281 name=id> <INPUT type=hidden
value=5151779 name=Sid> <INPUT type=hidden
value=/dev-archive/1281/4135281-908.html name=nextlink> <INPUT type=submit value=Submit> </FORM></DIV></DIV><!--Center side End--><!--Right side start-->
<DIV class=index_box_right style="MARGIN-BOTTOM: 10px"><!--plus--><!--plus-->
<DIV class=index_right_titlebox>
<DIV class=index_left_title>QUESTION ON "VxWorks开发"</DIV>
<DIV class=index_left_more align=right><IMG
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/news_index_moreb.gif"
border=0></DIV></DIV>
<UL class=index_faq>
<LI><A
href="http://www.devdb.cn/dev-archive/1219/4129219-908.html">[求助]有没有人有vxworks下的dosfs的源码?</A>
<LI><A
href="http://www.devdb.cn/dev-archive/1653/4127653-getchar.html">【请问】关于getchar()</A>
<LI><A
href="http://www.devdb.cn/dev-archive/1182/4127182-vxworksvxsim.html">VxWorks中VxSim问题</A>
<LI><A
href="http://www.devdb.cn/dev-archive/764/4126764-908.html">用Tornado做MPC嵌入式实验的时候,编译已经通过,但是download时出错</A>
<LI><A href="http://www.devdb.cn/dev-archive/616/4126616-908.html">转载: vxsim
无法启动的弟兄们注意了</A>
<LI><A
href="http://www.devdb.cn/dev-archive/709/4124709-tl1cl1.html">什么是TL1,CL1协议啊?</A>
<LI><A
href="http://www.devdb.cn/dev-archive/673/4122673-developer%20question.html">系统服务不能正常启动,这是怎么回事?</A>
<LI><A
href="http://www.devdb.cn/dev-archive/1564/4117564-908.html">100分---[windml]windriver自带的ugldemo.c文件download的时候出unresolved
symbols encountered</A>
<LI><A
href="http://www.devdb.cn/dev-archive/960/4112960-908.html">应用程序调用end驱动,收不到包,为什么</A>
<LI><A
href="http://www.devdb.cn/dev-archive/620/4104620-908.html">在Tornado集成仿真器下调试应用程序时如何输入信息?急!</A>
<DIV class=hr-class></DIV>
<LI><A href="http://www.devdb.cn/dev-archive/1818/4133818-908.html">请问Tornado
2.2/VxWorks 5.5下面绘制界面是用哪个库?立即放分</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/342/4124342-908.html">用Tornado调试环境build没问题,但是下载到PPC850时出错,提示asm出错</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1182/4121182-908.html">有在vmware下安装vxworks成功的吗,求助</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1986/4113986-bsp.html">勾建BSP中碰到得一个有趣问题</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1257/4109257-vxworks.html">vxworks不能上手</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/934/4102934-908.html">请问如何在vxworks下实现双向链表的操作?</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1366/4099366-908.html">loadModule怎么不能加载模块符号表,在线等!</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1510/4093510-vxworks.html">vxworks核心问题</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1882/4091882-vxworks.html">vxworks下边这个函数怎么执行啊</A></L>
<LI><A
href="http://www.devdb.cn/dev-archive/1021/4089021-908.html">vxworks中,函数不声明就可以在另外一个文件中用?这似乎不符合c语言标准啊?</A></L>
</LI></UL><BR><!--plus--><!--plus--></DIV><!--Right side End--></DIV>
<DIV class=index_bottom></DIV>
<DIV class=index_foot>
<DIV class=index_foot_domain align=center>DEVDB.CN</DIV>
<UL>
<LI class=index_foot_url><A href="http://www.devdb.cn/">Home</A> - <A
href="http://www.devdb.cn/sitemap.xml" target=_blank>Map.XML</A> - <A
href="http://www.devdb.cn/rss/908.xml" target=_blank>Rss.Xml</A>
<LI>Copyright 2001-2009 by DEVDB.CN Information Technology Co.,Ltd All rights
reserved
<LI>0.391
<SCRIPT
src="初学VxWorks,请高手对vxworks下的一个例子程序windDemo_c做详细分析,附源程序,主要是我不理解调用过程_ - 硬件-嵌入开发.files/s.htm"
type=text/javascript></SCRIPT>
</LI></UL></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -