Added exclusive locking for POSIX serial ports.
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 01848e9..e6ef534 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -302,6 +302,17 @@
         """Set communication parameters on opened port."""
         if self.fd is None:
             raise SerialException("Can only operate on a valid file descriptor")
+            
+        # if exclusive lock is requested, create it before we modify anything else
+        if self._exclusive is not None:
+            if self._exclusive:
+                try:
+                    fcntl.flock(self.fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+                except IOError as msg:
+                    raise SerialException(msg.errno, "Could not exclusively lock port {}: {}".format(self._port, msg))
+            else:
+                fcntl.flock(self.fd, fcntl.LOCK_UN)
+            
         custom_baud = None
 
         vmin = vtime = 0                # timeout is done via select