Correct an error in named application priority when SCHED_RR is enabled
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4928 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
a8c7b0bb8f
commit
16dc9afc30
@ -242,3 +242,9 @@
|
||||
* apps/nshlib/nsh_fscmds.c: Add the 'mv' command
|
||||
|
||||
6.20 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
|
||||
|
||||
* namedapp/exec_namedapp.c - Correct an error when round robin scheduling
|
||||
is enabled. The priority of the new, named application was erroneously
|
||||
being set to the priority of the parent thread; losing its configured
|
||||
priority. Reported by Mike Smith.
|
||||
|
||||
|
@ -122,33 +122,66 @@ int namedapp_isavail(FAR const char *appname)
|
||||
* Execute the application with name 'appname', providing the arguments
|
||||
* in the argv[] array.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the task ID of the named application is returned. On
|
||||
* failure, -1 (ERROR) is returned an the errno value is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int exec_namedapp(FAR const char *appname, FAR const char **argv)
|
||||
{
|
||||
int i;
|
||||
pid_t pid;
|
||||
int index;
|
||||
|
||||
if ((i = namedapp_isavail(appname)) >= 0)
|
||||
/* Verify that an application with this name exists */
|
||||
|
||||
index = namedapp_isavail(appname);
|
||||
if (index >= 0)
|
||||
{
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
i = task_create(namedapps[i].name, namedapps[i].priority,
|
||||
namedapps[i].stacksize, namedapps[i].main,
|
||||
(argv) ? &argv[1] : (const char **)NULL);
|
||||
#else
|
||||
i = task_create(namedapps[i].name, namedapps[i].priority, namedapps[i].main,
|
||||
(argv) ? &argv[1] : (const char **)NULL);
|
||||
#endif
|
||||
/* Disable pre-emption. This means that although we start the named
|
||||
* application here, it will not actually run until pre-emption is
|
||||
* re-enabled below.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
|
||||
/* Start the named application task */
|
||||
|
||||
pid = TASK_CREATE(namedapps[index].name, namedapps[index].priority,
|
||||
namedapps[index].stacksize, namedapps[index].main,
|
||||
(argv) ? &argv[1] : (const char **)NULL);
|
||||
|
||||
/* If robin robin scheduling is enabled, then set the scheduling policy
|
||||
* of the new task to SCHED_RR before it has a chance to run.
|
||||
*/
|
||||
|
||||
#if CONFIG_RR_INTERVAL > 0
|
||||
if (i > 0)
|
||||
if (pid > 0)
|
||||
{
|
||||
struct sched_param param;
|
||||
|
||||
sched_getparam(0, ¶m);
|
||||
sched_setscheduler(i, SCHED_RR, ¶m);
|
||||
/* Pre-emption is disabled so the task creation and the
|
||||
* following operation will be atomic. The priority of the
|
||||
* new task cannot yet have changed from its initial value.
|
||||
*/
|
||||
|
||||
param.sched_priority = namedapps[index].priority;
|
||||
sched_setscheduler(pid, SCHED_RR, ¶m);
|
||||
}
|
||||
#endif
|
||||
/* Now let the named application run */
|
||||
|
||||
sched_unlock();
|
||||
|
||||
/* Return the task ID of the new task if the task was sucessfully
|
||||
* started. Otherwise, pid will be ERROR (and the errno value will
|
||||
* be set appropriately).
|
||||
*/
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
return i;
|
||||
/* Return ERROR with errno set appropriately */
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user