<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MQX Software Solutions中的主题 Why does RTCS use rtcs_fd_set for sets of file descriptors instead of just an fd array pointer and count? What are the implications of changing RTCSCFG_FD_SETSIZE?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-RTCS-use-rtcs-fd-set-for-sets-of-file-descriptors/m-p/452714#M15191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking at the RTCS manual, specifically the select() function, and wondering why it takes rtcs_fd_set pointers instead of just taking arrays of file descriptors and their respective lengths. Is there some reasoning behind this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the one hand, it is somewhat inefficient because the user is forced to use the biggest array ever used in one of these fd_set structures. On the other hand, it leaves room for a dangerous configuration change by making RTCSCFG_FD_SETSIZE configurable in user_config.h. If I change it to, say, 4 from the default 8, everything that uses rtcs_fd_set is at risk of not having a big enough FD set array to operate properly (not to mention possible overruns in unsafe code).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something? I'm sure there's a good reason for this design decision, but I can't quite figure out what it is. If a Freescale employee who dealt with that part of the code would explain the reasoning behind it, that would be ideal, but I would also appreciate any speculation on why it's done this way or relevant historical background from other similar APIs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a safeguard, I do something similar to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_1440016242325261 jive_macro_code jive_text_macro" data-renderedposition="310.3999938964844_8_1223_48" jivemacro_uid="_1440016242325261"&gt;&lt;P&gt;#if RTCSCFG_FD_SETSIZE &amp;lt; 5&lt;/P&gt;&lt;P&gt;#error "RTCS FD SET SIZE TOO SMALL"&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in code that requires a certain FD set size to function. Of course there's also the ability to calculate constants and loop counts based on RTCSCFG_FD_SETSIZE to make things more generic, so the fact that it's changeable really isn't a big deal if the code handles it properly. Mostly, the thing that puzzles me here is the willingness to potentially waste some RAM in an embedded system for the sake of having fewer arguments in API function calls...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Aug 2015 20:52:28 GMT</pubDate>
    <dc:creator>dmitriyc</dc:creator>
    <dc:date>2015-08-19T20:52:28Z</dc:date>
    <item>
      <title>Why does RTCS use rtcs_fd_set for sets of file descriptors instead of just an fd array pointer and count? What are the implications of changing RTCSCFG_FD_SETSIZE?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-RTCS-use-rtcs-fd-set-for-sets-of-file-descriptors/m-p/452714#M15191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking at the RTCS manual, specifically the select() function, and wondering why it takes rtcs_fd_set pointers instead of just taking arrays of file descriptors and their respective lengths. Is there some reasoning behind this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the one hand, it is somewhat inefficient because the user is forced to use the biggest array ever used in one of these fd_set structures. On the other hand, it leaves room for a dangerous configuration change by making RTCSCFG_FD_SETSIZE configurable in user_config.h. If I change it to, say, 4 from the default 8, everything that uses rtcs_fd_set is at risk of not having a big enough FD set array to operate properly (not to mention possible overruns in unsafe code).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something? I'm sure there's a good reason for this design decision, but I can't quite figure out what it is. If a Freescale employee who dealt with that part of the code would explain the reasoning behind it, that would be ideal, but I would also appreciate any speculation on why it's done this way or relevant historical background from other similar APIs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a safeguard, I do something similar to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_1440016242325261 jive_macro_code jive_text_macro" data-renderedposition="310.3999938964844_8_1223_48" jivemacro_uid="_1440016242325261"&gt;&lt;P&gt;#if RTCSCFG_FD_SETSIZE &amp;lt; 5&lt;/P&gt;&lt;P&gt;#error "RTCS FD SET SIZE TOO SMALL"&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in code that requires a certain FD set size to function. Of course there's also the ability to calculate constants and loop counts based on RTCSCFG_FD_SETSIZE to make things more generic, so the fact that it's changeable really isn't a big deal if the code handles it properly. Mostly, the thing that puzzles me here is the willingness to potentially waste some RAM in an embedded system for the sake of having fewer arguments in API function calls...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 20:52:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-RTCS-use-rtcs-fd-set-for-sets-of-file-descriptors/m-p/452714#M15191</guid>
      <dc:creator>dmitriyc</dc:creator>
      <dc:date>2015-08-19T20:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does RTCS use rtcs_fd_set for sets of file descriptors instead of just an fd array pointer and count? What are the implications of changing RTCSCFG_FD_SETSIZE?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-RTCS-use-rtcs-fd-set-for-sets-of-file-descriptors/m-p/452715#M15192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Partially answering my own question after some more research, it's may be because that's the way POSIX does it. For example, the Linux select manpages: &lt;A href="http://man7.org/linux/man-pages/man2/select.2.html" title="http://man7.org/linux/man-pages/man2/select.2.html"&gt;select(2) - Linux manual page&lt;/A&gt;&amp;nbsp; and&amp;nbsp; &lt;A href="http://linux.die.net/man/3/fd_set" title="http://linux.die.net/man/3/fd_set"&gt;fd_set(3): synchronous I/O multiplexing - Linux man page &lt;/A&gt;​.&amp;nbsp; This makes sense because MQX tries to follow POSIX were possible, but the POSIX API was probably designed primarily for application-level OSes, which would have no problem with an fd_set size of 1024. Would still appreciate some comments from other people on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 21:01:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Why-does-RTCS-use-rtcs-fd-set-for-sets-of-file-descriptors/m-p/452715#M15192</guid>
      <dc:creator>dmitriyc</dc:creator>
      <dc:date>2015-08-19T21:01:18Z</dc:date>
    </item>
  </channel>
</rss>

