02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

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 />

#include "CCRTOS.h"<br />

OS_EventID semaphore;<br />

void TaskN (void *pdata)<br />

{<br />

StatusType result;<br />

...<br />

/* Create a semaphore */<br />

result = CoDeleteSem (semaphore, OPT_DEL_ANYWAY);<br />

if (result != E_OK)<br />

{<br />

if (result == E_INVALID_ID)<br />

{<br />

printf("Invalid event ID !\n");<br />

}<br />

}<br />

...<br />

}<br />

Note:<br />

Release the resources that the semaphore occupied If delete it<br />

successfully,then run a task sheduling and give the system execution time<br />

to the highest priority task.<br />

6.7.3 CoAcceptSem()<br />

Function Prototype:<br />

StatusType CoAcceptSem(<br />

Descriptions:<br />

OS_EventID id<br />

);<br />

To obtain semaphore resources whose ID was designated.<br />

Parameters:<br />

[in] id<br />

the designated semaphore ID<br />

Returns:<br />

E_INVALID_ID,<br />

E_SEM_EMPTY,<br />

E_OK,<br />

the semaphore ID that was<br />

incomed is invalid<br />

the semaphore resources whose<br />

ID was designated is empty<br />

to obtain the resources successfully<br />

82

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!