9
0
Fork 0

Correct an error in named application priority when SCHED_RR is enabled

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4928 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-07-11 02:43:12 +00:00
parent bb44062429
commit 6846715123
2 changed files with 56 additions and 17 deletions

View File

@ -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.

View File

@ -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;
if ((i = namedapp_isavail(appname)) >= 0)
pid_t pid;
int index;
/* 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, &param);
sched_setscheduler(i, SCHED_RR, &param);
/* 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, &param);
}
#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;
}