欢迎来到天天文库
浏览记录
ID:37344385
大小:83.50 KB
页数:19页
时间:2019-05-22
《μCOS-II中OS_SEM.C源码中文注释版》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、xilentz的网络文摘博客园 首页 新随笔 联系 订阅 管理随笔-204 文章-0 评论-10 trackbacks-0OS_SEM.C/*********************************************************************************************************** uC/OS-II*
2、 TheReal-TimeKernel* SEMAPHOREMANAGEMENT** (c)Copyright1992-2002,JeanJ.Labrosse,Weston,FL* AllRightsReserved**File:OS_SEM.C*By :JeanJ.Labrosse***
3、*******************************************************************************************************/#ifndef OS_MASTER_FILE#include"includes.h"#endif#ifOS_SEM_EN>0/****************************************************************************************************
4、******* ACCEPTSEMAPHORE接受信号量**Description:Thisfunctionchecksthesemaphoretoseeifaresourceisavailableor,ifanevent* occurred. UnlikeOSSemPend(),OSSemAccept()doesnotsuspendthecallingtaskifthe* resourceisnot
5、availableortheeventdidnotoccur.**Arguments :pevent isapointertotheeventcontrolblock**Returns :> 0 iftheresourceisavailableortheeventdidnotoccurthesemaphoreis* decrementedtoobtaintheresource.* ==0 iftheresourceisnotava
6、ilableortheeventdidnotoccuror,* if'pevent'isaNULLpointeror,* ifyoudidn'tpassapointertoasemaphore**********************************************************************************************************/#ifOS_SEM_ACCEPT_E
7、N>0INT16U OSSemAccept(OS_EVENT*pevent){#ifOS_CRITICAL_METHOD==3 /*AllocatestorageforCPUstatusregister */ OS_CPU_SR cpu_sr;#endif INT16U cnt;#ifOS_ARG_CHK_EN>0 if(pevent==(OS_EVENT*)0){ /*Validate'pevent'
8、 */ return(0); } if(pevent->OSEventType!=OS_EVENT_TYPE_SEM){ /*Validateeventblocktype
此文档下载收益归作者所有