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

📄 fileio-select.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Select</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="File System Support Infrastructure"HREF="fileio.html"><LINKREL="PREVIOUS"TITLE="Sockets"HREF="fileio-sockets.html"><LINKREL="NEXT"TITLE="Devices"HREF="fileio-devices.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="fileio-sockets.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="fileio-devices.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="FILEIO-SELECT">Chapter 27. Select</H1><P>The infrastructure provides support for implementing a selectmechanism. This is modeled on the mechanism in the BSD kernel, but hasbeen modified to make it implementation independent.</P><P>The main part of the mechanism is the <TTCLASS="FUNCTION">select()</TT>API call. This processes its arguments and calls the<TTCLASS="FUNCTION">fo_select()</TT> function pointer on all file objectsreferenced by the file descriptor sets passed to it. If the samedescriptor appears in more than one descriptor set, the<TTCLASS="FUNCTION">fo_select()</TT> function will be called separatelyfor each appearance.</P><P>The <TTCLASS="PARAMETER"><I>which</I></TT> argument of the<TTCLASS="FUNCTION">fo_select()</TT> function will either be<TTCLASS="LITERAL">CYG_FREAD</TT> to test for read conditions,<TTCLASS="LITERAL">CYG_FWRITE</TT> to test for write conditions or zero totest for exceptions. For each of these options the function shouldtest whether the condition is satisfied and if so return true. If itis not satisfied then it should call<TTCLASS="FUNCTION">cyg_selrecord()</TT> with the<TTCLASS="PARAMETER"><I>info</I></TT> argument that was passed to the functionand a pointer to a <SPANCLASS="STRUCTNAME">cyg_selinfo</SPAN> structure.</P><P>The <SPANCLASS="STRUCTNAME">cyg_selinfo</SPAN> structure is used to record information about currentselect operations. Any object that needs to support select mustcontain an instance of this structure.  Separate <SPANCLASS="STRUCTNAME">cyg_selinfo</SPAN>structures should be kept for each of the options that the object canselect on - read, write or exception.</P><P>If none of the file objects report that the select condition issatisfied, then the <TTCLASS="FUNCTION">select()</TT> API function putsthe calling thread to sleep waiting either for a condition to becomesatisfied, or for the optional timeout to expire.</P><P>A selectable object must have some asynchronous activity that maycause a select condition to become true - either via interrupts or theactivities of other threads. Whenever a selectable condition issatisfied, the object should call <TTCLASS="FUNCTION">cyg_selwakeup()</TT> with a pointer tothe appropriate <SPANCLASS="STRUCTNAME">cyg_selinfo</SPAN> structure. If the thread is still waiting,this will cause it to wake up and repeat its poll of the filedescriptors. This time around, the object that caused the wakeupshould indicate that the select condition is satisfied, and the<TTCLASS="FUNCTION">select()</TT> API call will return.</P><P>Note that <TTCLASS="FUNCTION">select()</TT> does not exhibit real timebehaviour: the iterative poll of the descriptors, and the wakeupmechanism mitigate against this. If real time response to device orsocket I/O is required then separate threads should be devoted to eachdevice of interest and should use blocking calls to wait for acondition to become ready.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="fileio-sockets.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="fileio-devices.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Sockets</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="fileio.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Devices</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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