02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

[in] muterID<br />

the designated mutex section ID<br />

Returns:<br />

E_CALL, be called in the interrupt service program<br />

E_INVALID_ID, the mutex section ID that was incomed is invalid<br />

E_OK,<br />

enter the mutex section successfully<br />

Example usage:<br />

#include "CCRTOS.h"<br />

OS_MutexID mutex;<br />

void TaskN (void *pdata)<br />

{<br />

...<br />

/* Create a mutex */<br />

mutex = CoCreateMutex ();<br />

/* Enter critical region */<br />

CoEnterMutexSection(mutex);<br />

…<br />

/*Process here */<br />

…<br />

/* Exit critical region */<br />

CoLeaveMutexSection(mutex);<br />

...<br />

}<br />

Note:<br />

1) If there are tasks waiting to enter the mutex section currently,it need<br />

to run a task scheduling and the priority of the currently task will be<br />

back to the original priority when leaving the mutex section.<br />

2) This function can not be used in interrupt service routine.<br />

3) It should be used in pairs with CoEnterMutexSection().<br />

79

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

Saved successfully!

Ooh no, something went wrong!