⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 嵌入式系统vxworks介绍及编程.htm

📁 Vxwork的学习资料,对初学者有帮助 有关于BSP的说明介绍
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                <P align=left><B><A name=91152></A><FONT class=sans 
                face="Helvetica, sans-serif" size=-1>Semaphore Call</FONT></B> 
                </P></DIV></TH>
              <TH>
                <DIV class=CellHeadingC align=center>
                <P align=left><A name=91154></A><B><FONT class=sans 
                face="Helvetica, sans-serif" size=-1>Count after Call</FONT></B> 
                </P></DIV></TH>
              <TH>
                <DIV class=CellHeading>
                <P align=left><B><A name=91156></A><FONT class=sans 
                face="Helvetica, sans-serif" size=-1>Resulting 
                Behavior</FONT></B> </P></DIV></TH></TR>
            <TR>
              <TD colSpan=3>
                <HR class=tablerule2>
              </TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91158></A><B class=routine><I 
                class=routine>semCCreate</I></B><B>(&nbsp;)</B> &nbsp; 
              </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91160></A>3 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91162></A>Semaphore initialized with 
                initial count of 3.&nbsp; </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91164></A><B class=routine><I 
                class=routine>semTake</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91166></A>2 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91168></A>Semaphore taken.&nbsp; 
              </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91170></A><B class=routine><I 
                class=routine>semTake</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91172></A>1 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91174></A>Semaphore taken.&nbsp; 
              </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91176></A><B class=routine><I 
                class=routine>semTake</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91178></A>0 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91180></A>Semaphore taken.&nbsp; 
              </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91182></A><B class=routine><I 
                class=routine>semTake</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91184></A>0 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91186></A>Task blocks waiting for 
                semaphore to be available.&nbsp; </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91188></A><B class=routine><I 
                class=routine>semGive</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91190></A>0 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91192></A>Task waiting is given 
                semaphore.&nbsp; </P></DIV></TD></TR>
            <TR vAlign=top>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91194></A><B class=routine><I 
                class=routine>semGive</I></B><B>(&nbsp;)</B>&nbsp; </P></DIV></TD>
              <TD>
                <DIV class=CellBodyC align=center>
                <P align=left><A name=91196></A>1 </P></DIV></TD>
              <TD>
                <DIV class=CellBody>
                <P align=left><A name=91198></A>No task waiting for semaphore; 
                count incremented.&nbsp; </P></DIV></TD></TR>
            <TR>
              <TD colSpan=3>
                <HR class=tablerule>
              </TD></TR>
            <TR vAlign=center>
              <TD colSpan=3>
                <P align=left></P></TD></TR></TBODY></TABLE>
          <P style="LINE-HEIGHT: 150%"> </P></BLOCKQUOTE></BLOCKQUOTE>
      <P style="LINE-HEIGHT: 150%"> </P><FONT lang=ZH-CN face=System>
      <P 
      style="LINE-HEIGHT: 150%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      </FONT><FONT lang=ZH-CN face=宋体 size=4><B>消息队列(Message 
      queues)</B></FONT></P>
      <BLOCKQUOTE>
        <BLOCKQUOTE>
          <P style="LINE-HEIGHT: 150%"><FONT size=3><SPAN 
          style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: Times New Roman; mso-bidi-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">现实的实时应用由一系列互相独立又协同工作的任务组成。信号量为任务间同步和联锁提供了高效机制。在VxWorks中,用于但一CPU任务之间通信主要(primary)的机制是消息队列。</SPAN></FONT></P>
          <H4 class=EntityTitle><A name=85857><FONT class=sans 
          face="Helvetica, sans-serif" size=-1>Full Duplex Communication Using 
          Message Queues</FONT></A></H4>
          <DL class=margin>
            <DIV class=Anchor><A name=85854></A><IMG class=figure height=139 
            src="嵌入式系统VxWorks介绍及编程.files/c-basic11.gif" width=313 border=0> 
            </DIV></DL>
          <P style="LINE-HEIGHT: 150%"> </P>
          <P style="LINE-HEIGHT: 150%"><FONT size=3><SPAN 
          style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: Times New Roman; mso-bidi-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">消息队列允许一定数量不同长度的消息进行排列。任何任务或中断服务程序(ISR)能够发送消息给消息队列。任何任务可以从消息队列接受消息。多任务可以从同意消息队列发送和接受消息。两个任务之间的全双工(Full-duplex)通信需要针对不同方向的两个消息队列。</SPAN></FONT></P>
          <P style="LINE-HEIGHT: 150%"><B><FONT lang=ZH-CN 
          face=宋体>消息队列函数介绍</FONT></B><FONT lang=ZH-CN 
          face=System>&nbsp;&nbsp;&nbsp; </FONT></P>
          <P style="LINE-HEIGHT: 150%"><B class=routine><I 
          class=routine>msgQCreate</I></B><B>(&nbsp;)&nbsp; </B>创建斌初始化一个消息队列</P>
          <P style="LINE-HEIGHT: 150%"><B class=routine><I 
          class=routine>msgQDelete</I></B><B>(&nbsp;) </B>终止并释放一个消息队列</P>
          <P style="LINE-HEIGHT: 150%"><B class=routine><I 
          class=routine>msgQSend</I></B><B>(&nbsp;)</B>&nbsp; 发送一个消息到消息队列</P>
          <P style="LINE-HEIGHT: 150%"><B class=routine><I 
          class=routine>msgQReceive</I></B><B>(&nbsp;) </B>从消息队列接受一个消息</P>
          <P style="LINE-HEIGHT: 150%">消息队列是由函数<FONT face=宋体><B>msgQCreate 
          (MAX_MSGS, MAX_MSG_LEN, MSG_Q_PRIORITY)</B></FONT>创建。它的参数<FONT 
          face=宋体><B>MAX_MSGS</B></FONT>指定了消息队列中可允许最多可以排列的消息数和每个消息允许的最大的字节数<FONT 
          face=宋体><B>MAX_MSG_LEN</B></FONT>。</P>
          <P style="LINE-HEIGHT: 150%">一个任务或中断服务程序(ISR)用函数<B class=routine><I 
          class=routine>msgQSend</I></B><B>(&nbsp;)</B>发送一个消息到消息队列。如果没有任务等待消息队列的消息,这个消息被添加消息缓存的队列里。如果某些任务已经在等待消息队列中的消息,消息立刻被传递给第一个等待的消息的任务。</P>
          <P style="LINE-HEIGHT: 150%">一个任务用函数<B class=routine><I 
          class=routine>msgQReceive</I></B><B>(&nbsp;)</B>从消息队列得到一个消息。如果消息队列缓存中有消息存在,第一个消息立刻出列并回到调用处(caller).如果没有消息存在,则任务(calling 
          task)停止(blocks)并被添加到等待消息的任务队列中。这个等待的任务队列按照优先级或先进先出(FIFO)规则排列,这个规则有消息队列创建时所指定。</P>
          <P style="LINE-HEIGHT: 150%"><B>等待时间限制(time out)</B></P>
          <P style="LINE-HEIGHT: 150%"><B class=routine><I 
          class=routine>msgQSend</I></B><B>(&nbsp;)</B> 和 <B class=routine><I 
          class=routine>msgQReceive</I></B><B>(&nbsp;)</B>都有时间限制参数。当发送一个消息,如果消息队列缓存这时没有空间,这个参数指定允许等待的时间(ticks数),直到队列缓存有空间来接收消息。当接收消息时,如果消息队列没有消息,这个参数指定允许等待的时间(ticks数),直到消息队列有消息。</P>
          <P style="LINE-HEIGHT: 150%"> </P><PRE class=Code style="LINE-HEIGHT: 150%"><B><A name=85925><FONT size=4><I>/* In this example, task t1 creates the message queue and sends a message 
&nbsp;* to task t2. Task t2 receives the message from the queue and simply 
&nbsp;* displays the message. 
&nbsp;*/</I></FONT></A></B><FONT size=4><I>
 
<B><A name=85927>/* includes */ 
#include "vxWorks.h" 
#include "msgQLib.h"</A></B>
 
<B><A name=85930>/* defines */ 
#define MAX_MSGS (10) 
#define MAX_MSG_LEN (100)</A><

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -