Document revision date: 30 March 2001 | |
Previous | Contents | Index |
Figure 17-1 shows a task stack.
Figure 17-1 Diagram of a Task Stack
The SHOW TASK/STATISTICS command reports some statistics about all tasks in your program. Example 17-5 shows the output of the SHOW TASK/STATISTICS/FULL command for a sample program with POSIX Threads tasks. This information enables you to measure the performance of your program. The larger the number of total schedulings (also known as context switches), the more tasking overhead there is.
Example 17-5 Sample SHOW TASK/STAT/FULL Display for POSIX Threads Tasks |
---|
task statistics Total context switches: 0 Number of existing threads: 0 Total threads created: 0 DBG> |
The SHOW TASK/ALL command displays information about all of the tasks of the program that currently exist---namely, tasks that have been created and whose master has not yet terminated (see Example 17-6).
Example 17-6 Sample SHOW TASK/ALL Display for Ada Tasks |
---|
(1) (2) (3) (4) (5) (6) task id pri hold state substate task object * %TASK 1 7 RUN SHARE$ADARTL+130428 %TASK 2 7 HOLD SUSP Accept TASK_EXAMPLE.MOTHER+4 %TASK 4 7 SUSP Entry call TASK_EXAMPLE.FATHER_TYPE$TASK_BODY.CHILD+4 %TASK 3 6 READY TASK_EXAMPLE.MOTHER) DBG> |
Key to Example 17-6:
Task Substate | Description |
---|---|
Abnormal | Task has been aborted. |
Accept | Task is waiting at an accept statement that is not inside a select statement. |
Activating | Task is elaborating its declarative part. |
Activating tasks | Task is waiting for tasks it has created to finish activating. |
Completed [abn] | Task is completed due to an abort statement but is not yet terminated. In Ada, a completed task is one that is waiting for dependent tasks at its end statement. After the dependent tasks are terminated, the state changes to terminated. |
Completed [exc] | Task is completed due to an unhandled exception 1 but is not yet terminated. In Ada, a completed task is one that is waiting for dependent tasks at its end statement. After the dependent tasks are terminated, the state changes to terminated. |
Completed | Task is completed. No abort statement was issued and no unhandled exception 1 occurred. |
Delay | Task is waiting at a delay statement. |
Dependents | Task is waiting for dependent tasks to terminate. |
Dependents [exc] | Task is waiting for dependent tasks to allow an unhandled exception 1 to propagate. |
Entry call | Task is waiting for its entry call to be accepted. |
Invalid state | There is an error in the Compaq Ada Run-Time Library. |
I/O or AST | Task is waiting for I/O completion or some AST. |
Not yet activated | Task is waiting to be activated by the task that created it. |
Select or delay |
Task is waiting at a select statement with a delay
alternative. |
Select or terminate | Task is waiting at a select statement with a terminate alternative. |
Select | Task is waiting at a select statement with no else, delay, or terminate alternative. |
Shared resource | Task is waiting for an internal shared resource. |
Terminated [abn] | Task was terminated by an abort statement. |
Terminated [exc] | Task was terminated because of an unhandled exception. 1 |
Terminated | Task terminated normally. |
Timed entry call | Task is waiting in a timed entry call. |
Figure 17-1 shows a task stack.
The SHOW TASK/FULL command provides detailed information about each task selected for display. Example 17-7 shows the output of this command for a sample Ada task.
Example 17-7 Sample SHOW TASK/FULL Display for an Ada Task |
---|
(1) task id pri hold state substate task object * %TASK 2 7 RUN TASK_EXAMPLE.MOTHER+4 (2) Waiting entry callers: Waiters for entry BOGUS: %TASK 4, type: CHILD (3) Task type: FATHER_TYPE Created at PC: TASK_EXAMPLE.%LINE 14+22 Parent task: %TASK 1 Start PC: TASK_EXAMPLE.FATHER_TYPE$TASK_BODY (4) Task control block: (5) Stack storage (bytes): Task value: 490816 RESERVED_BYTES: 10640 Entries: 3 TOP_GUARD_SIZE: 5120 Size: 1488 STORAGE_SIZE: 30720 (6) Stack addresses: Bytes in use: 456 Top address: 001EB600 Base address: 001F2DFC (7) Total storage: 47968 DBG> |
Key to Example 17-7:
The SHOW TASK/STATISTICS command reports some statistics about all tasks in your program. Example 17-8 shows the output of the SHOW TASK/STATISTICS/FULL command for a sample Ada tasking program on a VAX system. This information enables you to measure the performance of your program. The larger the number of total schedulings (also known as context switches), the more tasking overhead there is.
Example 17-8 Sample SHOW TASK/STATISTICS/FULL Display for Ada Tasks (VAX Example) |
---|
task statistics Entry calls = 4 Accepts = 1 Selects = 2 Tasks activated = 3 Tasks terminated = 0 ASTs delivered = 4 Hibernations = 0 Total schedulings = 15 Due to readying a higher priority task = 1 Due to task activations = 3 Due to suspended entry calls = 4 Due to suspended accepts = 1 Due to suspended selects = 2 Due to waiting for a DELAY = 0 Due to scope exit awaiting dependents = 0 Due to exception awaiting dependents = 0 Due to waiting for I/O to complete = 0 Due to delivery of an AST = 4 Due to task terminations = 0 Due to shared resource lock contention = 0 DBG> |
17.5 Changing Task Characteristics
To modify a task's characteristics or the tasking environment while
debugging, use the SET TASK command, as shown in the following table:
Command | Description |
---|---|
SET TASK/ACTIVE | Makes a specified task the active task; not for POSIX Threads (on OpenVMS Alpha or VAX) or Ada on OpenVMS Alpha (see Section 17.3.1). |
SET TASK/VISIBLE | Makes a specified task the visible task (see Section 17.3.1). |
SET TASK/ABORT | Requests that a task be terminated at the next allowed opportunity. The exact effect depends on the current event facility (language dependent). For Ada tasks, this is equivalent to executing an abort statement. |
SET TASK/PRIORITY | Sets a task's priority. The exact effect depends on the current event facility (language dependent). |
SET TASK/RESTORE | Restores a task's priority. The exact effect depends on the current event facility (language dependent). |
SET TASK/[NO]HOLD | Controls task switching (task state transitions, see Section 17.5.1). |
SET TASK/TIME_SLICE | Controls the time slice value or disable time slicing (see Section 17.5.2); supported for VAX Ada only, and not with POSIX Threads. |
For more information, see the SET TASK command description.
17.5.1 Putting Tasks on Hold to Control Task Switching
Task switching might be confusing when you are debugging a program. Placing a task on hold with the SET TASK/HOLD command restricts the state transitions the task can make once the program is subsequently allowed to execute.
A task placed on hold can enter any state except the RUNNING state. If necessary, you can force it into the RUNNING state by using the SET TASK/ACTIVE command.
The SET TASK/HOLD/ALL command freezes the state of all tasks except the active task. You can use this command in combination with the SET TASK/ACTIVE command, to observe the behavior of one or more specified tasks in isolation, by executing the active task with the STEP or GO command, and then switching execution to another task with the SET TASK/ACTIVE command. For example:
DBG> SET TASK/HOLD/ALL DBG> SET TASK/ACTIVE %TASK 1 DBG> GO . . . DBG> SET TASK/ACTIVE %TASK 3 DBG> STEP . . . |
When you no longer want to hold a task, use the SET TASK/NOHOLD command.
17.5.2 Debugging Programs That Use Time Slicing (VAX Ada Only)
Tasking programs that use time slicing are difficult to debug because time slicing makes the relative behavior of tasks asynchronous. Without time slicing, task execution is determined solely by task priority; task switches are predictable and the behavior of the program is repeatable from one run to the next. With time slicing, task priorities still govern task switches, but tasks of the same priority also take turns executing for a specified period of time. Thus, time slicing causes tasks to execute more independently from each other, and the behavior of a program that uses time slicing might not be repeatable from one run of the program to the next.
The SET TASK/TIME_SLICE=t command (supported for VAX Ada only) enables you to specify a new time slice or disable time slicing (with SET TASK/TIME_SLICE=0.0). Thus, you can tune the execution of your tasking programs or diagnose problems that depend on the order in which tasks execute.
The SET TASK/TIME_SLICE command is supported for VAX Ada only, and not for VAX Ada with POSIX Threads. If you use the command in an unsupported context, the debugger issues the following error message:
|
Note that there is an interaction between time slicing and the debugger
watchpoint implementation. When you set watchpoints, the debugger might
automatically increase the value of the time-slice interval to 10.0
seconds. Slowing the time-slice rate prevents some problems.
17.6 Controlling and Monitoring Execution
The following sections explain how to do the following functions:
An eventpoint is an event that you can use to return control to the debugger. Breakpoints, tracepoints, watchpoints, and the completion of STEP commands are eventpoints.
A task-independent eventpoint can be triggered by the execution of any task in a program, regardless of which task is active when the eventpoint is set. Task-independent eventpoints are generally specified by an address expression such as a line number or a name. All watchpoints are task-independent eventpoints. The following are examples of setting task-independent eventpoints:
DBG> SET BREAK COUNTER DBG> SET BREAK/NOSOURCE %LINE 55, CHILD$TASK_BODY DBG> SET WATCH/AFTER=3 KEEP_COUNT |
A task-specific eventpoint can be set only for the task that is active when the command is entered. A task-specific eventpoint is triggered only when that same task is active. For example, the STEP/LINE command is a task-specific eventpoint: other tasks might execute the same source line and not trigger the event.
If you use the SET BREAK, SET TRACE, or STEP commands with the following qualifiers, the resulting eventpoints are task specific:
/BRANCH
/CALL
/INSTRUCTION
/LINE
/RETURN
/VECTOR_INSTRUCTION (VAX only)
Any other eventpoints that you set with those commands and any eventpoints that you set with the SET WATCH command are task independent. The following are examples of setting task-specific eventpoints:
DBG> SET BREAK/INSTRUCTION DBG> SET TRACE/INSTRUCTION/SILENT DO (EXAMINE KEEP_COUNT) DBG> STEP/CALL/NOSOURCE |
You can conditionalize eventpoints that are normally task-independent to make them task specific. For example:
DBG> SET BREAK %LINE 11 WHEN (%ACTIVE_TASK=FATHER) |
You can set a breakpoint on a thread start routine. The breakpoint will trigger just before the start routine begins execution. In Example 17-1, this type of breakpoint is set as follows:
DBG> SET BREAK worker_routine |
Unlike Ada tasks, you cannot specify the body of a POSIX Threads task by name but the start routine is similar.
Specifying a WHEN clause with the SET BREAK command ensures that you catch the point at which a particular thread begins execution. For example:
DBG> SET BREAK worker_routine - _DBG> WHEN (%ACTIVE_TASK = %TASK 4) |
In Example 17-1, this conditional breakpoint will trigger when the second worker thread begins executing its start routine.
Other useful places to set breakpoints are just prior to and immediately after condition waits, joins, and locking of mutexes. You can set such breakpoints by specifying either a line number or the routine name.
Previous | Next | Contents | Index |
privacy and legal statement | ||
4538PRO_036.HTML |