PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Activation Groups In AS/400

Go down

Activation Groups In AS/400

Post  sivakumar on Mon Jul 19, 2010 5:59 pm

Activation group is a container for memory and other resources. According to the ILE Concepts manual (PDF format), this container is considered a "substructure of a job." In other words, the job owns the activation group. In fact, a job can own many activation groups.
So an activation group is a resource container within a job. Simple enough. But what does the container hold? The short answer is that it holds a bunch of activations, hence the term "activation" group. An activation is a reference to the storage allocation and runtime program binding activities that the operating systems perform when a program executes.

If it sounds complex, that's because it is. The good news is that you don't really have to understand these details in order to use activation groups. In fact, whether you realize it or not, you're already are using activation groups! Your job has a DAG, or default activation group, that is automatically created when your job is started. Actually, two default activation groups are created, but we'll treat them as one for the purpose of this article. This activation group is where your system code and OPM (Original Program Model) programs run. ILE programs can run in the default activation group, but I'll come back to that in a bit.


Previous articles discussed creating programs out of modules, which is a two-step process: In RPG, this would include CRTRPGMOD (Create RPG Module) and then CRTPGM (Create Program). I use this approach exclusively, but for single-module programs, these steps can be consolidated into one command: CRTBNDRPG (Create Bound RPG Program). In PDM, this is the old stand by option 14, and the result is a *PGM object: The interim *MODULE object is not created. The reason why I mention this approach now is that this is typically the first run-in that new RPG IV programmers have with activation groups.

If you prompt 14 in PDM, you will see an option for Default Activation Group, with a default of *YES. If you try to create a program with DFTACTGRP(*YES), that program can't use any ILE features: no procedures (not even internal), no service programs, no binding directories. This sort of program is considered OPM even if it is written in RPG IV. As a result, you frequently see examples that include an H-spec of DFTACTGRP(*NO). This allows the program to compile with all of those ILE goodies because now, by virtue of being created with something other than the DAG, it is an ILE program.

For clarification, I should point out that a program created from *MODULE objects, whether one or many, cannot be created with DFTACTGRP(*YES). In fact, even if you include DFTACTGRP(*NO) in a source member and try to create a module (option 15 in PDM), you will receive a compile error because DFTACTGRP is not a valid parameter for the CRTMOD command. This makes sense when you consider that only ILE programs can use *MODULE objects, so a non-ILE option cannot be allowed.

Now that we are firmly entrenched in ILE territory, we are going to leave the DAG behind and explore our ILE options. There are several approaches you can use when creating a program or service program.

The default for CRTPGM (and not an option for CRTSRVPGM) is ACTGRP(*NEW), so let's start there. This means that every time the program is executed, it creates a new activation group, or container, for all the resources necessary to run the program. Memory is allocated, the program is copied into the activation group, variables are initialized, and so on: This is very similar to OPM behavior. When the program reaches termination, the activation group is deleted and the resources are reclaimed.

As you can probably guess, this can be a labor-intensive process for the operating system, especially if the program is executed frequently. If you have a program that you execute 50 times a day from the same job (remember this is all job-oriented!), you are creating the activation group, executing the program, and destroying the activation group 50 times. This adds a lot of overhead to your job and will certainly affect performance.

The most important thing to remember about *NEW is that every call to the program is an island unto itself: Variable values and file states are new and fresh every time the program is called, even if called recursively. As such, it is advisable to use *NEW sparingly.

The default for CRTSRVPGM is *CALLER. Any program or service program invoked with *CALLER will run inside the activation group of the calling program or procedure. This can really improve performance in your applications, because it removes the overhead of creating the activation group. Using *CALLER works well for most procedures that are activated by other procedures, which is why it is the logical default for service programs.

I mentioned earlier that ILE programs can run in the DAG. You do so by specifying *CALLER, then executing the program directly from a command line or calling it from an OPM program. Since you are in the DAG when you do so, the program executes within the DAG. This is generally considered a poor practice, for several reasons. First, it defeats the purpose of having activation groups by lumping all resources together into a single group. Second, it unnecessarily clutters up the DAG: Remember that the DAG's main job is to run operating system code, so it seems logical that the less you can make that group worry about, the better. Finally, it prevents you from isolating the activities of an activation group because it doesn't have a unique name, a topic that will be covered a little later.


The final option for activation groups is to give them a name. This is also the coolest option, and has the best promise for performance. A named activation group is just that: one for which you specify the name. The first time the program or service program executes, it goes through the overhead of creating the group, but then that group remains active until it is reclaimed or the job has ended. Now any subsequent time the program is called it will run in the already extant group. Since the activation group is already running, start up time can be greatly diminished. As promised, this means faster performance.

To illustrate this, let me tell a story on myself. When I first went live several years ago with my RPG-CGI Web site,, I noticed that it ran great for a few users but that performance seriously degraded with more visitors. There were lots of explanations for that scenario, and I think we tried every one we could think of, to no avail. As I have frequently done in the past, I turned to an e-mail list for assistance. After going around the barn a few times, someone asked about the activation group specified when the CGI programs were created. After that, it didn't take long to realize my mistake: I had created all the programs with ACTGRP(*NEW).

By using *NEW, every Web request required the AS/400 to create an activation group, execute the program, answer the request, and destroy the activation group. That was a lot of overhead for something as simple as a Web page! Multiply that overhead by several thousand hits an hour, and my poor little 270 simply couldn't keep up with the demand. The solution was simple: I recreated all the programs with ACTGRP(named), where named is the name of the CGI program. Now, within each CGI job, once a page has been requested the activation group remains and is constantly reused. This provided a dramatic increase in performance.


So far I've primarily discussed programs, so I'll shift a little and talk about service programs in particular. Again, the most common approach for CRTSRVPGM is to use ACTGRP(*CALLER). When you consider that most service programs consist of procedures that are called and used by other programs, it makes perfect sense to let the service program run in the same activation group as the program that's calling it.
Now, if you have 100 programs in 100 activation groups all using the same procedure in service program A, there will be 100 activations of that service program. That could obviously hamper performance. To improve that, you could put your service program into a named activation group, so that all the calling activations are sharing the same service program activation. This would be worth examining if you have a service program that is used extensively. As always, though, there is a caveat.

Using a named activation group introduces another interesting feature: Any static or global variables you use in a service program with a named activation group are available across other activation group boundaries.


I'll leave you this time with a couple of quick goodies about activation groups. If you have an activation group that is not being used, and you would like to get rid of it, you can use the Reclaim Activation Group (RCLACTGRP) command. Indicate ACTGRP(*ELIGIBLE) to delete all non-active but existing activation groups (not including the DAG) or indicate ACTGRP(name), where name is the specific activation group you want to delete.

So how do you see an activation group? Well, you can't really see the activation group, but you can find a list of all the active groups for a particular job. Go to WRKJOB (or WRKACTJOB, and select option 5 for the job you want), and select option 18 ("display activation groups, if active"). You will see a listing of all the active groups associated with that job and a status indicator.


Posts : 174
Join date : 2009-07-27
Age : 32
Location : Chennai

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum