Step 5 : ARM 4.0 C Hello World example

Description

Now that we have registered all meta data and started the application instance. It is time to start the real transaction measurement:

  1. We also need a transaction start handle to be able to stop the transaction measurement later. Therefore we need the
    arm_tran_start_handle_t tran_handle;
    variable.
  2. Now we can start our transaction measurement with the arm_start_transaction() call. We pass the following parameters:
    1. pointer to application start handle so ARM knows in which application context this transaction is executed.
    2. pointer to the transaction ID returned by a previous call to arm_register_transaction().
    3. ARM_CORR_NONE - We have no parent transaction therefore no correlator.
    4. ARM_FLAG_NONE - we just ignore any flags for now.
    5. ARM_BUF4_NONE - it is a simple example, so no optional data is passed.
    6. pointer to our tran_handle variable where the agent stores the transaction start handle for our measurement.
    7. ARM_CORR_NONE - we need no correlator for our transaction.

Code

01: #include <stdio.h>
02: #include "arm4.h"
03: 
04: int main(int argc, char *argv[])
05: {   
06:    arm_id_t app_id;
07:    arm_id_t tran_id;
08:    arm_app_start_handle_t app_handle;
09:    arm_tran_start_handle_t tran_handle;
10:    arm_register_application("HelloWorldApp", ARM_ID_NONE,
11:                              ARM_FLAG_NONE, ARM_BUF4_NONE,
12:                              &app_id);
13:    arm_register_transaction(&app_id, "HelloWorldTran", ARM_ID_NONE,
14:                              ARM_FLAG_NONE, ARM_BUF4_NONE,
15:                              &tran_id);
16:    arm_start_application(&app_id, "Tutorial", NULL,
17:                           ARM_FLAG_NONE, ARM_BUF4_NONE,
18:                           &app_handle);
19:    arm_start_transaction(app_handle, &tran_id, ARM_CORR_NONE,
20:                            ARM_FLAG_NONE, ARM_BUF4_NONE,
21:                            &tran_handle, ARM_CORR_NONE);
22:    printf("Hello world!\n");
23:    return 0;
24: }