📄 libc-thread-safety.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>Thread safety</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="C and math library overview"HREF="c-and-math-library-overview.html"><LINKREL="PREVIOUS"TITLE="Some implementation details"HREF="libc-implementation-details.html"><LINKREL="NEXT"TITLE="C library startup"HREF="c-library-startup.html"></HEAD><BODYCLASS="SECT1"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="libc-implementation-details.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 13. C and math library overview</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="c-library-startup.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="LIBC-THREAD-SAFETY">Thread safety</H1><P>The ISO C library has configuration options that control threadsafety, i.e. working behavior if multiple threads call the samefunction at the same time.</P><P>The following functionality has to be configured correctly,or used carefully in a multi-threaded environment:</P><P></P><UL><LI><P><TTCLASS="FUNCTION">mblen()</TT></P></LI><LI><P><TTCLASS="FUNCTION">mbtowc()</TT></P></LI><LI><P><TTCLASS="FUNCTION">wctomb()</TT></P></LI><LI><P><TTCLASS="FUNCTION">printf()</TT> (and all standard I/O functions except for <TTCLASS="FUNCTION">sprintf()</TT> and <TTCLASS="FUNCTION">sscanf()</TT></P></LI><LI><P><TTCLASS="FUNCTION">strtok()</TT></P></LI><LI><P><TTCLASS="FUNCTION">rand()</TT> and <TTCLASS="FUNCTION">srand()</TT></P></LI><LI><P><TTCLASS="FUNCTION">signal()</TT> and <TTCLASS="FUNCTION">raise()</TT></P></LI><LI><P><TTCLASS="FUNCTION">asctime()</TT>, <TTCLASS="FUNCTION">ctime()</TT>, <TTCLASS="FUNCTION">gmtime()</TT>, and <TTCLASS="FUNCTION">localtime()</TT></P></LI><LI><P>the <TTCLASS="FUNCTION">errno</TT> variable</P></LI><LI><P>the <TTCLASS="FUNCTION">environ</TT> variable</P></LI><LI><P>date and time settings</P></LI></UL><P>In some cases, to make <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> developmenteasier, functions are provided (as specified by POSIX 1003.1) that definere-entrant alternatives, i.e. <TTCLASS="FUNCTION">rand_r()</TT>, <TTCLASS="FUNCTION">strtok_r()</TT>, <TTCLASS="FUNCTION">asctime_r()</TT>, <TTCLASS="FUNCTION">ctime_r()</TT>, <TTCLASS="FUNCTION">gmtime_r()</TT>,and <TTCLASS="FUNCTION">localtime_r()</TT>. In other cases,configuration options are provided that control either locking of functionsor their shared data, such as with standard I/O streams,or by using per-thread data, such as with the <TTCLASS="FUNCTION">errno</TT> variable.</P><P>In some other cases, like the setting of date and time, nore-entrant or thread-safe alternative or configuration is providedas it is simply not a worthwhile addition (date and time shouldrarely need to be set.)</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="libc-implementation-details.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="c-library-startup.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Some implementation details</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="c-and-math-library-overview.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">C library startup</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -