Profiler Example Application
Overview
This is a simple profiler program designed for the NBRTOS (NetBurner Real-Time Operating System) that demonstrates task profiling capabilities. The application provides a menu-driven interface to monitor task execution times and system performance metrics.
Features
- Task Time Monitoring: Track execution time for individual tasks
- System Statistics: Display total system tick counts and timing information
- Real-time Counter: Shows a continuously updating counter display
- Web Server Integration: Includes HTTP server functionality
- Network Configuration: Automatic DHCP setup and network interface management
Profiling Functionality
The NBRTOS profiling system works by recording tick counts and tick fractions during task switching events. This allows the system to track how much CPU time each task consumes.
Key Profiling Functions
GetCurrentTaskTime(uint32_t *TotalTicks) - Returns the number of ticks the current task has run
ShowTaskTimes() - Prints a list of all tasks with their execution times and percentages
ClearTaskTimes() - Resets all task timing counters to zero
Menu Commands
The application provides an interactive menu system with the following commands:
- C - Get statistics on the current task (execution time and percentage)
- S - Show OS seconds counter and tick information
- T - Display statistics for all tasks in the system
- ? - Display the main menu
Setup and Configuration
Enabling Profiling
Profiling functionality requires the system to be built with NBRTOS_TIME defined. There are two ways to enable this:
Method 1: Using Overload Folder (Recommended)
Copy the provided overload folder into your application directory. This method is preferred as it only affects your specific application.
Method 2: System-wide Configuration
- Edit
\nburn\nbrtos\include\predef.h
- Uncomment the line:
#define NBRTOS_TIME(1)
Rebuild the system libraries
Note**: Method 2 affects all applications and adds overhead to the entire system.
Important Considerations
- Profiling adds computational overhead and should typically only be used during development
- The profiling feature is disabled by default for performance reasons
- When profiling is disabled, attempting to use profiling commands will display a warning message
Application Flow
- Initialization: The application initializes the network stack and starts the HTTP server
- Network Setup: Waits for DHCP completion and displays IP address information
- Main Loop: Continuously checks for user input while displaying an updating counter
- Command Processing: Handles user commands through a simple dispatcher system
Network Features
- DHCP Support: Automatic IP address configuration
- Web Server: Built-in HTTP server on port 80
- Interface Monitoring: Displays network interface information
- Connection Status: Shows current IP addresses and network configuration
Development Notes
- The application includes system diagnostics that should be removed for production code
- The counter display uses backspace characters to create an updating effect
- Error handling is included for cases where profiling features are not available
- The application waits up to 5 seconds for network activation
Output Examples
When profiling is enabled, you can expect output like:
Current Task Ticks: 12345, Total System Ticks: 100000, Percent: 12.35
Tick Count = 0x1A2B3C = 1715004 (171 seconds)
Compilation Requirements
- NBRTOS development environment
- Network libraries (ethervars, ipshow)
- Standard I/O system libraries (iosys)
- Initialization libraries (init)
Usage
- Compile and flash the application to your NetBurner device
- Connect via serial terminal
- Wait for network initialization to complete
- Use the menu commands to monitor system performance
- Press any key after each command display to return to the menu