4.1 Elementary Structure
FIG. 1 Layout of a “Stress-Flow Atom” - rudimentary building block of program using stress-flow method.
The underlying building block of concurrent programming using stress-flow are subroutines of special layout – further referred to as “stress-flow atoms.” Each stress-flow atom comes with a built in access/synchronization mechanism and is divided into two specific parts. These are “Stressed” and “Relaxed” sections as shown on FIG. 1. One of these parts can in special cases be empty.
Very roughly - the stressed section is the part that is executed while the calling routine is constrained from doing a similar thing again. This is also where the stress-flow atom has been guaranteed exclusive access to critical context information from the calling environment. For example, the calling routine may pass an index to an array, and the called stress-flow atom may have to copy the indexed element for use later and to guarantee that the right element is used while the source array may change in the meantime. The relaxed section is entered when the stress-flow atom knows all that it needs to do its work, and so both the calling routine and our atom can go their separate ways.
The concurrency definition method of stress-flow is easy to understand because it attempts to mimic the real life. For example – Imagine a boss calling on a worker to perform a task. When the task is simple, there is nothing to do in the “stressed” section. The worker simply acknowledges taking the task, begins to do it alone, while the boss can go on and do something else. However, if the task definition requires cooperation with/information from the boss or third parties, the stressed section does have some steps defined in it. The worker might need to collect details of the task from the boss. He may also need to call a third party for the task to be properly defined. All this needs to be done while the boss waits to provide further details/decision and so all this work belongs in the stressed section. In some other situations all work may involve simply coordinating with others, meaning that there is nothing to do in the relaxed section.
Just as it is clear in real life – for the worker to be of any benefit, he has to tie up the boss (or other job requestor) as little as possible. Improving parallel performance in a stress-flow program requires organizing things in a way there is as little as possible to do in the stressed sections.
An actual implementation of stress-flow atom in a script language such as C/C++ might use a special keyword to indicate the end of stressed section or it can use the “return” or similar existing keyword for that purpose - with everything following the return instruction(s) automatically becoming the relaxed section. Currently, code written past “return” type keywords is considered invalid “unreachable code.” Apart from the practical advantage of not needing a new keyword, the method has many additional benefits. The end of the stressed section is the last possible moment where it would make sense to return any information to the calling process – therefore, if we are to allow the useful feature of returning a value back, this is the way to do it.
Internally, the implementation of a stress-flow atom binds it to a special simple critical section or lock mechanism that controls access to instances of the same stress-flow atom (or their group – this will be explained in detail later.)
Send mail to
email@example.com with questions or