public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: LONY David <david.lony@pragmadev.com>
To: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Create a thread (uitron)
Date: Wed, 02 May 2007 13:15:00 -0000	[thread overview]
Message-ID: <46388F46.3070201@pragmadev.com> (raw)
In-Reply-To: <4635FF31.60609@pragmadev.com>

Hi all,

I succeded to create a uITRON thread!!!
My options :

"Number of tasks" --> 4
"Start tasks" -> 1
...
...
"Externs for initialization" ->
extern "C" void RTDS_Start( unsigned int ); \
extern "C" void task2( unsigned int ); \
extern "C" void task3( unsigned int ); \
extern "C" void task4( unsigned int ); \
static char stack1[ MAX(CYGNUM_UITRON_STACK_SIZE, 
CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack2[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack3[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack4[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ];

"Static initializers" ->
CYG_UIT_TASK( "t1", 1, RTDS_Start, &stack1, 
MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t2", &stack2, MAX(CYGNUM_UITRON_STACK_SIZE, 
CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t3", &stack3, MAX(CYGNUM_UITRON_STACK_SIZE, 
CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t4", &stack4, MAX(CYGNUM_UITRON_STACK_SIZE, 
CYGNUM_HAL_STACK_SIZE_MINIMUM) ),

So with these parameters I can use 3 ID (2,3 and 4) to create a miximum 
of 3 threads
Then to start the RTDS_Start thread I just have to call the 
cyg_uitron_start() function (see the main function below)....
But I cannot understand the behavior of my test program... I try to 
create another task in the main (it work well!!!) but if I do it on 
RTDS_Start it does not work!!!

This is my program :

#include <cyg/compat/uitron/uit_func.h>
#include <stdio.h>

void task2(unsigned int a)
{
  printf("In function test()\n");
}

void task1(unsigned int b)
{
 
  printf("Hello from task1\n");
}

void RTDS_Start()
{
  ID tid = 2;
  T_CTSK thread_attr;
  int retval;
 
  printf("Hello from RTDS_Start\n");
 
  thread_attr.stksz = 1000;
  thread_attr.itskpri = 5;
  thread_attr.task = (FP)&task2;
  retval = cre_tsk(tid, &thread_attr);
 
  if(retval != E_OK)
    {
      printf("Error in RTDS_Start %d !!!\n",retval);
    }
  else
    {
      printf("Good in RTDS_Start! \n");
      sta_tsk(tid,NULL);
    } 
}


int main()
{
  ID tid = 3;
  T_CTSK thread_attr;
  int retval;
 
  printf("In main\n");
  cyg_uitron_start();
 
  thread_attr.stksz = 1000;
  thread_attr.itskpri = 5;
  thread_attr.task = (FP)&task1;
  retval = cre_tsk(tid, &thread_attr);
 
  if(retval != E_OK)
    {
      printf("Error in main %d !!!\n",retval);
    }
  else
    {
      printf("Good in main! \n");
      sta_tsk(tid,NULL);
    }
  return 0;
}

Some ideas ?
PS : Does someone know the function of the 2nd argument in 
|*sta_tsk*|(ID tskid, INT stacd) function ?

Thanks a lot.
David


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

      parent reply	other threads:[~2007-05-02 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-30 14:36 LONY David
2007-04-30 14:47 ` Gary Thomas
2007-05-01 20:53   ` Daniel Morris
2007-05-02  9:16     ` David LONY
2007-05-02 13:15 ` LONY David [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46388F46.3070201@pragmadev.com \
    --to=david.lony@pragmadev.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).