Select Page

Threads Assignment 1

► Launch Code Composer Studio
► Import atomthreads Template Project into the current workspace
►Rename the Project as atomthreads_threads_assignment_one
►Launch Serial terminal emulator (minicom, gtkterm,etc) and configure for 115200,8,1,N
►Create two threads (Task1 and Task2) with equal priorities. Task1 should display the string “Task 1 is Running …” and Task2 should display the string “Task 2 is Running …”.
►After Displaying the string, introduce a small (software) Delay;

void Taskn(uint32_t entry_param)
{
    while(1) { 
        printf("%s", "Task n is Running ..."); 
        for( auto int32_t ul = 0; ul < 3180; ul++ ) { ; }
    }
}
  • Observe which Tasks strings Displayed and Why?
  • Change Tasks priorities and Observe
  • Delay generated using a null loop
    the task effectively polled an incrementing loop counter until it reached a fixed value.
  • Disadvantages to any form of polling
    While executing the null loop, the task remains in the Ready state, ‘starving’ the other task of any processing time.
    During polling, the task does not really have any work to do, but it still uses maximum processing time and so wastes processor cycles.
  • Replace the polling null loop with a call to atomTimerDelay(); API function corrects this behavior.

    References

    1. Introduction to atomthreads
    2. atomthreads kernel Reference
    3. atomthreads Documentation