ARM Shanghai IoT Team (Internal)
/
Semaphoreapp_JacobShi
test the function of the semaphore
Fork of rtos_semaphore by
main.cpp@4:0acf7ac363a8, 2014-10-27 (annotated)
- Committer:
- shiyilei
- Date:
- Mon Oct 27 04:37:39 2014 +0000
- Revision:
- 4:0acf7ac363a8
- Parent:
- 1:bdf73f017a77
test the function of the semaphore
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shiyilei | 4:0acf7ac363a8 | 1 | /************************************************** |
shiyilei | 4:0acf7ac363a8 | 2 | *file name : the test of the semaphore |
shiyilei | 4:0acf7ac363a8 | 3 | *Creator :JacobShi |
shiyilei | 4:0acf7ac363a8 | 4 | *Time:2014/10/27 |
shiyilei | 4:0acf7ac363a8 | 5 | * Description :test the function of the semaphore |
shiyilei | 4:0acf7ac363a8 | 6 | *************************************************/ |
emilmont | 1:bdf73f017a77 | 7 | #include "mbed.h" |
emilmont | 1:bdf73f017a77 | 8 | #include "rtos.h" |
shiyilei | 4:0acf7ac363a8 | 9 | DigitalOut led1(LED1); |
shiyilei | 4:0acf7ac363a8 | 10 | DigitalOut led2(LED2); |
shiyilei | 4:0acf7ac363a8 | 11 | DigitalOut led3(LED3); |
emilmont | 1:bdf73f017a77 | 12 | |
shiyilei | 4:0acf7ac363a8 | 13 | Semaphore twoslots(2); |
shiyilei | 4:0acf7ac363a8 | 14 | void normal_task(void const *args) |
shiyilei | 4:0acf7ac363a8 | 15 | { |
emilmont | 1:bdf73f017a77 | 16 | |
shiyilei | 4:0acf7ac363a8 | 17 | while(1) |
shiyilei | 4:0acf7ac363a8 | 18 | { |
shiyilei | 4:0acf7ac363a8 | 19 | twoslots.wait(); |
shiyilei | 4:0acf7ac363a8 | 20 | printf("%s\n",(char*)args); |
shiyilei | 4:0acf7ac363a8 | 21 | Thread::wait(400); |
shiyilei | 4:0acf7ac363a8 | 22 | twoslots.release(); |
shiyilei | 4:0acf7ac363a8 | 23 | } |
shiyilei | 4:0acf7ac363a8 | 24 | |
shiyilei | 4:0acf7ac363a8 | 25 | |
emilmont | 1:bdf73f017a77 | 26 | } |
emilmont | 1:bdf73f017a77 | 27 | |
shiyilei | 4:0acf7ac363a8 | 28 | |
shiyilei | 4:0acf7ac363a8 | 29 | int main(void) |
shiyilei | 4:0acf7ac363a8 | 30 | { |
shiyilei | 4:0acf7ac363a8 | 31 | |
shiyilei | 4:0acf7ac363a8 | 32 | Thread task1_thread1(normal_task,(void *)"task1"); |
shiyilei | 4:0acf7ac363a8 | 33 | Thread task2_thread2(normal_task,(void *)"task2"); |
shiyilei | 4:0acf7ac363a8 | 34 | Thread task3_thread3(normal_task,(void *)"task3"); |
shiyilei | 4:0acf7ac363a8 | 35 | |
shiyilei | 4:0acf7ac363a8 | 36 | while(1) |
shiyilei | 4:0acf7ac363a8 | 37 | { |
shiyilei | 4:0acf7ac363a8 | 38 | |
shiyilei | 4:0acf7ac363a8 | 39 | |
shiyilei | 4:0acf7ac363a8 | 40 | } |
shiyilei | 4:0acf7ac363a8 | 41 | } |