Barr Group FacebookBarr Group TwitterBarr Group LinkedInBarr Group Vimeo

Rules

The following C coding rules relate to the representation of tasks (a.k.a., threads):

Rule 6.4.a.) All functions that represent tasks (a.k.a., threads) shall be given names ending with _task().

Example

void
alarm_task (void * p_data)
{
    alarm_t  alarm = ALARM_NONE;
    uint8_t   err     = OS_NO_ERR;

    for (;;)
    {
        alarm = OSMboxPend(alarm_mbox, &err);
        // Process alarm here.
    }
}

Reasoning

Each task in a real-time operating system (RTOS) is like a mini-main(), typically running forever in an infinite loop. It is valuable to easily identify these important functions during code reviews and debugging sessions.

Exceptions

Alternatively, _thread() may be used to end the function name.

Enforcement

This naming convention shall be enforced during the detailed design phase and in code reviews.

What’s happening and how it’s done. Get in the know.

Sign up for our newsletter today!

Receive free how-to articles, industry news, and the latest info on Barr Group webinars and training courses via email. 

To prevent automated spam submissions leave this field empty.