Hi,
I would like to make multiple write calls to the serial port from different threads. I want to make sure that all of the calls in a given portion of a thread are performed sequentially and not interrupted by another thread. What is the best mechanism to do this?
My hunch is that this is a fairly straightforward issue that shows my ignorance of general RTOS principals. Can anybody recommend a resource to learn general best practices when dealing with RTOS threads and interrupts?
Thanks!
Serial write from multiple threads
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Serial write from multiple threads
Hi,
This is a common problem, you need to do mutual exclusion using a mutex or a semaphore. The threads would take the mutex/semaphore, perform their I/O and finally release the mutex/semaphore. The I/O operation will be atomically performed.
I think this can help: http://www.chibios.org/dokuwiki/doku.ph ... sion_guide
Giovanni
This is a common problem, you need to do mutual exclusion using a mutex or a semaphore. The threads would take the mutex/semaphore, perform their I/O and finally release the mutex/semaphore. The I/O operation will be atomically performed.
I think this can help: http://www.chibios.org/dokuwiki/doku.ph ... sion_guide
Giovanni