Semaphores, Mutex and RTOS on Arduino (ChibiOS Help?)

Variables that are shared between threads should be typed volatile.

Also you need to insure access to variables is atomic. A context switch can happen during a multi-byte fetch or store.

See count in the the chBlinkPrint example.