# uC/OS-III 互斥量例程 ## 概述 该工程演示了uC/OS-III互斥量的使用。 ## 硬件设置 无特殊设置 ## 运行现象 本例程创建了两个任务。这两个任务都会在没有mutex保护的情况下打印一条消息,然后在mutex的保护下再打印一条消息。 如同打印的消息中所描述的,在mutex保护下的两条消息不能出现混合,但是其仍然可以被未被mutex保护的消息所打断。 即:打印2和打印4的语句是互斥的,打印2的过程中不能出现数字4,但是可以出现数字3;打印4的过程中不能出现数字2,但是可以出现数字1。 当工程正确运行后,串口终端会输出如下信息: ```console This thread will print 3 without mutex protection, and will print 4 within mutex protection. This thread will print 1 without mutex protection, and will print 2 within mutex protection. 11111111111111111111111111111 22222222222222222222222222222 11111111111111111111111111111 22222222222222222222222222222 3333333333333333333333333333 11111111111111111111111111111 4444444444444444444444444444 222222222 33333333332222222222223333333333322222222 3333333 11111111111111111111111111111 4444444444444444444444444444 222222222 33333333332222222222223333333333322222222 3333333 ```