CooCox CoOS User's Guide
CooCox CoOS User's Guide
CooCox CoOS User's Guide
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Example usage:<br />
Note:<br />
#include "CCRTOS.h"<br />
OS_EventID semaphore;;<br />
void TaskN (void *pdata)<br />
{<br />
}<br />
StatusType result;<br />
...<br />
/* Accept a semaphore without waitting */<br />
result = CoAcceptSem (semaphore);<br />
if (result != E_OK)<br />
{<br />
}<br />
{<br />
{<br />
else<br />
{<br />
}<br />
if (result == E_INVALID_ID)<br />
}<br />
printf("Invalid event ID !\n");<br />
else if (result == E_SEM_EMPTY)<br />
}<br />
...<br />
…<br />
printf("No semaphore exist !\n");<br />
/* Process semaphore here */<br />
…<br />
1) Running AcceptSem() program is an incomplete P operation. There are<br />
some difference between them,when the number of the resources is<br />
0,complete P operation will wait until other task release the<br />
corresponding resource or finished for timeout,but this program will<br />
return error immediately.<br />
2) The number of the semaphore resources substract 1 after getting the<br />
resources successfully.<br />
6.7.4 CoPendSem()<br />
Function Prototype:<br />
StatusType CoPendSem(<br />
OS_EventID id,<br />
U32<br />
timeout<br />
);<br />
83