summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/binfmt_loadmodule.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-17 00:30:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-17 00:30:12 +0000
commit4f0e8b1249c1550bac83f9db61c67094bc6afc2d (patch)
tree039d43ce0b08169a020076ccc59ee70b2e80c771 /nuttx/binfmt/binfmt_loadmodule.c
parenta0d71b94386f014bdeff6be77b7444438f867bbd (diff)
downloadnuttx-4f0e8b1249c1550bac83f9db61c67094bc6afc2d.tar.gz
nuttx-4f0e8b1249c1550bac83f9db61c67094bc6afc2d.tar.bz2
nuttx-4f0e8b1249c1550bac83f9db61c67094bc6afc2d.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: svn://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.c43
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, &param);
+ 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 '/'.
*/