| Embedded IDE Link™ VS | ![]() |
| On this page… |
|---|
Along with real-time task execution profiling, the software enables you to determine how your application uses the processor system stack. Using the profile method, you can initialize and test the size and usage of the stack. This capability helps you optimize both the size of the stack and how your code uses the stack.
To provide stack profiling, profile writes a known pattern to the addresses in the stack. After you run your application for a while, and then stop your application, profile examines the contents of the stack addresses. profile counts each address that no longer contains the known pattern as used. The total number of address that have been used, compared to the total number of addresses you allocated, becomes the stack usage profile. This profile process does not tell you how often any address was changed by your application.
When you use profile to initialize and test the stack operation, the software returns a report that contains information about stack size, usage, addresses, and direction. With this information, you can modify your code to use the stack efficiently. The following program listing shows the stack usage results from running an application on a simulator.
profile(cc,'stack','report')
Maximum stack usage:
System Stack: 532/1024 (51.95%) MAUs used.
name: System Stack
startAddress: [512 0]
endAddress: [1535 0]
stackSize: 1024 MAUs
growthDirection: ascendingThe following table describes the entries in the report:
| Report Entry | Units | Description |
|---|---|---|
| System Stack | Minimum Addressable Unit (MAU) | Maximum number of MAUs used and the total MAUs allocated for the stack. |
| name | String for the stack name | Lists the name assigned to the stack. |
| startAddress | Decimal address and page | Lists the address of the stack start and the memory page. |
| endAddress | Decimal address and page | Lists the address of the end of the stack and the memory page. |
| stackSize | Addresses | Reports number of address locations, in MAUs, allocated for the stack. |
| growthDirection | Not applicable | Reports whether the stack grows from the lower address to the higher address (ascending) or from higher to lower (descending). |
To profile the system stack operation, perform these tasks in order:
Load an application.
Set up the stack to enable profiling.
Run your application.
Request the stack profile information.
Note If your application initializes the stack with known values when you run it, stack usage is reported as 100%. The value does not correctly reflect the stack usage. |
Follow these steps to profile the stack as your application interacts with it. In this example, cc is an existing adivdsp object.
Load the application to profile.
Use the profile method with the setup input keyword to initialize the stack to a known state.
profile(cc,'stack','setup')
With the setup input argument, profile writes a known pattern into the addresses that compose the stack. For all processors, the pattern is A5. As long as your application does not write the same pattern to the system stack, profile can report the stack usage correctly.
Run your application.
Stop your running application. Stack use results gathered from an application that is running may be incorrect.
Use the profile method to capture and view the results of profiling the stack.
profile(cc,'stack','report')
The following example demonstrates setting up and profiling the stack. The adivdsp object vd must exist in your MATLAB workspace and your application must be loaded on your processor. This example comes from a SHARC ADSP–2136x simulator.
profile(vd,'stack','setup') % Set up processor stack--write A5 to the stack addresses.
Maximum stack usage:
System Stack: 0/512 (0%) MAUs used.
name: System Stack
startAddress: [785920 1]
endAddress: [786431 1]
stackSize: 512 MAUs
growthDirection: ascending
run(vd)
halt(vd)
profile(vd,'stack','report')
Maximum stack usage:
System Stack: 91/512 (17.77%) MAUs used.
name: System Stack
startAddress: [785920 1]
endAddress: [786431 1]
stackSize: 512 MAUs
growthDirection: ascending
![]() | Real-Time Execution Profiling | Function Reference | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |