From c5ec593bc47b4388b85bd1bdd96d3ccbeb8fd1e0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 28 Mar 2011 13:21:11 +0000 Subject: [PATCH] Move helper macro into sched.h git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3430 42af7a65-404d-4744-a932-0658087f49c3 --- include/sched.h | 24 ++++++++++++++++++++---- sched/os_bringup.c | 24 +++++++++--------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/include/sched.h b/include/sched.h index 4bb1fbe78a..739f6a98b6 100644 --- a/include/sched.h +++ b/include/sched.h @@ -1,7 +1,7 @@ /******************************************************************************** * include/sched.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,7 @@ * Pre-processor Definitions ********************************************************************************/ -/* Task Management Definitins ***************************************************/ +/* Task Management Definitions **************************************************/ /* POSIX-like scheduling policies */ @@ -63,6 +63,21 @@ #define PTHREAD_KEYS_MAX CONFIG_NPTHREAD_KEYS +/* Non-standard Helper **********************************************************/ +/* One processor family supported by NuttX has a single, fixed hardware stack. + * That is the 8051 family. So for that family only, there is a variant form + * of task_create() that does not task a stack size of a parameter. The following + * helper macro is provided to work around the ugliness of that exception. + */ + +#ifndef CONFIG_CUSTOM_STACK +# define TASK_INIT(t,n,p,m,s,e,a) task_init(t,n,p,m,s,e,a) +# define TASK_CREATE(n,p,s,e,a) task_create(n,p,s,e,a) +#else +# define TASK_INIT(t,n,p,m,s,e,a) task_init(t,n,p,e,a) +# define TASK_CREATE(n,p,s,e,a) task_create(n,p,e,a) +#endif + /******************************************************************************** * Global Type Definitions ********************************************************************************/ @@ -126,8 +141,8 @@ EXTERN int sched_lock(void); EXTERN int sched_unlock(void); EXTERN int32_t sched_lockcount(void); -/* If instrumentation of the scheduler is enabled, then some - * outboard logic must provide the following interfaces. +/* If instrumentation of the scheduler is enabled, then some outboard logic + * must provide the following interfaces. */ #ifdef CONFIG_SCHED_INSTRUMENTATION @@ -149,3 +164,4 @@ EXTERN void sched_note_switch(FAR _TCB *pFromTcb, FAR _TCB *pToTcb); #endif /* __ASSEMBLY__ */ #endif /* __INCLUDE_SCHED_H */ + diff --git a/sched/os_bringup.c b/sched/os_bringup.c index 38f9be51da..7ef7f5f6d2 100644 --- a/sched/os_bringup.c +++ b/sched/os_bringup.c @@ -62,12 +62,6 @@ * Pre-processor Definitions ****************************************************************************/ -#ifndef CONFIG_CUSTOM_STACK -# define START_TASK(n,p,s,e,a) task_create(n,p,s,e,a) -#else -# define START_TASK(n,p,s,e,a) task_create(n,p,e,a) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -133,9 +127,9 @@ int os_bringup(void) #ifdef CONFIG_PAGING svdbg("Starting paging thread\n"); - g_pgworker = START_TASK("pgfill", CONFIG_PAGING_DEFPRIO, - CONFIG_PAGING_STACKSIZE, - (main_t)pg_worker, (const char **)NULL); + g_pgworker = TASK_CREATE("pgfill", CONFIG_PAGING_DEFPRIO, + CONFIG_PAGING_STACKSIZE, + (main_t)pg_worker, (const char **)NULL); ASSERT(g_pgworker != ERROR); #endif @@ -144,9 +138,9 @@ int os_bringup(void) #ifdef CONFIG_SCHED_WORKQUEUE svdbg("Starting worker thread\n"); - g_worker = START_TASK("work", CONFIG_SCHED_WORKPRIORITY, - CONFIG_SCHED_WORKSTACKSIZE, - (main_t)work_thread, (const char **)NULL); + g_worker = TASK_CREATE("work", CONFIG_SCHED_WORKPRIORITY, + CONFIG_SCHED_WORKSTACKSIZE, + (main_t)work_thread, (const char **)NULL); ASSERT(g_worker != ERROR); #endif @@ -165,9 +159,9 @@ int os_bringup(void) #else /* Start the default application at user_start() */ - init_taskid = START_TASK("init", SCHED_PRIORITY_DEFAULT, - CONFIG_USERMAIN_STACKSIZE, - (main_t)user_start, (const char **)NULL); + init_taskid = TASK_CREATE("init", SCHED_PRIORITY_DEFAULT, + CONFIG_USERMAIN_STACKSIZE, + (main_t)user_start, (const char **)NULL); #endif ASSERT(init_taskid != ERROR); return OK;