diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-09-29 06:50:48 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-09-29 06:50:48 -0600 |
commit | e6ce09d1a6daf619d06a0c5237fc935a8758398b (patch) | |
tree | 9ded6a97bf7dd7ea60e17986a52b972ef6490b53 | |
parent | 490134ea71ef420ac319d77685330001261b0ea4 (diff) | |
download | nuttx-e6ce09d1a6daf619d06a0c5237fc935a8758398b.tar.gz nuttx-e6ce09d1a6daf619d06a0c5237fc935a8758398b.tar.bz2 nuttx-e6ce09d1a6daf619d06a0c5237fc935a8758398b.zip |
Semaphore initialization is now only required if priority inheritance is initialized
-rw-r--r-- | nuttx/sched/init/os_start.c | 12 | ||||
-rw-r--r-- | nuttx/sched/semaphore/Make.defs | 6 | ||||
-rw-r--r-- | nuttx/sched/semaphore/sem_initialize.c | 14 | ||||
-rw-r--r-- | nuttx/sched/semaphore/semaphore.h | 9 |
4 files changed, 24 insertions, 17 deletions
diff --git a/nuttx/sched/init/os_start.c b/nuttx/sched/init/os_start.c index ca0fdb21f..309cb4020 100644 --- a/nuttx/sched/init/os_start.c +++ b/nuttx/sched/init/os_start.c @@ -334,17 +334,11 @@ void os_start(void) up_initial_state(&g_idletcb.cmn); /* Initialize RTOS facilities *********************************************/ - /* Initialize the semaphore facility(if in link). This has to be done - * very early because many subsystems depend upon fully functional - * semaphores. + /* Initialize the semaphore facility. This has to be done very early + * because many subsystems depend upon fully functional semaphores. */ -#ifdef CONFIG_HAVE_WEAKFUNCTIONS - if (sem_initialize != NULL) -#endif - { - sem_initialize(); - } + sem_initialize(); /* Initialize the memory manager */ diff --git a/nuttx/sched/semaphore/Make.defs b/nuttx/sched/semaphore/Make.defs index 0df778956..0f39b1f96 100644 --- a/nuttx/sched/semaphore/Make.defs +++ b/nuttx/sched/semaphore/Make.defs @@ -33,15 +33,15 @@ # ############################################################################ -SEM_SRCS = sem_initialize.c sem_destroy.c sem_wait.c sem_trywait.c -SEM_SRCS += sem_timedwait.c sem_post.c +SEM_SRCS = sem_destroy.c sem_wait.c sem_trywait.c sem_timedwait.c +SEM_SRCS += sem_post.c ifneq ($(CONFIG_DISABLE_SIGNALS),y) SEM_SRCS += sem_waitirq.c endif ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) -SEM_SRCS += sem_holder.c +SEM_SRCS += sem_initialize.c sem_holder.c endif # Include semaphore build support diff --git a/nuttx/sched/semaphore/sem_initialize.c b/nuttx/sched/semaphore/sem_initialize.c index 9d9740c1d..2468da1db 100644 --- a/nuttx/sched/semaphore/sem_initialize.c +++ b/nuttx/sched/semaphore/sem_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/semaphore/sem_initialize.c * - * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -41,8 +41,12 @@ #include "semaphore/semaphore.h" +/* Currently only need to setup priority inheritance logic */ + +#ifdef CONFIG_PRIORITY_INHERITANCE + /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -70,7 +74,7 @@ * * Description: * The control structures for all semaphores may be initialized by calling - * sem_initialize(). This should be done once at poweron. + * sem_initialize(). This should be done once at power-on. * * Parameters: * None @@ -84,7 +88,9 @@ void sem_initialize(void) { - /* Initialize holder structures needed to support priority inheritiance */ + /* Initialize holder structures needed to support priority inheritance */ sem_initholders(); } + +#endif /* CONFIG_PRIORITY_INHERITANCE */ diff --git a/nuttx/sched/semaphore/semaphore.h b/nuttx/sched/semaphore/semaphore.h index 8721fecba..d8ed3ecd7 100644 --- a/nuttx/sched/semaphore/semaphore.h +++ b/nuttx/sched/semaphore/semaphore.h @@ -75,8 +75,15 @@ extern "C" /* Common semaphore logic */ -void weak_function sem_initialize(void); +#ifdef CONFIG_PRIORITY_INHERITANCE +void sem_initialize(void); +#else +# define sem_initialize() +#endif + +#ifndef CONFIG_DISABLE_SIGNALS void sem_waitirq(FAR struct tcb_s *wtcb, int errcode); +#endif /* Special logic needed only by priority inheritance to manage collections of * holders of semaphores. |