[squeak-dev] Serial Port(s) from multiple processes

David T. Lewis lewis at mail.msen.com
Fri Jun 12 11:19:40 UTC 2009


On Thu, Jun 11, 2009 at 04:16:06PM -0400, Jon Hylands wrote:
> 
> Hi everyone,
> 
> I've got a couple USB-based serial ports on my robot BrainBot, and I've got
> four different processes - two for each port. One process reads from the
> serial port, and one writes to it.
> 
> For each serial port, I have a mutex semaphore to protect access to the
> port, like this:
> 
> readData
> 	^portAccess critical: [serialPort readByteArray]
> 
> writeData: aByteArray
> 	portAccess critical: [serialPort nextPutAll: aByteArray]
> 
> Those two methods are implemented in the same class, and thus the
> 'portAccess' instance variable (which is a Semaphore) is shared between
> read and write, but not between different serial ports..
> 
> I have two instances of this class, one for each USB device plugged in (the
> USB devices are both FT232-based interfaces, one at port 4, the other at
> port 5).
> 
> The question is, do I need to protect the two instances of SerialPort with
> a single Semaphore? Looking at the serial port code for read/writing, it
> looks like the code just jumps directly into the primitives. I was under
> the assumption that primitive execution can't be pre-empted, and therefore
> the code shouldn't need mutex protection.
> 
> Am I missing something?

It does not sound like you are missing anything. Are you encountering
problems with this, or are you just asking to be sure?

Dave




More information about the Squeak-dev mailing list