Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    xTaskCreate versus CmdProcessor_Enqueue

    sunstos
    New Poster

    xTaskCreate versus CmdProcessor_Enqueue

    Hi,

    in the provided sample applications in the Workbench I can see that the AppController follows this structure:

     

    void AppController_Init(void * cmdProcessorHandle, uint32_t param2)
    {
    ...
            retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerSetup, NULL, UINT32_C(0));
    ...
    }
    void AppControllerSetup(void * cmdProcessorHandle, uint32_t param2)
    {
    ...
            retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerEnable, NULL, UINT32_C(0));
    ...
    }
    void AppControllerEnable(void * cmdProcessorHandle, uint32_t param2)
    {
    ...
           xTaskCreate(AppControllerFire, (const char * const ) "AppController", TASK_STACK_SIZE_APP_CONTROLLER, NULL, TASK_PRIO_APP_CONTROLLER, &AppControllerHandle))
    ...
    }
    static void AppControllerFire(void* pvParameters)
    {
    ...
           //Application logic
    ...
    }

     

    I have two question concerning this structure:

    1) What is the benefit of "isolating" every function in a separate "CmdProcessor_Enqueue" call, instead of directly call "AppControllerSetup" in "AppController_Init" and so on?

    2) Why is "AppControllerSetup" created as a task rather than enqueued through  "CmdProcessor_Enqueue" ? What is the benefit of this?

    I checked as well the documentation: https://developer.bosch.com/web/xdk/cmdprocessor but could not find some hint.

    Kind regards Christof

    1 REPLY 1
    Padmapriya
    Long-established Member

    Re: xTaskCreate versus CmdProcessor_Enqueue

    Hello Sunstos,

    Before answering your question, I would like to highlight about the XDK application. The applications provided in XDK workbench can run on XDK hardware and are template applications; meaning- user can extend one's idea in the existing application.

    There is no hardcore rule to follow the same application structure and user has the freedom to use custom structure (like you mentioned direct function call) considering the performance risk.

    What is the benefit of "isolating" every function in a separate "CmdProcessor_Enqueue" call, instead of directly call "AppControllerSetup" in "AppController_Init" and so on?

    1. Since XDK workbench v3.0, command processor was not used and timer was used instead. During which non-deterministic timing and instability was observed. Hence CmdProcessor was used to maintain a proper execution context for the application.
    2. There may arise a question, why not use task ?
    3. CmdProcessor is essentially a combination of the features task and queue. Compared to task, the CmdProcessor can call the same function with different parameters every time. User send functions to the CmdProcessor, which will then be processed by the internal task. This allows for more control of the environment in which a function will run, and provides a strict order of execution.

    Why is "AppControllerSetup" created as a task rather than enqueued through  "CmdProcessor_Enqueue" ? What is the benefit of this?

    1. I suppose you meant "AppControllerFire", since this function is called from task.
    2. Since the AppControllerFire of all XDK applications implement continuous loop like while(1), it is not advisable to enqueue this continuous loop function into queue(CmdProcessor). Reason being, this AppControllerFire will run continuously/periodically (depending on application) which will keep it busy  and interfere with the execution of other application functions. Hence used separate task for this type of continuous operations.

    Thank you,

    Padmapriya.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist