CMSIS RTOS Demo

Here are three examples of CMSIS RTOS applications:

Thread

Import programcmsis_rtos_demo_thread

cmsis rtos demo

Result:

Creating thread 0
Creating thread 1
Creating thread 2
Creating thread 3
Creating thread 4
Creating thread 5
Creating thread 6
Creating thread 7
Thread 1: French: Bonjour, le monde!  Sum=1
Thread 0: English: Hello World!  Sum=0
Thread 3: Klingon: Nuq neH!  Sum=6
Thread 2: Spanish: Hola al mundo  Sum=3
Thread 4: German: Guten Tag, Welt!  Sum=10
Thread 6: Japan: Sekai e konnichiwa!  Sum=21
Thread 5: Russian: Zdravstvytye, mir!  Sum=15
Thread 7: Latin: Orbis, te saluto!  Sum=28

Mutex

Import programcmsis_rtos_demo_mutex

cmsis rtos demo: mutex

Result:

Sum =  0.000000 
Thread 0 did 0 to 200:  mysum=200.000000 global sum=200.000000
Thread 1 did 200 to 400:  mysum=200.000000 global sum=400.000000
Thread 2 did 400 to 600:  mysum=200.000000 global sum=600.000000
Thread 3 did 600 to 800:  mysum=200.000000 global sum=800.000000

Signal

Import programcmsis_rtos_demo_signal

cmsis rtos demo

Result:

Main(): Waited and joined with 3 threads. Final value of count = 0. Done.
Starting watch_count(): thread 1
inc_count(): thread 2, count = 1, unlocking mutex
inc_count(): thread 3, count = 2, unlocking mutex
watch_count(): thread 1 Count= 2. Going into wait...
inc_count(): thread 2, count = 3, unlocking mutex
inc_count(): thread 3, count = 4, unlocking mutex
inc_count(): thread 2, count = 5, unlocking mutex
inc_count(): thread 3, count = 6, unlocking mutex
inc_count(): thread 2, count = 7, unlocking mutex
inc_count(): thread 3, count = 8, unlocking mutex
inc_count(): thread 2, count = 9, unlocking mutex
inc_count(): thread 3, count = 10, unlocking mutex
inc_count(): thread 2, count = 11, unlocking mutex
inc_count(): thread 3, count = 12  Threshold reached. Just sent signal.
inc_count(): thread 3, count = 12, unlocking mutex
watch_count(): thread 1 Condition signal received. Count= 12
watch_count(): thread 1 Updating the value of count...
watch_count(): thread 1 count now = 137.
watch_count(): thread 1 Unlocking mutex.
inc_count(): thread 2, count = 138, unlocking mutex
inc_count(): thread 3, count = 139, unlocking mutex
inc_count(): thread 2, count = 140, unlocking mutex
inc_count(): thread 3, count = 141, unlocking mutex
inc_count(): thread 2, count = 142, unlocking mutex
inc_count(): thread 3, count = 143, unlocking mutex
inc_count(): thread 2, count = 144, unlocking mutex
inc_count(): thread 3, count = 145, unlocking mutex

All three examples are ported from the following pthread tutorial: https://computing.llnl.gov/tutorials/pthreads/

I'm new to rtos, so if you find any silly mistakes, just let me know. Thanks!


Please log in to post comments.