diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 00:30:12 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-17 00:30:12 +0000 |
commit | caeef71797019505fd450b1a0ae573ac5e490c6e (patch) | |
tree | 039d43ce0b08169a020076ccc59ee70b2e80c771 /nuttx/binfmt/binfmt_loadmodule.c | |
parent | e7e1c6aee0e0d84f290995a092c1722878a54044 (diff) | |
download | px4-firmware-caeef71797019505fd450b1a0ae573ac5e490c6e.tar.gz px4-firmware-caeef71797019505fd450b1a0ae573ac5e490c6e.tar.bz2 px4-firmware-caeef71797019505fd450b1a0ae573ac5e490c6e.zip |
Change the way thread priority is handled in binfmt/ to better match the way that priority is set up for the builtin tasks
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5527 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/binfmt/binfmt_loadmodule.c')
-rw-r--r-- | nuttx/binfmt/binfmt_loadmodule.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nuttx/binfmt/binfmt_loadmodule.c b/nuttx/binfmt/binfmt_loadmodule.c index 112a6b35b..4f3dc6952 100644 --- a/nuttx/binfmt/binfmt_loadmodule.c +++ b/nuttx/binfmt/binfmt_loadmodule.c @@ -67,6 +67,39 @@ ****************************************************************************/ /**************************************************************************** + * Name: load_default_priority + * + * Description: + * Set the default priority of the module to be loaded. This may be + * changed (1) by the actions of the binary format's load() method if + * the binary format contains priority informaition, or (2) by the user + * between calls to load_module() and exec_module(). + * + * Returned Value: + * Zero (OK) is returned on success; Otherwise, -1 (ERROR) is returned and + * the errno variable is set appropriately. + * + ****************************************************************************/ + +static int load_default_priority(FAR struct binary_s *bin) +{ + struct sched_param param; + + /* Get the priority of this thread */ + + ret = sched_getparam(0, ¶m); + if (ret < 0) + { + bdbg("ERROR: sched_getparam failed: %d\n", errno); + return ERROR; + } + + /* Save that as the priority of child thread */ + + bin->priority = param.sched_priority; +} + +/**************************************************************************** * Name: load_absmodule * * Description: @@ -145,6 +178,16 @@ int load_module(FAR struct binary_s *bin) if (bin && bin->filename) #endif { + /* Set the default priority of the new program. */ + + ret = load_default_priority(bin) + if (ret < 0) + { + /* The errno is already set in this case */ + + return ERROR; + } + /* Were we given a relative path? Or an absolute path to the file to * be loaded? Absolute paths start with '/'. */ |