Powerteam / Mbed 2 deprecated rtos_mutex

Dependencies:   mbed-rtos mbed

Fork of rtos_mutex by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 #include <string>
00004 #include "iostream"
00005 
00006 Mutex stdio_mutex; 
00007 string teststring;
00008 
00009 void notify(const char* name, int state) {
00010     int counter;
00011     stdio_mutex.lock();
00012     counter ++;
00013     teststring = "hallo welt %a" , counter; 
00014     stdio_mutex.unlock();
00015 }
00016 
00017 void test_thread(void const *args) {
00018     while (true) {
00019         notify((const char*)args, 0); Thread::wait(1000);
00020         notify((const char*)args, 1); Thread::wait(1000);
00021     }
00022 }
00023 
00024 int main() {
00025     Thread t2(test_thread, (void *)"Th 2");
00026 
00027     while (1)
00028     {
00029         stdio_mutex.lock();
00030         printf( "%s" , teststring);
00031         stdio_mutex.unlock();
00032         wait_ms(100);
00033         }
00034     
00035 }