ScottM wrote:I have a handful of threads, each calling wiringPi's digitalWrite. Do I need to wrap a mutex around the digitalWrite call, or does it already have one internally?
You can read the source. Get it here: http://wiringpi.com/
then make your own mind up.
However, knowing a little about how the hardware works will go a long way. The Pi's GPIO hardware does not need a read/modify/write cycle. Write a bit in one register to turn a pin on, write a bit in another register to turn that pin off, so no mutex is required.
If you're using digitalWrite() to control some external GPIO expander, then you may need to wrap mutexes round it, depending on the device. Again, inspection of the source code will help you here.
Also, and off topic - I'm horrified to learn the GPIO pins come up at boot time as anything other than Input, pulled in some consistent direction. I'm more horrified to learn the start state of the pins varies with the hardware revision (and maybe OS?). This is beyond a joke. I realize this is not wiringPi's fault or problem, but if anyone has a way to hack the OS (raspian) to get the pins to a proper starting state as soon as possible at boot time (microseconds preferred to seconds), I'd love to know about it. My application currently only drives LEDs, but without at least ONE pin that is guaranteed to come up in a known state forever, it looks like I won't be using the pi for anything but LEDs.
I'm horrified to learn that you've not read the manual. It's very predictable. The power-on values and pull up/down resistors are all in the Broadcom ARM peripherals manual.
After power-on, the bootloader enables the serial port and the aux. I2C port to read an eeprom (if present). It passes the eeprom data to the kernel as a device tree, then the kernel does what it needs based on that information and the device tree stuff in /boot/config.txt. No eeprom and nothing extra in the config file and it doesn't do anything else.
Do google "crushed to death by automatic garage door" though and build in your own interlocks for anything critical. This is why industrial PLCs cost 1000x more than a Pi.