fdasfasd

Dependencies:   mbed-rtos mbed

Fork of rtos_mutex by mbed official

main.cpp

Committer:
MaxAigner
Date:
2015-01-18
Revision:
5:c1722555cc45
Parent:
1:0f886ffbe0c1

File content as of revision 5:c1722555cc45:

#include "mbed.h"
#include "rtos.h"
#include <string>
#include "iostream"

Mutex stdio_mutex; 
string teststring;

void notify(const char* name, int state) {
    int counter;
    stdio_mutex.lock();
    counter ++;
    teststring = "hallo welt %a" , counter; 
    stdio_mutex.unlock();
}

void test_thread(void const *args) {
    while (true) {
        notify((const char*)args, 0); Thread::wait(1000);
        notify((const char*)args, 1); Thread::wait(1000);
    }
}

int main() {
    Thread t2(test_thread, (void *)"Th 2");

    while (1)
    {
        stdio_mutex.lock();
        printf( "%s" , teststring);
        stdio_mutex.unlock();
        wait_ms(100);
        }
    
}