#include #include static arm_id_t app_id; static arm_id_t tran_id; static arm_app_start_handle_t app_handle; static void registerApp (void) { /* -------------------------- 1. step -------------------------- */ /* Register application class with ARM agent. */ arm_register_application("C Introduction Tutorial", ARM_ID_NONE, ARM_FLAG_NONE, ARM_BUF4_NONE, &app_id); /* Register transaction class with ARM agent. */ arm_register_transaction(&app_id, "Hello Transaction", ARM_ID_NONE, ARM_FLAG_NONE, ARM_BUF4_NONE, &tran_id); /* -------------------------- 2. step -------------------------- */ /* Now start the application instance for the ARM agent. */ arm_start_application(&app_id, "Tutorials", ARM_STRING_NONE, ARM_FLAG_NONE, ARM_BUF4_NONE, &app_handle); } static void removeApp (void) { /* -------------------------- 4. step -------------------------- */ /* Stop the application instance. */ arm_stop_application(app_handle, ARM_FLAG_NONE, ARM_BUF4_NONE); /* -------------------------- 5. step -------------------------- */ /* Destroy all registered metadata. */ arm_destroy_application(&app_id, ARM_FLAG_NONE, ARM_BUF4_NONE); } static void hello_world (void) { arm_tran_start_handle_t tran_handle; /* -------------------------- 3. step -------------------------- */ /* Now start the transaction measurement. */ arm_start_transaction(app_handle, &tran_id, ARM_CORR_NONE, ARM_FLAG_NONE, ARM_BUF4_NONE, &tran_handle, ARM_CORR_NONE); /* Real transaction takes place here! */ printf("Hello world!\n"); /* Stop the measurement and commit the transaction to ARM. */ arm_stop_transaction(tran_handle, ARM_STATUS_GOOD, ARM_FLAG_NONE, ARM_BUF4_NONE); } static void appLoop (void) { int i; registerApp (); for (i = 0; i < 100000; i++) hello_world (); removeApp (); } int main(int argc, char *argv[]) { int rc = 0; while (1) appLoop(); return rc; }