RES: passing parameters to task

Wendell Pereira da Silva wendell.silva at
Mon Sep 17 12:35:08 UTC 2012

Hi Luca,

Mathew, please, may I post an example?

rtems_task mytask(rtems_task_argument arg);


struct complex_task_parameters
   uint32_t ui;  // first parameter...
   uint16_t usi; // second parameter...
   const char* foo;  // another parameter...

rtems_task Init(rtems_task_argument arg)
   rtems_id tid;
   struct complex_task_parameters* p_task_param;

   // allocate and initialize parameters
   p_task_param = calloc(1, sizeof(*p_task_param));
   p_task_param->ui = 1;
   p_task_param->usi = 0x1000;
   p_task_param->foo = "test...";

   // create the task as usual
   rtems_task_create(..., &tid);

   // now pass the parameter to the task;
   // use typecast to make the compiler happy.
   rtems_task_start(tid, mytask, (rtems_task_argument)p_task_param);


rtems_task mytask(rtems_task_argument arg)
   struct complex_task_parameters* p;

   p = (complex_task_parameters *)arg;

      //use parameters in p

Hope it helps.


De: rtems-users-bounces at [mailto:rtems-users-bounces at] Em nome de Luca Cinquepalmi
Enviada em: segunda-feira, 17 de setembro de 2012 07:20
Para: Mathew Benson
Cc: rtems-users at
Assunto: Re: passing parameters to task

I understand your suggestion... is there any example I could view?


Il 17/09/2012 12.18, Mathew Benson ha scritto:
The same way you would with a POSIX pthread create call.  Just malloc a struct with your multiple parameters, set your parameters, and pass the reference of your struct to the function.  In your task entry point, cast the argument to a pointer to your struct and pull your parameters out.

Sent from my Amiga 1000

On Sep 17, 2012, at 4:35 AM, Luca Cinquepalmi <cinquepalmi at<mailto:cinquepalmi at>> wrote:
Hi all,
I would like to know if is it possible to pass more than one argument to a single task...
At the moment I only use this syntax when I define a task

rtems_task Test_task(rtems_task_argument unused)

How can I declare and define a more parameters dependent task?
Thanks a lot.


rtems-users mailing list
rtems-users at<mailto:rtems-users at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list