Sharing a Domain Device with Threads
When numerous threads attempt to access a domain device
simultaneously, we enter into the realm of a Thread-Safe environment. When more
than one thread competes for access to an object simultaneously, some threads
may receive an invalid state if another thread modifies the resource at the
same time. For example, if a robot attempt to access objects on a conveyor belt
while another robot is operating on that same conveyor belt, the first thread
(robot) may receive an invalid state of access (Zhai et al., 2012). This situation leads to what is known as a race
condition.
What's notable is the profound ability to use
synchronization techniques that prevent thread interference of shared objects through
calls to a method that will lock the thread. In this scenario, no other thread
can access the conveyor belt until completing the current thread's (robot's)
execution (Basile et al., 2002).
.
The Semaphore Safe Thread Regarding the Robot and the Conveyor
We can use semaphores when dealing with a conveyor system in
which there is a single robot that needs access to a multi-accessed conveyor
system.
Preventing simultaneous access to the conveyor system is an issue and can be solved using a semaphore. In the robot-conveyor case, the robot must wait before accessing an atomic conveyor system until the semaphore is in a state that allows access to acquire objects. When the robot accesses the conveyor belt, the semaphore changes state to stop other robots from accessing the conveyor system (Moiseev, 2010). A robot that has completed it's conveyor access operations changes the semaphore state to permit another robot to access the conveyor belt.
In the robot-conveyor scenario, a semaphore could be a
simple number. More specifically, a robot waits for permission to proceed. It
then messages other robots a flag indicating it has proceeded by implementing a
numerical value on the semaphore's operation.
The Garage State Machine
Below is a state machine that depicts the state of a garage
door opening and closing operations provided with specific time and emergency
conditions. It also illustrates state changes with cause and effect of
additional actions based on either remote control triggers or emergency
conditions. Many of the states shown in the diagram below refer to the various
inputs from devices that affect the garage's behavior. To fully demonstrate the
garage's multiple states, I provided a comprehensive state machine diagram that
presents states' full visualization and how the garage door transitions to each
state (Alonso et al., 2008).
The state diagram below (fig.1) begins with a green start
icon and a square titled "garage closed" as the initial state and ends
with a square titled "garage closed" as the final state. However, as
you will witness, many conditions and triggers affect the garage door events'
progression. The behavior of the garage door is illustrated clearly in
transitory order from garage operational state to state.
References
Alonso, D., Vicente-Chicote, C., Pastor, J. A., & Álvarez, B. (2008). Stateml+: From graphical state machine models to thread-safe ada code. International Conference on Reliable Software Technologies,
Basile, C., Whisnant, K., Kalbarczyk, Z., & Iyer, R. (2002). Loose synchronization of multithreaded replicas. 21st IEEE Symposium on Reliable Distributed Systems, 2002. Proceedings.,
Moiseev, M. (2010). Defect detection for multithreaded programs with semaphore-based synchronization. 2010 6th Central and Eastern European Software Engineering Conference (CEE-SECR),
Zhai,
K., Xu, B., Chan, W., & Tse, T. (2012). CARISMA: a context-sensitive
approach to race-condition sample-instance selection for multithreaded
applications. Proceedings of the 2012 International Symposium on Software
Testing and Analysis,
No comments:
Post a Comment