21.01.2015 Views

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

INtime® 3.1 Software - tenAsys

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: About RT programming<br />

Synchronization<br />

When one thread needs to run before another thread, it can use an exchange object to<br />

signal the second thread when it has completed. For example, the thread that creates<br />

the transaction summary in an automated teller application shouldn’t run until after<br />

the threads that handle withdrawals and deposits run. The transaction summary thread<br />

must synchronize with the other threads.<br />

INtime software provides several objects for synchronization that accommodate a wide<br />

variety of situations. The next figure illustrates using a semaphore to send a signal to<br />

another thread.<br />

Figure 4-6. Threads that use a semaphore for synchronization<br />

A<br />

<br />

<br />

B<br />

Thread A, the running thread, preprocesses some data. Thread B needs to use the data after thread<br />

A finishes.<br />

When thread A finishes, it sends a signal (not data) to the semaphore.<br />

When thread B receives the signal, it processes the data.<br />

Mutual exclusion<br />

INtime software includes regions that you can use to protect data from being accessed<br />

by multiple threads at the same time. This is called mutual exclusion.<br />

When an INtime application runs, multiple threads can concurrently access the same<br />

data. This is useful in a multithreading system, such as a transaction processing system<br />

where a large number of operators concurrently manipulate a common database.<br />

47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!