Ada 95 Quality and Style Guide Chapter 6

Chapter 6: Concurrency - TOC - 6.2 COMMUNICATION

6.2.6 Communication Complexity

guideline

  • Minimize the number of accept and select statements per task .
  • Minimize the number of accept statements per entry.

  • example

    Use:

    accept A;
    if Mode_1 then
       -- do one thing
    else  -- Mode_2
       -- do something different
    end if;
    

    rather than:

    if Mode_1 then
       accept A;
       -- do one thing
    else  -- Mode_2
       accept A;
       -- do something different
    end if;
    

    rationale

    This guideline reduces conceptual complexity. Only entries necessary to understand externally observable task behavior should be introduced. If there are several different accept and select statements that do not modify task behavior in a way important to the user of the task, there is unnecessary complexity introduced by the proliferation of select/accept statements. Externally observable behavior important to the task user includes task timing behavior, task rendezvous initiated by the entry calls, prioritization of entries, or data updates (where data is shared between tasks).

    notes

    Sanden (1994) argues that you need to trade off the complexity of the guards associated with the accept statements against the number of select/accept statements. Sanden (1994) shows an example of a queue controller for bank tellers where there are two modes, open and closed. You can implement this scenario with one loop and two select statements, one for the open mode and the other for the closed mode. Although you are using more select/accept statements, Sanden (1994) argues that the resulting program is easier to understand and verify.


    < Previous Page Search Contents Index Next Page >
    1 2 3 4 5 6 7 8 9 10 11
    TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC
    Appendix References Bibliography