📄 int9.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/01/03 14:15:18">
<title>10.8 Locking out interrupts</title>
<STYLE TYPE="text/css">
<!--
span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>
<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="os20toc.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="int8.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="int10.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="os20ix.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<h2>
<a name="1205042"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">10.8 Locking out interrupts</font>
</h2><hr>
<p>
<a name="1205043"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">All interrupts to the CPU can be globally disabled or re-enabled using the following two commands:</font>
</p>
<a name="1205046"> </a><font size=2 face=Courier><strong>#include <interrupt.h><br>void interrupt_lock(void);<br>void interrupt_unlock(void);<br></strong></font>
<p>
<a name="1205047"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">These functions should always be called as a pair, and prevent any interrupts from the interrupt controller having any effect on the currently executing task while the lock is in place. These functions can be used to create a critical region in which the task cannot be preempted by any other task or interrupt. Calls to <font size=2 face=Courier><strong>interrupt_lock()</strong></font> can be nested, and the lock not released until an equal number of calls to <font size=2 face=Courier><strong>interrupt_unlock()</strong></font> have been made.</font>
</p>
<p>
<a name="1205048"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif"><em>Note: Locking out interrupts is slightly different from disabling an interrupt. Interrupts are locked by changing the ST20's <span class=Signal>Enables</span> register, which causes the CPU to ignore the interrupt controller (and any other external device), while disabling an interrupt modifies the interrupt controller's <span class=Signal>Mask</span> register, and so can be used much more selectively. On the ST20C2, locking interrupts also prevents high priority processes from interrupting, and disables channels and timers.</em></font>
</p>
<p>
<a name="1205049"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">A task must not deschedule with interrupts locked, as this can cause the scheduler to fail. When interrupts are locked, calling any function that may not be called by an interrupt service routine is illegal.</font>
</p>
</blockquote>
<hr>
<table width="331" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><a href="os20toc.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="int8.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="int10.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="os20ix.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<font size=1 face="Verdana, Arial, Helvetica, sans-serif"> © 2001, 2002, 2003 STMicroelectronics. All Rights Reserved.<br>
ADCS 7473749B</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -