Thread: OSCreateTask Help with a stack size question.

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    30

    OSCreateTask Help with a stack size question.

    Hi I am recently new to programming, just a quick question on what exactly stack size is? Is that how many bits will be used if it is held in a queve? or is it the order it should be done? I am using Salvo for a Cube Sat kit. And dspic33 microcontroller. MPLAB is my programming/debugging software. I am using OSCreatTask(Task, Arg, stacksize). Another question is what does the argument mean? here is a sample code I am working off of. Thank you in advance for your time.

    code[]
    // Create tasks.
    OSCreateTask(task_led, TASK_LED_P, 3);
    OSCreateTask(task_sd_append, TASK_SD_APPEND_P, 11);
    OSCreateTask(task_sd_measure, TASK_SD_MEASURE_P, 7);
    code[/]

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    the stack is the area of memory used for things like local variables and function calls. each time you call a function, some data is pushed on to the stack including the return address for the function. some space on the stack may be allocated for local variables. you can look at the stack as a linear array of memory that starts with a pointer pointing to the highest address in the array. every time a function is called, the required data is pushed on to the stack and the pointer is moved down. then inside the function if there are local variables the pointer is moved down by enough to make room for those. when a function returns the pointer is moved back up to deallocate the memory.

    Call stack - Wikipedia, the free encyclopedia

    in any case, your stack size argument will be in bytes, not bits, and it needs to be reasonably sized. it all depends on your application and system, but values like 3,11 and 7 are WAY too small. something in the hundreds or thousands of bytes would be needed in most cases.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    You could at least provide us with a link to some documentation (wait, we did this sketch in your other thread). It's not like anyone here is an instant reference manual for any random function name you care to come up with.

    In your previous thread, you declared
    void task_sd_measure(void)
    so I don't know what you're supposed to do with the parameter.

    If it follows the pthread model, then the single parameter is a pointer, and you would declare
    void task_sd_measure(void *arg)

    From the look of things, TASK_SD_MEASURE_P is a macro of some sort, but that's just a guess - again, more vagueness.

    Code:
    OSCreateTask(task_led, TASK_LED_P, 3);
    OSCreateTask(task_sd_append, TASK_SD_APPEND_P, 11);
    OSCreateTask(task_sd_measure, TASK_SD_MEASURE_P, 7);
    As dmh2000 notes, the stack sizes can't be bytes.
    Best guess (in other words, you should read the manual), the stack size is n * some basic block size (somewhere between 256 bytes and 1Kbytes looks plausible).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Feb 2013
    Posts
    30
    I am not asking about the code. I am simply asking what the stack size is meaning. Thank you dmh2000, this code is just to give you an idea of why I needed to know stack size. That is just some piece of pumpkins code they have available. As for salem. I was not asking anything about the function? I was simply asking about the call stack, don't get all hostile haha. And thank you for the info on what the P is meaning in there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to calculate the Stack Size?
    By shwetha_siddu in forum C Programming
    Replies: 32
    Last Post: 06-25-2008, 07:59 AM
  2. Determine a function's stack size.
    By koodoo in forum C Programming
    Replies: 6
    Last Post: 06-11-2007, 12:31 PM
  3. Stack Size
    By siavoshkc in forum C++ Programming
    Replies: 15
    Last Post: 03-01-2006, 11:39 AM
  4. Stack size
    By MadCow257 in forum C++ Programming
    Replies: 7
    Last Post: 03-17-2005, 12:29 PM
  5. What fgures into my stack size? heap?
    By sean in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 02-07-2002, 03:46 AM