Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Deprecated

This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.

Committer:
emilmont
Date:
Fri Nov 23 09:57:31 2012 +0000
Revision:
6:350b53afb889
Child:
8:88a1a9c26ae3
Merge RTOS C++ API and RTX under the same library; Update RTX to version 4.60; Add proper Thread destructor;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 6:350b53afb889 1 #include "Semaphore.h"
emilmont 6:350b53afb889 2
emilmont 6:350b53afb889 3 #include <string.h>
emilmont 6:350b53afb889 4 #include "error.h"
emilmont 6:350b53afb889 5
emilmont 6:350b53afb889 6 namespace rtos {
emilmont 6:350b53afb889 7
emilmont 6:350b53afb889 8 Semaphore::Semaphore(int32_t count) {
emilmont 6:350b53afb889 9 #ifdef CMSIS_OS_RTX
emilmont 6:350b53afb889 10 memset(_semaphore_data, 0, sizeof(_semaphore_data));
emilmont 6:350b53afb889 11 _osSemaphoreDef.semaphore = _semaphore_data;
emilmont 6:350b53afb889 12 #endif
emilmont 6:350b53afb889 13 _osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
emilmont 6:350b53afb889 14 }
emilmont 6:350b53afb889 15
emilmont 6:350b53afb889 16 int32_t Semaphore::wait(uint32_t millisec) {
emilmont 6:350b53afb889 17 return osSemaphoreWait(_osSemaphoreId, millisec);
emilmont 6:350b53afb889 18 }
emilmont 6:350b53afb889 19
emilmont 6:350b53afb889 20 osStatus Semaphore::release(void) {
emilmont 6:350b53afb889 21 return osSemaphoreRelease(_osSemaphoreId);
emilmont 6:350b53afb889 22 }
emilmont 6:350b53afb889 23
emilmont 6:350b53afb889 24 Semaphore::~Semaphore() {
emilmont 6:350b53afb889 25 osSemaphoreDelete(_osSemaphoreId);
emilmont 6:350b53afb889 26 }
emilmont 6:350b53afb889 27
emilmont 6:350b53afb889 28 }