📄 linux环境进程间通信(四):信号灯.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0063)http://study.feloo.com/computer/pro/vc/system/200506/39163.html -->
<HTML><HEAD><TITLE>Linux环境进程间通信(四):信号灯</TITLE>
<META
content=Linux环境进程间通信(四):信号灯,Linux环境进程间通信(四):信号灯教程,Linux环境进程间通信(四):信号灯学习文章,Linux环境进程间通信(四):信号灯电脑教程,Linux环境进程间通信(四):信号灯电脑文章,Linux环境进程间通信(四):信号灯学习教程,Linux环境进程间通信(四):信号灯学习资料,Linux环境进程间通信(四):信号灯资料下载,Linux环境进程间通信(四):信号灯实例,Linux环境进程间通信(四):信号灯实例教学
name=Description>
<META
content='="Linux环境进程间通信(四):信号灯,Linux环境进程间通信(四):信号灯教程,Linux环境进程间通信(四):信号灯学习文章,Linux环境进程间通信(四):信号灯电脑教程,Linux环境进程间通信(四):信号灯电脑文章,Linux环境进程间通信(四):信号灯学习教程,Linux环境进程间通信(四):信号灯学习资料,Linux环境进程间通信(四):信号灯资料下载,Linux环境进程间通信(四):信号灯实例,Linux环境进程间通信(四):信号灯实例教学"'
name=keywords>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>.style1 {
COLOR: #0099cc
}
</STYLE>
<LINK href="Linux环境进程间通信(四):信号灯.files/Skin3.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript src="Linux环境进程间通信(四):信号灯.files/menu.js"
type=text/JavaScript></SCRIPT>
<SCRIPT language=JavaScript1.2 src="Linux环境进程间通信(四):信号灯.files/stm31.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript type=text/JavaScript>
//改变图片大小
function resizepic(thispic)
{
if(thispic.width>700) thispic.width=700;
}
//无级缩放图片笮?
function bbimg(o)
{
var zoom=parseInt(o.style.zoom, 10)||100;
zoom+=event.wheelDelta/12;
if (zoom>0) o.style.zoom=zoom+'%';
return false;
}
//双击鼠标滚动屏幕的代码
var currentpos,timer;
function initialize()
{
timer=setInterval ("scrollwindow ()",30);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos !=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
//更改字体大小
var status0='';
var curfontsize=10;
var curlineheight=18;
function fontZoomA(){
if(curfontsize>8){
document.getElementById('fontzoom').style.fontSize=(--curfontsize)+'pt';
document.getElementById('fontzoom').style.lineHeight=(--curlineheight)+'pt';
}
}
function fontZoomB(){
if(curfontsize<64){
document.getElementById('fontzoom').style.fontSize=(++curfontsize)+'pt';
document.getElementById('fontzoom').style.lineHeight=(++curlineheight)+'pt';
}
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY leftMargin=0 topMargin=0>
<DIV id=menuDiv
style="Z-INDEX: 1000; VISIBILITY: hidden; WIDTH: 1px; POSITION: absolute; HEIGHT: 1px; BACKGROUND-COLOR: #9cc5f8"></DIV><!-- ********网页顶部代码开始******** -->
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD bgColor=#4f4f4f height=3></TD></TR>
<TR>
<TD class=top_Channel align=right width="100%"><FONT
color=red> | <A class=Channel
href="http://study.feloo.com/Index.html">网站首页</A> | <A
class=Channel2 href="http://study.feloo.com/computer/Index.html"
target=_self>电脑学习</A> | <A class=Channel
href="http://study.feloo.com/Article/Index.html"
target=_self>英语学堂</A> | <A class=Channel
href="http://study.feloo.com/lunwen/Index.html"
target=_self>论文中心</A> | <A class=Channel
href="http://study.feloo.com/exam/Index.html"
target=_self>试题资源</A> | <A class=Channel
href="http://study.feloo.com/jiaoan/Index.html"
target=_self>教案集锦</A> | <A class=Channel
href="http://study.feloo.com/kejian/Index.html"
target=_self>课件下载</A> | <A class=Channel
href="http://study.feloo.com/school/Index.html"
target=_self>高校联盟</A> | <A class=Channel
href="http://study.feloo.com/job/Index.html"
target=_self>求职创业</A> | <A class=Channel
href="http://study.feloo.com/fanben/Index.html"
target=_self>实用范本</A> | <A class=Channel
href="http://study.feloo.com/down"
target=_blank>软件下载</A> | </FONT></TD></TR>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR></TBODY></TABLE>
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD align=middle height=72>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=180 height=72><A title=中国学习联盟
href="http://study.feloo.com/" target=_blank><IMG height=60
src="Linux环境进程间通信(四):信号灯.files/logo.gif" width=180 border=0></A></TD>
<TD align=middle width=*>
<SCRIPT src="Linux环境进程间通信(四):信号灯.files/banner.js"></SCRIPT>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE class=top_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR>
<TR><!--banner广告显示代码-->
<TD align=middle>
<SCRIPT src="Linux环境进程间通信(四):信号灯.files/ban-wen.js"></SCRIPT>
</TD></TR>
<TR>
<TD bgColor=#4f4f4f height=1></TD></TR></TBODY></TABLE><!--导航代码开始-->
<TABLE class=top_Path style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0
width=760 align=center border=0>
<TBODY>
<TR>
<TD align=middle width="5%"><IMG height=25
src="Linux环境进程间通信(四):信号灯.files/ad_mqdhl.gif" width=40></TD>
<TD width="73%">您现在的位置: <A
href="http://study.feloo.com/">中国学习联盟</A> >> <A
href="http://study.feloo.com/computer/Index.html">电脑学习</A> >> <A
href="http://study.feloo.com/computer/pro/Index.html">程序设计</A> >> <A
href="http://study.feloo.com/computer/pro/vc/Index.html">VC语言</A> >> <A
href="http://study.feloo.com/computer/pro/vc/system/Index.html">系统类编程</A> >> 电脑文章正文</TD>
<TD align=middle width="22%"><IMG height=13
src="Linux环境进程间通信(四):信号灯.files/User_Login.gif" width=13 align=absMiddle>
<A class=top_UserLogin href="http://study.feloo.com/User/User_Login.asp"
target=_blank>用户登录</A> <IMG height=13
src="Linux环境进程间通信(四):信号灯.files/User_Reg.gif" width=13 align=absMiddle> <A
class=top_UserLogin href="http://study.feloo.com/Reg/User_Reg.asp"
target=_blank>注册</A> </TD></TR></TBODY></TABLE><!--导航代码结束--><!-- ********网页顶部代码结束******** --><!-- ********网页中部代码开始******** -->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top width=*><!--网页中部左栏文章内容代码开始-->
<TABLE style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0
width="100%" align=center border=0>
<TBODY>
<TR>
<TD class=main_title_282 vAlign=center width="3%"><IMG height=28
src="Linux环境进程间通信(四):信号灯.files/ad_dh.gif" width=29
align=absMiddle></TD>
<TD class=main_title_282 width="66%">Linux环境进程间通信(四):信号灯</TD>
<TD class=main_title_282
align=middle> <FONT
color=#009999>★★★★★</FONT></TD></TR></TBODY></TABLE>
<TABLE class=main_tdbg_575 style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR vAlign=center align=middle>
<TD class=main_ArticleTitle style="WORD-BREAK: break-all"
background=Linux环境进程间通信(四):信号灯.files/ad_dybg2.gif colSpan=2
height=48>Linux环境进程间通信(四):信号灯</TD></TR>
<TR align=middle bgColor=#eeeeee>
<TD colSpan=2 height=24>作者:未知 文章来源:中国学习联盟 点击数:
<SCRIPT language=javascript
src="Linux环境进程间通信(四):信号灯.files/GetHits.htm"></SCRIPT>
更新时间:2005-6-9</TD></TR>
<TR>
<TD colSpan=2></TD></TR>
<TR align=right>
<TD colSpan=2 height=24>【字体:<A class=top_UserLogin
href="javascript:fontZoomA();">小</A> <A class=top_UserLogin
href="javascript:fontZoomB();">大</A>】【<A
href="http://study.feloo.com/computer/Comment.asp?ArticleID=39163"
target=_blank>发表评论</A>】【<A
href="http://study.feloo.com/User/User_Favorite.asp?Action=Add&ChannelID=25&InfoID=39163"
target=_blank>加入收藏</A>】【<A
href="http://study.feloo.com/computer/SendMail.asp?ArticleID=39163"
target=_blank>告诉好友</A>】【<A
href="http://study.feloo.com/computer/Print.asp?ArticleID=39163"
target=_blank>打印此文</A>】【<A
href="javascript:window.close();">关闭窗口</A>】 </TD></TR><!--文章标题下部广告代码开始-->
<TR>
<TD align=middle colSpan=2>
<SCRIPT src="Linux环境进程间通信(四):信号灯.files/wen-top.js"></SCRIPT>
</TD></TR><!--文章标题下部广告代码结束-->
<TR>
<TD background=Linux环境进程间通信(四):信号灯.files/ad_bx1.gif colSpan=2
height=6></TD></TR>
<TR>
<TD colSpan=6></TD></TR>
<TR>
<TD id=fontzoom style="WORD-BREAK: break-all" vAlign=top colSpan=2
height=600>
<P><A name=1><SPAN class=atitle2>一、信号灯概述</SPAN></A></P>
<P>信号灯与其他进程间通信方式不大相同,它主要提供对进程间共享资源访问控制机制。相当于内存中的标志,进程可以根据它判定是否能够访问某些共享资源,同时,进程也可以修改该标志。除了用于访问控制外,还可用于进程同步。信号灯有以下两种类型:</P>
<UL class=n01>
<LI>二值信号灯:最简单的信号灯形式,信号灯的值只能取0或1,类似于互斥锁。<BR>注:二值信号灯能够实现互斥锁的功能,但两者的关注内容不同。信号灯强调共享资源,只要共享资源可用,其他进程同样可以修改信号灯的值;互斥锁更强调进程,占用资源的进程使用完资源后,必须由进程本身来解锁。
<LI>计算信号灯:信号灯的值可以取任意非负值(当然受内核本身的约束)。 </LI></UL>
<P><A name=2><SPAN class=atitle2>二、Linux信号灯</SPAN></A></P>
<P>linux对信号灯的支持状况与消息队列一样,在red had
8.0发行版本中支持的是系统V的信号灯。因此,本文将主要介绍系统V信号灯及其相应API。在没有声明的情况下,以下讨论中指的都是系统V信号灯。</P>
<P>注意,通常所说的系统V信号灯指的是计数信号灯集。</P>
<P><A name=3><SPAN class=atitle2>三、信号灯与内核</SPAN></A></P>
<P>1、系统V信号灯是随内核持续的,只有在内核重起或者显示删除一个信号灯集时,该信号灯集才会真正被删除。因此系统中记录信号灯的数据结构(struct
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -