summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-01 21:05:55 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-01 21:05:55 +0000
commit08680a039b6ffc922731d9a1cfdff20ef204dbba (patch)
tree25bb704377c624f2d63c4bb5ad1df332d44aa78a /nuttx/sched
parent129dd27cc4deb042d2f88c65927adc49c338756d (diff)
downloadpx4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.tar.gz
px4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.tar.bz2
px4-nuttx-08680a039b6ffc922731d9a1cfdff20ef204dbba.zip
This creates a 8051 build that can run in 24Kb of RAM
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@26 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/Makefile5
-rw-r--r--nuttx/sched/irq_initialize.c2
-rw-r--r--nuttx/sched/irq_internal.h2
-rw-r--r--nuttx/sched/os_internal.h13
-rw-r--r--nuttx/sched/os_start.c24
-rw-r--r--nuttx/sched/sched_getfiles.c5
-rw-r--r--nuttx/sched/sched_getstreams.c5
-rw-r--r--nuttx/sched/sched_releasefiles.c5
-rw-r--r--nuttx/sched/sched_setupidlefiles.c5
-rw-r--r--nuttx/sched/sched_setuppthreadfiles.c5
-rw-r--r--nuttx/sched/sched_setupstreams.c5
-rw-r--r--nuttx/sched/sched_setuptaskfiles.c5
-rw-r--r--nuttx/sched/task_create.c10
13 files changed, 52 insertions, 39 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index fa69c60b5..43868d4fb 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -100,7 +100,10 @@ SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \
- $(PTHREAD_SRCS) $(SEM_SRCS) $(IRQ_SRCS)
+ $(SEM_SRCS) $(IRQ_SRCS)
+ifneq ($(CONFIG_DISABLE_PTHREAD),y)
+CSRCS += $(PTHREAD_SRCS)
+endif
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CSRCS += $(SIGNAL_SRCS)
endif
diff --git a/nuttx/sched/irq_initialize.c b/nuttx/sched/irq_initialize.c
index b213a5b09..445bb3e2c 100644
--- a/nuttx/sched/irq_initialize.c
+++ b/nuttx/sched/irq_initialize.c
@@ -54,7 +54,7 @@
* Global Variables
************************************************************/
-xcpt_t g_irqvector[NR_IRQS+1];
+FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Private Variables
diff --git a/nuttx/sched/irq_internal.h b/nuttx/sched/irq_internal.h
index a1216fa9d..6cac68ecf 100644
--- a/nuttx/sched/irq_internal.h
+++ b/nuttx/sched/irq_internal.h
@@ -53,7 +53,7 @@
* Public Type Declarations
************************************************************/
-extern xcpt_t g_irqvector[NR_IRQS+1];
+extern FAR xcpt_t g_irqvector[NR_IRQS+1];
/************************************************************
* Public Variables
diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h
index d829783bd..900484d9b 100644
--- a/nuttx/sched/os_internal.h
+++ b/nuttx/sched/os_internal.h
@@ -85,14 +85,13 @@ enum os_crash_codes_e
/* Although task IDs can take the (positive, non-zero)
* range of pid_t, the number of tasks that will be supported
- * at any one time is (artificially) limited by the following
- * definition. Limiting the number of tasks speeds certain
+ * at any one time is (artificially) limited by the CONFIG_MAX_TASKS
+ * configuration setting. Limiting the number of tasks speeds certain
* OS functions (this is the only limitation in the number of
* tasks built into the design).
*/
-#define MAX_TASKS_ALLOWED 64
-#define MAX_TASKS_MASK 0x3f
+#define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1)
#define PIDHASH(pid) ((pid) & MAX_TASKS_MASK)
/* Stubs used when there are no file descriptors */
@@ -216,14 +215,16 @@ extern sq_queue_t g_delayeddeallocations;
extern pid_t g_lastpid;
/* The following hash table is used for two things:
+ *
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
+ *
* It has the side effects of using more memory and limiting
- * the number of tasks to MAX_TASKS_ALLOWED.
+ * the number of tasks to CONFIG_MAX_TASKS.
*/
-extern pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
+extern pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index d8106ed16..5cf7c940f 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -53,7 +53,9 @@
#ifndef CONFIG_DISABLE_MQUEUE
# include "mq_internal.h"
#endif
-#include "pthread_internal.h"
+#ifndef CONFIG_DISABLE_PTHREAD
+# include "pthread_internal.h"
+#endif
#include "clock_internal.h"
#include "irq_internal.h"
@@ -140,14 +142,16 @@ sq_queue_t g_delayeddeallocations;
pid_t g_lastpid;
/* The following hash table is used for two things:
+ *
* 1. This hash table greatly speeds the determination of
* a new unique process ID for a task, and
* 2. Is used to quickly map a process ID into a TCB.
* It has the side effects of using more memory and limiting
- * the number of tasks to MAX_TASKS_ALLOWED.
+ *
+ * the number of tasks to CONFIG_MAX_TASKS.
*/
-pidhash_t g_pidhash[MAX_TASKS_ALLOWED];
+pidhash_t g_pidhash[CONFIG_MAX_TASKS];
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
@@ -185,6 +189,10 @@ const tasklist_t g_tasklisttable[NUM_TASK_STATES] =
static FAR _TCB g_idletcb;
+/* This is the name of the idle task */
+
+static FAR char g_idlename[] = "Idle Task";
+
/************************************************************
* Private Function Prototypes
************************************************************/
@@ -225,7 +233,7 @@ void os_start(void)
/* Initialize the logic that determine unique process IDs. */
g_lastpid = 0;
- for (i = 0; i < MAX_TASKS_ALLOWED; i++)
+ for (i = 0; i < CONFIG_MAX_TASKS; i++)
{
g_pidhash[i].tcb = NULL;
g_pidhash[i].pid = INVALID_PROCESS_ID;
@@ -248,10 +256,10 @@ void os_start(void)
g_idletcb.entry.main = (main_t)os_start;
#if CONFIG_TASK_NAME_SIZE > 0
- strncpy(g_idletcb.name, "Idle Task", CONFIG_TASK_NAME_SIZE-1);
+ strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1);
g_idletcb.argv[0] = g_idletcb.name;
#else
- g_idletcb.argv[0] = "Idle Task";
+ g_idletcb.argv[0] = g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */
/* Then add the idle task's TCB to the head of the ready to run list */
@@ -347,21 +355,25 @@ void os_start(void)
/* Initialize the thread-specific data facility (if in link) */
+#ifndef CONFIG_DISABLE_PTHREAD
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (pthread_initialize != NULL)
#endif
{
pthread_initialize();
}
+#endif
/* Initialize the file system (needed to support device drivers) */
+#if CONFIG_NFILE_DESCRIPTORS > 0
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
if (fs_initialize != NULL)
#endif
{
fs_initialize();
}
+#endif
/* The processor specific details of running the operating system
* will be handled here. Such things as setting up interrupt
diff --git a/nuttx/sched/sched_getfiles.c b/nuttx/sched/sched_getfiles.c
index 7478e7cf0..76c209b6e 100644
--- a/nuttx/sched/sched_getfiles.c
+++ b/nuttx/sched/sched_getfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
FAR struct filelist *sched_getfiles(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_getstreams.c b/nuttx/sched/sched_getstreams.c
index ba7f3a23d..cc21339cc 100644
--- a/nuttx/sched/sched_getstreams.c
+++ b/nuttx/sched/sched_getstreams.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
-
#include <sched.h>
#include "os_internal.h"
@@ -68,6 +65,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+
FAR struct streamlist *sched_getstreams(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_releasefiles.c b/nuttx/sched/sched_releasefiles.c
index 979aca22d..c511bdb54 100644
--- a/nuttx/sched/sched_releasefiles.c
+++ b/nuttx/sched/sched_releasefiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -69,6 +66,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_releasefiles(_TCB *tcb)
{
if (tcb)
diff --git a/nuttx/sched/sched_setupidlefiles.c b/nuttx/sched/sched_setupidlefiles.c
index 29d5dd3e0..871a445bd 100644
--- a/nuttx/sched/sched_setupidlefiles.c
+++ b/nuttx/sched/sched_setupidlefiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setupidlefiles(FAR _TCB *tcb)
{
int fd;
diff --git a/nuttx/sched/sched_setuppthreadfiles.c b/nuttx/sched/sched_setuppthreadfiles.c
index 5cc20c6d1..91dfd850f 100644
--- a/nuttx/sched/sched_setuppthreadfiles.c
+++ b/nuttx/sched/sched_setuppthreadfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setuppthreadfiles(FAR _TCB *tcb)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/sched_setupstreams.c
index 97509fc68..a19dd0bf1 100644
--- a/nuttx/sched/sched_setupstreams.c
+++ b/nuttx/sched/sched_setupstreams.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
-
#include <sched.h>
#include <nuttx/fs.h>
#include <nuttx/lib.h>
@@ -53,6 +50,8 @@
* Public Functions
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+
int sched_setupstreams(FAR _TCB *tcb)
{
/* Allocate file strems for the TCB */
diff --git a/nuttx/sched/sched_setuptaskfiles.c b/nuttx/sched/sched_setuptaskfiles.c
index 175398031..25275e89b 100644
--- a/nuttx/sched/sched_setuptaskfiles.c
+++ b/nuttx/sched/sched_setuptaskfiles.c
@@ -38,9 +38,6 @@
************************************************************/
#include <nuttx/config.h>
-
-#if CONFIG_NFILE_DESCRIPTORS > 0
-
#include <sched.h>
#include <errno.h>
#include <nuttx/fs.h>
@@ -71,6 +68,8 @@
*
************************************************************/
+#if CONFIG_NFILE_DESCRIPTORS > 0
+
int sched_setuptaskfiles(FAR _TCB *tcb)
{
#ifdef CONFIG_DEV_CONSOLE
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c
index daf42af2f..399bba20c 100644
--- a/nuttx/sched/task_create.c
+++ b/nuttx/sched/task_create.c
@@ -62,6 +62,10 @@
* Private Variables
************************************************************/
+/* This is the name for un-named tasks */
+
+static FAR char g_noname[] = "no name";
+
/************************************************************
* Private Function Prototypes
************************************************************/
@@ -141,7 +145,7 @@ static STATUS task_assignpid(FAR _TCB *tcb)
/* We'll try every allowable pid */
- for (tries = 0; tries < MAX_TASKS_ALLOWED; tries++)
+ for (tries = 0; tries < CONFIG_MAX_TASKS; tries++)
{
/* Get the next process ID candidate */
@@ -244,7 +248,7 @@ STATUS _task_init(FAR _TCB *tcb, const char *name, int priority,
if (!name)
{
- name = "no name";
+ name = g_noname;
}
/* copy the name into the TCB */
@@ -257,7 +261,7 @@ STATUS _task_init(FAR _TCB *tcb, const char *name, int priority,
#if CONFIG_TASK_NAME_SIZE > 0
tcb->argv[0] = tcb->name;
#else
- tcb->argv[0] = "no name";
+ tcb->argv[0] = g_noname;
#endif
/* For pthreads, args are strictly pass-by-value; the char*