?? 初學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 + -