problem starting a rtems task
Martínez, Pablo
pabloa.mar at gmail.com
Fri Jun 27 15:54:01 UTC 2014
On 27 June 2014 12:41, Joel Sherrill <joel.sherrill at oarcorp.com> wrote:
>
> On 6/27/2014 9:44 AM, Martínez, Pablo wrote:
>
>
>
>
> On 26 June 2014 18:54, Joel Sherrill <joel.sherrill at oarcorp.com> wrote:
>
>>
>> On 6/26/2014 4:48 PM, Martínez, Pablo wrote:
>>
>>
>>
>>
>> On 26 June 2014 18:28, Chris Johns <chrisj at rtems.org> wrote:
>>
>>> On 26/06/2014 11:54 pm, Martínez, Pablo wrote:
>>>
>>>>
>>>>
>>>>
>>>> On 26 June 2014 08:37, Chris Johns <chrisj at rtems.org
>>>> <mailto:chrisj at rtems.org>> wrote:
>>>>
>>>>
>>>>
>>>> On 26/06/2014 12:56 am, Martínez, Pablo wrote:
>>>>
>>>> Hi,
>>>>
>>>> Im having troubles trying to use the class rtemsTask from the
>>>> the
>>>> librtems++.
>>>>
>>>> (
>>>>
>>>> https://github.com/atgreen/__RTEMS/blob/master/c/src/__librtems%2B%2B/include/rtems%__2B%2B/rtemsTask.h
>>>>
>>>> <
>>>> https://github.com/atgreen/RTEMS/blob/master/c/src/librtems%2B%2B/include/rtems%2B%2B/rtemsTask.h
>>>> >
>>>> )
>>>>
>>>> This class is basically a wrapper for the rtems task api.
>>>>
>>>> I can create the task successfully (its returns 0), but when I
>>>> call
>>>> start() the entry point origin doesnt start despite returning 0
>>>> (this
>>>> method just write a memory position to check if the task is
>>>> working).
>>>>
>>>>
>>>> const rtems_status_code rtemsTask::start(const
>>>> rtems_task_argument arg)
>>>>
>>>>
>>>> {
>>>> if (owner)
>>>>
>>>>
>>>> {
>>>> argument = arg;
>>>>
>>>>
>>>> // pass the this pointer as the argument
>>>> set_status_code(rtems_task___start(id,
>>>> origin,
>>>> (rtems_task_argument) this));
>>>>
>>>>
>>>> }
>>>> else
>>>> set_status_code(RTEMS_NOT___OWNER_OF_RESOURCE);
>>>>
>>>> return last_status_code();
>>>>
>>>>
>>>> }
>>>>
>>>> Any help?
>>>>
>>>>
>>>> Are the priorities ok ? If not it might not be able to run.
>>>>
>>>>
>>>> Im using this parameters to create the task:
>>>>
>>>> "SELF"
>>>> 1 (priority)
>>>> RTEMS_MINIMUM_STACK_SIZE
>>>> RTEMS_NO_PREEMPT
>>>> 0
>>>> RTEMS_NO_FLOATING_POINT
>>>> RTEMS_LOCAL
>>>>
>>>>
>>>> In C implementation is working fine, but the problem comes with C++.
>>>>
>>>>
>>> I would need a more complete example to know what is happening.
>>>
>>>
>> Chris,
>>
>> Im trying to use the rtems++ library as follows:
>>
>>
>> //////////////Tempo.h
>>
>> #ifndef TEMPO_H_
>> #define TEMPO_H_
>>
>> #include <rtems++/rtemsTask.h>
>> #include <rtems++/rtemsTaskMode.h>
>>
>> class Tempo: public rtemsTask
>> {
>> public:
>> Tempo(const char* name,
>> const rtems_task_priority initial_priority,
>> const uint32_t stack_size,
>> const rtems_mode preemption = RTEMS_NO_PREEMPT,
>> const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
>> const rtems_mode asr = RTEMS_NO_ASR,
>> const rtems_interrupt_level interrupt_level = 0,
>> const FloatingPoint floating_point = fpoff,
>> const Scope scope = local);
>>
>> virtual ~Tempo();
>> //rtems_task origin(rtems_task_argument argument);
>>
>> const rtems_status_code start(const rtems_task_argument argument);
>> static rtems_task origen(rtems_task_argument argument);
>> void cuerpo(rtems_task_argument argument);
>>
>> private:
>>
>> // task name
>> rtems_name name;
>> char name_str[5];
>>
>> // owner, true if this object owns the task
>> // will delete the task when it destructs
>> bool owner;
>>
>> // the rtems id, object handle
>> rtems_id id;
>>
>> // the argument for the task, this class uses the actual argument
>> // passed to RTEMS
>> rtems_task_argument argument;
>>
>> };
>>
>> #endif /* TEMPO_H_ */
>>
>>
>> //////////////Tempo.cpp
>>
>> #include "Tempo.h"
>>
>> Tempo::Tempo(const char* tname,
>> const rtems_task_priority initial_priority,
>> const uint32_t stack_size,
>> const rtems_mode preemption,
>> const rtems_mode timeslice,
>> const rtems_mode asr,
>> const rtems_interrupt_level interrupt_level,
>> const FloatingPoint floating_point,
>> const Scope scope)
>> : name(rtems_build_name('S', 'E', 'L', 'F')),
>> owner(true),
>> id(RTEMS_SELF),
>> argument(0)
>> {
>> strcpy(name_str, "SELF");
>> create(tname,
>> initial_priority,
>> stack_size,
>> preemption,
>> timeslice,
>> asr,
>> interrupt_level,
>> floating_point,
>> scope);
>> }
>>
>>
>> Tempo::~Tempo()
>> {
>> }
>>
>>
>> const rtems_status_code Tempo::start(const rtems_task_argument arg)
>> {
>>
>> argument = arg;
>> // pass the this pointer as the argument
>> set_status_code(rtems_task_start(id,origen,(rtems_task_argument)
>> this));
>>
>> printf (" ---Tempo::start --- \n\n");
>>
>> return last_status_code();
>> }
>>
>>
>> rtems_task Tempo::origen(rtems_task_argument argument)
>> {
>> //just for debugging:
>> unsigned *regout;
>> regout= (unsigned*)0x80000d04;
>> (*regout)=0x12345678;
>>
>> printf (" --- Tempo::origen --- \n\n");
>>
>> Tempo *task = (Tempo*) argument;
>> task->cuerpo(task->argument);
>>
>> }
>>
>> void Tempo::cuerpo(rtems_task_argument )
>> {
>> printf (" --- Tempo::do sth --- \n\n");
>> }
>>
>>
>> ::::::::::
>>
>> " ---Tempo::start --- \n\n" gets printed, but origen() is not triggered.
>>
>>
>> Trying to solve this out, Im trying with one solution I just found
>> (from you!)
>> You use a thread template. I just found it so I haven't tested it yet.
>>
>> http://comments.gmane.org/gmane.os.rtems.user/20625
>>
>>
>> This is still not complete. There has to be an initialization task and
>> some RTEMS configuration (e.g. CONFIGURE_xxx followed by
>> an include of <rtems/confdefs.h>).
>>
>> My first guess is that you have an Init task at priority 1 sitting
>> in a loop watching for something to happen. It won't happen
>> because it never yields the processor.
>>
>> An alternative is that the Init() task falls off the bottom of its
>> body and this is a fatal error halting the system.
>>
>> If we saw the Init() and configuration that goes with this
>> it would really help. Something invokes your Tempo
>> constructor.
>>
>> --joel
>>
>>
> #define CONFIGURE_INIT
>
> #include <rtems.h>
> #include <rtems++/rtemsTask.h>
> #include <rtems++/rtemsTaskMode.h>
> #include </opt/rtems-4.10/sparc-rtems4.10/leon3/lib/include/bsp.h> /* for
> device driver prototypes */
> #include <tmacros.h>
>
> extern "C"
> {
> rtems_task Init(
> rtems_task_argument argument
> );
> }
>
>
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_MAXIMUM_TASKS 10
>
> #define CONFIGURE_MAXIMUM_TIMERS 5
> #define CONFIGURE_MAXIMUM_SEMAPHORES 5
>
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_INIT_TASK_STACK_SIZE (6 * RTEMS_MINIMUM_STACK_SIZE)
> #define CONFIGURE_EXTRA_TASK_STACKS (13 * RTEMS_MINIMUM_STACK_SIZE)
> //#include
> </opt/rtems-4.10/sparc-rtems4.10/leon3/lib/include/rtems/confdefs.h>
> #include <rtems/confdefs.h>
>
> #include "Tempo.h"
>
> rtems_task Init(rtems_task_argument )
> {
> printf (" --- Rtems++ V 1.1 --- \n\n");
>
> Tempo
> t1("SELF",1,RTEMS_MINIMUM_STACK_SIZE,RTEMS_NO_PREEMPT,0,RTEMS_NO_FLOATING_POINT,RTEMS_LOCAL);
>
> printf("Tempo::initial status: %d \n",t1.last_status_code());
> printf("Tempo::started: %d \n",t1.start(1));
> printf (" --- FIN --- \n\n");
> exit(0);
> }
>
>
> Using grmon I can see the program exits normally.
>
> Yep. exit(0) shuts down the entire program including all threads.
> Nothing
> runs after exit(0) is called.
>
> Try rtems_task_delete( RTEMS_SELF ) which only deletes the executing thread
> and does not shut down the application.
>
>
That was the problem! Thank you guys. Feel a bit fool now!
cheers,
Pablo
> Pablo
>
>
>
>>
>>
>> cheers,
>> Pablo
>>
>>
>>
>>> Chris
>>>
>>> thank u,
>>>> P
>>>>
>>>>
>>>>
>>>> Chris
>>>>
>>>> best regards,
>>>>
>>>>
>>>>
>>>> --
>>>> Martínez, Pablo Agustín
>>>>
>>>>
>>>> _________________________________________________
>>>> users mailing list
>>>> users at rtems.org <mailto:users at rtems.org>
>>>> http://lists.rtems.org/__mailman/listinfo/users
>>>> <http://lists.rtems.org/mailman/listinfo/users>
>>>>
>>>> _________________________________________________
>>>> users mailing list
>>>> users at rtems.org <mailto:users at rtems.org>
>>>> http://lists.rtems.org/__mailman/listinfo/users
>>>>
>>>> <http://lists.rtems.org/mailman/listinfo/users>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Martínez, Pablo Agustín
>>>>
>>>
>>
>>
>> --
>> Martínez, Pablo Agustín
>>
>>
>> --
>> Joel Sherrill, Ph.D. Director of Research & Developmentjoel.sherrill at OARcorp.com On-Line Applications Research
>> Ask me about RTEMS: a free RTOS Huntsville AL 35805
>> Support Available (256) 722-9985
>>
>>
>
>
> --
> Martínez, Pablo Agustín
>
>
> --
> Joel Sherrill, Ph.D. Director of Research & Developmentjoel.sherrill at OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
>
>
--
Martínez, Pablo Agustín
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20140627/96448990/attachment-0002.html>
More information about the users
mailing list