In a program that has the serial attribute, system work areas are allocated statically, and the program is locked on entry
and unlocked on exit.
This allows only one thread to execute the program at a given time and so eliminates any contention on system or user work
areas. No other explicit application logic is required.
A program can be given the serial attribute by specifying the SERIAL Compiler directive when you compile it.
By specifying a traditional COBOL program as a serial program it can be included in a multi-threaded application without any
source changes.
The disadvantages of serial programs are that:
- The level of multi-threading is limited within the application. Ideally, a multi-threaded application should allow free execution
of as much code as possible to allow maximum performance.
- Locking and unlocking the program can have a major run-time cost. This can significantly affect call speed and overall application
performance. For this reason, as few modules as possible should be compiled with this directive and, you should ensure that
called programs have the no-multi-threading attribute. For example, if program A is to be compiled with the serial attribute
and program A is the only program in the application that calls programs B and C, then by application design, program B and
C are already serialized and can be compiled with the no-multi-threading attribute.