Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rtos_semaphore by
main.cpp@4:8475152ef2ef, 2013-08-15 (annotated)
- Committer:
- avnisha
- Date:
- Thu Aug 15 06:51:38 2013 +0000
- Revision:
- 4:8475152ef2ef
- Parent:
- 1:bdf73f017a77
ok
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| emilmont | 1:bdf73f017a77 | 1 | #include "mbed.h" |
| emilmont | 1:bdf73f017a77 | 2 | #include "rtos.h" |
| emilmont | 1:bdf73f017a77 | 3 | |
| emilmont | 1:bdf73f017a77 | 4 | Semaphore two_slots(2); |
| emilmont | 1:bdf73f017a77 | 5 | |
| emilmont | 1:bdf73f017a77 | 6 | void test_thread(void const *name) { |
| emilmont | 1:bdf73f017a77 | 7 | while (true) { |
| emilmont | 1:bdf73f017a77 | 8 | two_slots.wait(); |
| emilmont | 1:bdf73f017a77 | 9 | printf("%s\n\r", (const char*)name); |
| emilmont | 1:bdf73f017a77 | 10 | Thread::wait(1000); |
| emilmont | 1:bdf73f017a77 | 11 | two_slots.release(); |
| emilmont | 1:bdf73f017a77 | 12 | } |
| emilmont | 1:bdf73f017a77 | 13 | } |
| emilmont | 1:bdf73f017a77 | 14 | |
| emilmont | 1:bdf73f017a77 | 15 | int main (void) { |
| emilmont | 1:bdf73f017a77 | 16 | Thread t2(test_thread, (void *)"Th 2"); |
| emilmont | 1:bdf73f017a77 | 17 | Thread t3(test_thread, (void *)"Th 3"); |
| emilmont | 1:bdf73f017a77 | 18 | |
| emilmont | 1:bdf73f017a77 | 19 | test_thread((void *)"Th 1"); |
| emilmont | 1:bdf73f017a77 | 20 | } |
