Case study Embedded System Design
/
Case_Study_rtos_mutex
finished
Fork of rtos_mutex by
Revision 5:969aeadd077e, committed 2015-02-13
- Comitter:
- cathal66
- Date:
- Fri Feb 13 00:03:22 2015 +0000
- Parent:
- 4:192fef923dbc
- Commit message:
- Comments put in
Changed in this revision
diff -r 192fef923dbc -r 969aeadd077e main.cpp --- a/main.cpp Tue Jun 04 16:03:01 2013 +0100 +++ b/main.cpp Fri Feb 13 00:03:22 2015 +0000 @@ -1,24 +1,26 @@ -#include "mbed.h" -#include "rtos.h" +#include "mbed.h" //Include the mbed.h file +#include "rtos.h" //Include the rtos.h file -Mutex stdio_mutex; +Mutex stdio_mutex; //Setup the mutex -void notify(const char* name, int state) { - stdio_mutex.lock(); - printf("%s: %d\n\r", name, state); - stdio_mutex.unlock(); +void notify(const char* name, int state) { //function and passes data NAME and STATE to the function + stdio_mutex.lock(); //mutex lock stdio_mutex + printf("%s: %d\n\r", name, state); //read name and state and print them on serial + stdio_mutex.unlock(); //mutex unlock stdio_mutex } -void test_thread(void const *args) { - while (true) { - notify((const char*)args, 0); Thread::wait(1000); - notify((const char*)args, 1); Thread::wait(1000); - } -} +void test_thread(void const *args) { //Thread and function, pass data to the thread/function + while (true) { //Super loop + notify((const char*)args, 0); //function call, passes number and toggles data to the function + Thread::wait(1000); //Thread wait 1 sec + notify((const char*)args, 1); ////function call, pass two data to the function + Thread::wait(1000); //Thread wait 1 sec + } //end super loop +} //end function int main() { - Thread t2(test_thread, (void *)"Th 2"); - Thread t3(test_thread, (void *)"Th 3"); + Thread t2(test_thread, (void *)"Th 2"); //start thread t2 + Thread t3(test_thread, (void *)"Th 3"); //start thread t3 - test_thread((void *)"Th 1"); -} + test_thread((void *)"Th 1"); //function call +} //end main
diff -r 192fef923dbc -r 969aeadd077e mbed-rtos.lib --- a/mbed-rtos.lib Tue Jun 04 16:03:01 2013 +0100 +++ b/mbed-rtos.lib Fri Feb 13 00:03:22 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed-rtos/#83e169389a69
diff -r 192fef923dbc -r 969aeadd077e mbed.bld --- a/mbed.bld Tue Jun 04 16:03:01 2013 +0100 +++ b/mbed.bld Fri Feb 13 00:03:22 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa \ No newline at end of file