📄 devapi-smp-support.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>SMP Support</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="Device Driver Interface to the Kernel"HREF="devapi-device-driver-interface-to-the-kernel.html"><LINKREL="PREVIOUS"TITLE="Synchronization"HREF="devapi-synchronization.html"><LINKREL="NEXT"TITLE="Device Driver Models"HREF="devapi-device-driver-models.html"></HEAD><BODYCLASS="SECTION"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="devapi-synchronization.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 18. Device Driver Interface to the Kernel</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="devapi-device-driver-models.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="DEVAPI-SMP-SUPPORT">SMP Support</H1><P>Some eCos targets contain support for Symmetric Multi-Processing (SMP)configurations, where more than one CPU may be present. This optionhas a number of ramifications for the way in which device drivers mustbe written if they are to be SMP-compatible. </P><P>Since it is possible for the ISR, DSR and thread components of adevice driver to execute on different CPUs, it is important thatSMP-compatible device drivers use the driver API routines correctly.</P><P>Synchronization between threads and DSRs continues to require that thethread-side code use <TTCLASS="FUNCTION">cyg_drv_dsr_lock()</TT> and<TTCLASS="FUNCTION">cyg_drv_dsr_unlock()</TT> to protect access to shareddata. While it is not strictly necessary for DSR code to claim the DSRlock, since DSRs are run with it claimed already, it is good practiceto do so.</P><P>Synchronization between ISRs and DSRs or threads requires that accessto sensitive data be protected, in all places, by calls to<TTCLASS="FUNCTION">cyg_drv_isr_lock()</TT> and<TTCLASS="FUNCTION">cyg_drv_isr_unlock()</TT>. Disabling or maskinginterrupts is not adequate, since the thread or DSR may be running ona different CPU and interrupt enable/disable only work on the currentCPU.</P><P>The ISR lock, for SMP systems, not only disables local interrupts, butalso acquires a spinlock to protect against concurrent access fromother CPUs. This is necessary because ISRs are not run with thescheduler lock claimed. Hence they can run in parallel with the othercomponents of the device driver.</P><P>The ISR lock provided by the driver API is just a shared spinlock thatis available for use by all drivers. If a driver needs to implement afiner grain of locking, it can use private spinlocks, accessed via the<TTCLASS="FUNCTION">cyg_drv_spinlock_*()</TT> functions.</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="devapi-synchronization.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="devapi-device-driver-models.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Synchronization</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="devapi-device-driver-interface-to-the-kernel.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Device Driver Models</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -