1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

<INTEGRITY RTOS> Passing arguments to an entry point function of the CreateTask() task kernel call

Discussion in 'Embedded' started by Alex Vinokur, Feb 26, 2006.

  1. Alex Vinokur

    Alex Vinokur Guest

    =============
    INTEGRITY RTOS
    =============
    Task kernel calls CreateTask(), CommonCreateTask(), CreateANSICTask(),
    CreateProtectedTask() contain several arguments. One of them is the
    entry point function.

    Can that (entry point) function have arguments? How to pass these
    arguments to the entry point function while calling CreateTask() and
    similar task kernel calls.
     
    Alex Vinokur, Feb 26, 2006
    #1
    1. Advertisements

  2. Alex Vinokur

    Richard Guest

    I have never used Integrity RTOS but I'm sure the answers to your questions
    are very easy to find in the manuals and examples that surely come with your
    purchase. You do have the manuals?

    I would be very surprised if the answer to your question "Can that function
    have arguments" was "no".

    Regards,
    Richard.

    http://www.FreeRTOS.org
     
    Richard, Feb 26, 2006
    #2
    1. Advertisements

  3. No, it can't have arguments. But you can associate an address with the
    task using Get/SetTaskIdentification; that address can point to a
    structure containing the arguments (like in Win32 or pthreads, where you
    also can pass a single pointer only, not arbitrary arguments).


    Stefan
     
    Stefan Reuther, Feb 26, 2006
    #3
  4. Alex Vinokur

    Alex Vinokur Guest

    Thank you.

    It works quite fine.

    Here is an example:

    ====== foo.c ======
    /* INTEGRITY RTOS */

    #include "INTEGRITY.h"
    #include <stdio.h>

    void CHECK(Error TheError)
    {
    if (TheError) HaltTask(CurrentTask());
    }

    void entry_point()
    {
    Address TheAddress;
    Error TheError = GetTaskIdentification(CurrentTask(),&TheAddress);
    if (TheError == Success)
    {
    printf("Success -> GetTaskIdentification returned %s\n", TheAddress);
    }
    else
    {
    printf("Failure -> GetTaskIdentification returned Error=%d\n",
    TheError);

    }
    Exit(0);
    }


    int main()
    {
    Task task;
    char* ptr = "ABCDXYZ";

    CHECK (CreateProtectedTask(1, (Address)entry_point, 0x1000,
    "the-task", &task));
    CHECK (SetTaskIdentification(task, (Address)ptr));

    CHECK (RunTask(task));

    exit(0);
    }


    ===================



    ===== Output ======

    Success -> GetTaskIdentification returned ABCDXYZ

    ===================

    Alex Vinokur
    email: alex DOT vinokur AT gmail DOT com
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn
     
    Alex Vinokur, Feb 26, 2006
    #4
  5. Alex Vinokur

    Alex Vinokur Guest

    Alex Vinokur wrote:
    [snip]
    CHECK (CloseProtectedTask(task));
     
    Alex Vinokur, Feb 27, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.