• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Embedded Software » BIOS » BIOS forum » What is the purpose of a Task Stack?
Share
BIOS
  • Forum
  • Announcements
Options
  • Subscribe via RSS

What is the purpose of a Task Stack?

What is the purpose of a Task Stack?

This question is answered
Naveed Hassan
Posted by Naveed Hassan
on Jun 25 2012 04:47 AM
Prodigy100 points

Hi, I have been reading different documents on this subject and none of them have managed to explain the following:

A. When exactly is a Task stack created? (e.g. when I enter a task, when I post it, or when I am exiting it. Some tutorial said that it is created for storing the context when the TASK IS BEING EXECUTED. I don't quite get why you need to make a stack for that if the variables are already global)

B. What exactly are the contents of such a stack.

C. If I am calling x number of functions from within a task, how does that affect the task stack

I am using the following:

DM6446 (custom board)

Xds560 emulator

CodeComposer Studio v3.3

DSP/BIOS RTOS

task stack stack overflow CodeComposer v3.3 DSP/BIOS RTOS
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Scott Gary
    Posted by Scott Gary
    on Jun 26 2012 18:11 PM
    Verified Answer
    Verified by Naveed Hassan
    Genius10040 points

    Naveed,

    A. A task’s stack is allocated when the task is created.

    Yes, a task’s stack holds context for the task execution.  When a task is preempted by another task, or if the task blocks (for example, with a SEM_pend()), then the task’s context is *maintained* on its stack until the task executes again.  

    A task can use both global variables (that aren’t maintained in the task’s stack), or it can use task-local variables, that are maintained on the task’s stack.

    B. The context on the task's stack is local variables for the task’s function, as well as the execution stack for any other functions that the task’s function calls.

    C. As you call functions they will consume space on the task’s stack.  If you call them one at a time, the task stack depth will rise/fall for each function call.  If you have functions that call other functions, the depth will increase with each nested function call.  The space required for each task can vary, and can be specified during task creation.  Usually a larger stack size will be allocated to begin with, and then tuned downward later in development as stack size requirements are determined.

    Scott

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Naveed Hassan
    Posted by Naveed Hassan
    on Jun 27 2012 04:14 AM
    Prodigy100 points

    Thanks a lot for the helpful information. I still seem to be stuck.

    Background:

    I am running audio compression (MELP) in a task that is posted from the interrupt routine that is catering for interrupts from the DMA. The DMA is linked with the ASP and is configured for interrupting after every 2ms. Each data sample collected after 2ms has 16 good voice samples, each 16 bits wide.

    Once 180 (or more) samples are collected, the task is posted. This seemed to run fine.

    It takes exactly 22.5ms to collect 180 samples and the compressor takes, averaging, 21~21.5 ms. So the realtimeness is not hurt.

    The task is structured as follows:

    The task calls a copy function and then calls the compressor on the copied data. The compressor nests function calls to up to 4 levels.

    Problem:

    I had to optimize the code further so I configured the DMA to interrupt me every 125 us (microseconds). The problem I am facing now is that the entire code crashes and the reason, as far as I have been able to figure out, is that the stack for the compressor task overflows.

    The only effect of increasing the interrupt rate on this task is that now it is preempted 16 times more than before.

    The effective function calls, task posts and nesting have not changed.

    What could be causing this issue?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Scott Gary
    Posted by Scott Gary
    on Jun 27 2012 11:03 AM
    Genius10040 points

    Naveed,

    Can you describe how you are configuring and handling the DMA interrupt?  Are you using the HWI dispatcher or the HWI_enter/HWI_exit macros?

    Scott

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use