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.

6.6 Mutex Section<br />

6.6.1 CoCreateMutex()<br />

Function Prototype:<br />

OS_MutexID CoCreateMutex(void);<br />

Descriptions:<br />

Create a Mutex section.<br />

Parameters:<br />

None<br />

Returns:<br />

Mutex section ID, create successfully<br />

-1, create failed<br />

Example usage:<br />

Note:<br />

#include "CCRTOS.h"<br />

OS_MutexID mutex;<br />

void TaskN (void *pdata)<br />

{<br />

}<br />

…<br />

/* Create a mutex */<br />

mutex = CoCreateMutex ();<br />

if (mutex == E_CREATE_FAIL)<br />

{<br />

}<br />

else<br />

{<br />

}<br />

None<br />

printf("Create mutex fail. \n");<br />

printf("Mutex ID : %d \n", mutex);<br />

...<br />

6.6.2 CoEnterMutexSection()<br />

Function Prototype:<br />

StatusType CoEnterMutexSection(<br />

OS_MutexID mutexID<br />

);<br />

Descriptions:<br />

Enter the mutex section whose ID was designated.<br />

77

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

Saved successfully!

Ooh no, something went wrong!