Question about task scheduling and RTEMS target shell

Joel Sherrill joel.sherrill at OARcorp.com
Thu Jun 19 17:56:26 UTC 2003



mikeci at acm.org wrote:
> 
> Hi!
> 
> I have a following problem:
> 
> There are three tasks in the system:
> 
> TA1 - with priority 95 (highest). This task has a loop in which there is a
> call to rtems_wake_after(2)
> TA2 - with priority 100. This task has a loop in which there is a call to
> rtems_wake_after(0)
> TA3 - shell (it is a rtems shell found in libmisc) with priority 100. It
> call serial driver and loops until something is typed on the terminal.
> 
> Now, all three of them are created with RTEMS_PREEMPT and RTEMS_TIMESLICE.
> ---------------------------------------------------------------------------
> Also interesting is that when you run a "task" command in the shell, task
> flags are never changed and are always displayed as "P:T:nA". This is not
> correct, because default setting for a task should be "P:nT:A". There is
> also a bug in a shell:
> 
> in the function register_cmds this is a correct code:
> 
>         command = rtems_monitor_commands;
>         while(command->command)
>         {
>                 if(strcmp("exit", command->command))        /* Exclude
> EXIT (alias quit) */
>                         shell_add_cmd(command->command, "monitor",
> command->usage, main_monitor);
>                 command = command->next;
>         };
> 
> while command must check for command->command == NULL, otherwise you will
> have problems with strcmp comparing string with NULL. On my system this
> cause an exception.

Could you please provide a diff?

> ---------------------------------------------------------------------------
> Now description about the problem with tasks:
> 
> What hapens is that task 2 is never scheduled if its priority is 100. If I
> lower priority of the shell to 101 then shell is never scheduled. Can you
> give me sugestions on how to solve this problem?

That's the defined behavior.  rtems_task_wake_after(0) only yields to
tasks of equal or greater importance.  See this for more info:

http://www.oarcorp.com/rtemsdoc-current/html/c_user/c_user00060.html

The paragraph of interest is:

=============
A task calling the rtems_task_wake_after directive with a delay interval
of RTEMS_YIELD_PROCESSOR ticks will yield the processor to any other
ready task
of equal or greater priority and remain ready to execute. 
=============

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the users mailing list