Download thesis

Transcript
3.3.4 SOCKET CONTROL THREAD
The socket control concept refers to the operations that make possible the transmission and
reception of network data using the operating system’s socket interface. The socket control
operations contain procedures such as socket initialization and release.
In addition, because the management service supports connection through multiple network
interfaces or through a multihomed interface (a network interface having multiple IP addresses
assigned), the socket control ensures that a socket reference is opened on all interfaces that have
been previously selected by the user.
After the socket procedures are completed, the socket control thread is also responsible of
starting the socket data threads that will handle the data transfer socket operations. There are two
reasons for which the socket operations i.e. socket open/close and socket read/write have been
separated in two threads:
A failure or a block is more probable to occur during data transfer procedures, and
therefore if such an event happens the control of the thread is still maintained.
Shortly, if a read/write procedure blocks the socket data thread it would never affect
the socket control thread. The advantages of this approach will be explained
immediately.
The second issue is robustness. By keeping socket and data operations running in two
functions and having two separate stacks prevents even the smallest corruption event
such as the case of buffer overflow and the socket operation can be recovered.
Furthermore, a prolonged data operation cannot affect the ability of the threads in
receiving controls from parent threads and finally, it isolated user management data
from other internal data structures.
Notes
In implementation, the probability that a socket operation to fail or block is prevented
through several methods such as data availability checking and received data size
checking. Even so, because the implementation of the service relies on operating
system code, such events were not excluded and the occurrence was taken into
account.
In understanding the reasons why the socket control should be implemented separately from the
socket data operations, try to imagine what if a socket operations takes too long or simply blocks
the thread operation. The most basic operation that would block the thread would be a read
operation from an empty buffer or a write operation onto a full buffer. In the first situation, the
operation would block indefinitely if management data would never arrive on the computer.
The management service has been designed to prevent recovery from such events, in the case
that their occurrence cannot be prevented. This is done by using a thread in which the socket
control operations are performed. If the socket data operation blocks for instance, it would only
block the socket data thread.
Now imagine that the SCM sends a stop control to the management service. The stop control is
received by the main service control thread in the form of a control variable change from
running to stop. As it was explained in the previous section, the main control thread would exit
the thread loop and start sending stop control to its descendent threads, i.e. the socket control
threads. The socket control threads also have a thread loop in which they wait for a stop control
to arrive.
87