sched: Don't include nuttx/sched.h inside sched.h

But let nuttx/sched.h include sched.h instead to
avoid expose nuttx kernel API to userspace.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-05-14 10:03:23 +08:00 committed by Masayuki Ishikawa
parent 0146231166
commit 001e7c3e76
105 changed files with 256 additions and 224 deletions

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"

View file

@ -29,6 +29,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"
#include "chip.h"

View file

@ -30,7 +30,7 @@
#include <nuttx/board.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "chip.h"

View file

@ -32,6 +32,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/wdog.h>
#include <nuttx/clock.h>

View file

@ -26,7 +26,7 @@
#include <stdint.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include <errno.h>

View file

@ -38,6 +38,7 @@
#include <nuttx/wdog.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/wqueue.h>
#include <nuttx/signal.h>
#include <nuttx/net/mii.h>

View file

@ -55,6 +55,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include "arm_arch.h"

View file

@ -38,6 +38,7 @@
#include <nuttx/wdog.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/wqueue.h>
#include <nuttx/signal.h>
#include <nuttx/net/mii.h>

View file

@ -33,6 +33,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/timers/rtc.h>
#include <arch/board/board.h>

View file

@ -38,6 +38,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/init.h>
#include <nuttx/power/pm.h>
#include <nuttx/fs/ioctl.h>

View file

@ -31,6 +31,7 @@
#include <assert.h>
#include <errno.h>
#include <nuttx/spinlock.h>
#include <nuttx/timers/watchdog.h>
#include "arm_arch.h"

View file

@ -35,6 +35,7 @@
#include <stdlib.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"
#include "lc823450_dma.h"

View file

@ -25,6 +25,7 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/clock.h>
#include <arch/board/board.h>
#include <string.h>

View file

@ -26,6 +26,7 @@
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <errno.h>
#include <debug.h>

View file

@ -29,7 +29,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/board.h>
#include <arch/armv7-m/nvicpri.h>

View file

@ -23,8 +23,8 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <stdint.h>
#include <debug.h>

View file

@ -29,6 +29,7 @@
#include <time.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "nvic.h"

View file

@ -39,6 +39,7 @@
#endif
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/kmalloc.h>
#include <nuttx/signal.h>
#include <nuttx/usb/usb.h>

View file

@ -29,6 +29,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"

View file

@ -28,7 +28,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"

View file

@ -27,6 +27,8 @@
#include <stdbool.h>
#include <fixedmath.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"
#include "arm_internal.h"

View file

@ -33,6 +33,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/clock.h>
#include <nuttx/timers/rtc.h>

View file

@ -34,6 +34,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/serial/serial.h>
#include <arch/board/board.h>

View file

@ -30,6 +30,7 @@
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/clock.h>
#include <nuttx/timers/watchdog.h>
#include <arch/board/board.h>

View file

@ -30,7 +30,7 @@
#include <errno.h>
#include <debug.h>
#include <arch/irq.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"
#include "hardware/nrf52_gpio.h"

View file

@ -26,7 +26,7 @@
#include <stdint.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include <errno.h>

View file

@ -56,6 +56,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include "arm_arch.h"

View file

@ -37,6 +37,7 @@
#include <nuttx/wdog.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/wqueue.h>
#include <nuttx/signal.h>
#include <nuttx/net/mii.h>

View file

@ -38,6 +38,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/init.h>
#include <nuttx/power/pm.h>
#include <nuttx/fs/ioctl.h>

View file

@ -35,6 +35,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include <nuttx/wireless/bluetooth/bt_uart.h>
#include <nuttx/power/pm.h>

View file

@ -28,7 +28,7 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "hardware/tiva_prcm.h"
#include "tiva_enablepwr.h"

View file

@ -30,7 +30,7 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_arch.h"
#include "tiva_gpio.h"

View file

@ -34,6 +34,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include <nuttx/wireless/bluetooth/bt_uart.h>
#include <nuttx/power/pm.h>

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "up_arch.h"

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "up_arch.h"

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "up_arch.h"

View file

@ -30,6 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "hardware/bl602_clic.h"
#include "riscv_arch.h"

View file

@ -29,6 +29,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "riscv_arch.h"

View file

@ -27,8 +27,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "riscv_arch.h"

View file

@ -24,8 +24,8 @@
#include <stdint.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/power/pm.h>
#include "esp32c3.h"

View file

@ -26,8 +26,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
/****************************************************************************
* Pre-processor Definitions

View file

@ -37,10 +37,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <irq/irq.h>
#include "nuttx/kmalloc.h"
#include <nuttx/kmalloc.h>
#include <nuttx/mqueue.h>
#include "nuttx/spinlock.h"
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include <nuttx/kthread.h>
#include <nuttx/wdog.h>

View file

@ -29,6 +29,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "riscv_arch.h"

View file

@ -30,6 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "riscv_arch.h"

View file

@ -29,6 +29,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "riscv_arch.h"

View file

@ -30,6 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include "riscv_arch.h"

View file

@ -29,8 +29,8 @@
#include <sched.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "sched/sched.h"
#include "riscv_internal.h"

View file

@ -395,10 +395,6 @@ static inline void set_pcid(uint64_t pcid)
"%%rbx; mov %%rbx, %%cr3;"
::"g"(pcid):"memory", "rbx", "rax");
}
else
{
PANIC();
}
}
static inline unsigned long read_msr(unsigned int msr)

View file

@ -30,6 +30,10 @@
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stddef.h>
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions

View file

@ -26,6 +26,7 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/himem/himem.h>
#include <nuttx/spinlock.h>
#include "esp32_spiram.h"
#include "esp32_himem.h"

View file

@ -24,8 +24,8 @@
#include <stdint.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/power/pm.h>
#include "esp32_pm.h"

View file

@ -30,7 +30,6 @@
#include <errno.h>
#include <nuttx/spinlock.h>
#include <arch/irq.h>
#include "hardware/esp32_dport.h"
#include "xtensa.h"

View file

@ -33,7 +33,7 @@
#include <string.h>
#include <sys/param.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "esp32_spiram.h"
#include "esp32_spicache.h"

View file

@ -37,9 +37,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <irq/irq.h>
#include "nuttx/kmalloc.h"
#include <nuttx/kmalloc.h>
#include <nuttx/mqueue.h>
#include "nuttx/spinlock.h"
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/semaphore.h>
#include <nuttx/kthread.h>

View file

@ -40,6 +40,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "imxrt_gpio.h"

View file

@ -40,6 +40,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "imxrt_gpio.h"
#include "imxrt_enet.h"

View file

@ -40,6 +40,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "imxrt_gpio.h"
#include "imxrt_enet.h"

View file

@ -40,6 +40,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "imxrt_gpio.h"
#include "imxrt_enet.h"

View file

@ -40,6 +40,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "imxrt_gpio.h"
#include "imxrt_enet.h"

View file

@ -30,6 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>

View file

@ -30,6 +30,7 @@
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/wireless/gs2200m.h>
#include "arm_arch.h"

View file

@ -32,6 +32,7 @@
#include <nuttx/arch.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mqueue.h>

View file

@ -30,7 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/config.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mqueue.h>

View file

@ -37,7 +37,7 @@
#include <queue.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/kmalloc.h>
#include <nuttx/semaphore.h>
#include <nuttx/clock.h>

View file

@ -27,7 +27,7 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
#include <nuttx/kmalloc.h>
#include <nuttx/i2c/i2c_master.h>

View file

@ -33,6 +33,7 @@
#include <unistd.h>
#include <nuttx/fs/fs.h>
#include <nuttx/spinlock.h>
#include <nuttx/ioexpander/gpio.h>
#ifdef CONFIG_DEV_GPIO

View file

@ -30,8 +30,8 @@
#include <stdbool.h>
#include <unistd.h>
#include <sched.h>
#include <syslog.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/signal.h>
#include <nuttx/kthread.h>

View file

@ -52,9 +52,8 @@
#include <termios.h>
#include <unistd.h>
#include <nuttx/arch.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/kmalloc.h>
#include <nuttx/kthread.h>
#include <nuttx/semaphore.h>

View file

@ -27,6 +27,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#if defined(CONFIG_VNCSERVER_DEBUG) && !defined(CONFIG_DEBUG_GRAPHICS)

View file

@ -78,13 +78,13 @@
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
#include <arch/arch.h>
#include <arch/types.h>
#include <nuttx/compiler.h>
#include <nuttx/cache.h>
#include <nuttx/sched.h>
/****************************************************************************
* Pre-processor definitions

View file

@ -32,11 +32,8 @@
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
#ifdef CONFIG_FS_NAMED_SEMAPHORES
# include <nuttx/semaphore.h>
#endif
#include <nuttx/semaphore.h>
/****************************************************************************
* Pre-processor Definitions

View file

@ -30,10 +30,7 @@
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <assert.h>
# ifdef CONFIG_SMP
# include <stdbool.h>
# include <nuttx/spinlock.h>
# endif
# include <stdbool.h>
#endif
/* Now include architecture-specific types */
@ -270,80 +267,6 @@ void leave_critical_section(irqstate_t flags);
# define leave_critical_section(f) up_irq_restore(f)
#endif
/****************************************************************************
* Name: spin_lock_irqsave
*
* Description:
* If SMP is are enabled:
* If the argument lock is not specified (i.e. NULL),
* disable local interrupts and take the global spinlock (g_irq_spin)
* if the call counter (g_irq_spin_count[cpu]) equals to 0. Then the
* counter on the CPU is increment to allow nested call and return
* the interrupt state.
*
* If the argument lock is specified,
* disable local interrupts and take the lock spinlock and return
* the interrupt state.
*
* NOTE: This API is very simple to protect data (e.g. H/W register
* or internal data structure) in SMP mode. But do not use this API
* with kernel APIs which suspend a caller thread. (e.g. nxsem_wait)
*
* If SMP is not enabled:
* This function is equivalent to up_irq_save().
*
* Input Parameters:
* lock - Caller specific spinlock. If specified NULL, g_irq_spin is used
* and can be nested. Otherwise, nested call for the same lock
* would cause a deadlock
*
* Returned Value:
* An opaque, architecture-specific value that represents the state of
* the interrupts prior to the call to spin_lock_irqsave(lock);
*
****************************************************************************/
#if defined(CONFIG_SMP)
irqstate_t spin_lock_irqsave(spinlock_t *lock);
#else
# define spin_lock_irqsave(l) up_irq_save()
#endif
/****************************************************************************
* Name: spin_unlock_irqrestore
*
* Description:
* If SMP is enabled:
* If the argument lock is not specified (i.e. NULL),
* decrement the call counter (g_irq_spin_count[cpu]) and if it
* decrements to zero then release the spinlock (g_irq_spin) and
* restore the interrupt state as it was prior to the previous call to
* spin_lock_irqsave(NULL).
*
* If the argument lock is specified, release the the lock and
* restore the interrupt state as it was prior to the previous call to
* spin_lock_irqsave(lock).
*
* If SMP is not enabled:
* This function is equivalent to up_irq_restore().
*
* Input Parameters:
* lock - Caller specific spinlock. If specified NULL, g_irq_spin is used.
*
* flags - The architecture-specific value that represents the state of
* the interrupts prior to the call to spin_lock_irqsave(lock);
*
* Returned Value:
* None
*
****************************************************************************/
#if defined(CONFIG_SMP)
void spin_unlock_irqrestore(spinlock_t *lock, irqstate_t flags);
#else
# define spin_unlock_irqrestore(l, f) up_irq_restore(f)
#endif
#undef EXTERN
#ifdef __cplusplus
}

View file

@ -30,6 +30,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <queue.h>
#include <sched.h>
#include <signal.h>
#include <semaphore.h>
#include <pthread.h>

View file

@ -36,12 +36,6 @@
* Pre-processor Definitions
****************************************************************************/
/* Values for protocol attribute */
#define SEM_PRIO_NONE 0
#define SEM_PRIO_INHERIT 1
#define SEM_PRIO_PROTECT 2
/* Most internal nxsem_* interfaces are not available in the user space in
* PROTECTED and KERNEL builds. In that context, the application semaphore
* interfaces must be used. The differences between the two sets of
@ -461,27 +455,6 @@ int nxsem_reset(FAR sem_t *sem, int16_t count);
#define nxsem_get_protocol(s,p) sem_getprotocol(s,p)
/****************************************************************************
* Name: sem_getprotocol
*
* Description:
* Return the value of the semaphore protocol attribute.
*
* Input Parameters:
* sem - A pointer to the semaphore whose attributes are to be
* queried.
* protocol - The user provided location in which to store the protocol
* value.
*
* Returned Value:
* This function is exposed as a non-standard application interface. It
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
* the errno value is set appropriately.
*
****************************************************************************/
int sem_getprotocol(FAR sem_t *sem, FAR int *protocol);
/****************************************************************************
* Name: nxsem_set_protocol
*
@ -521,45 +494,6 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol);
int nxsem_set_protocol(FAR sem_t *sem, int protocol);
/****************************************************************************
* Name: sem_setprotocol
*
* Description:
* Set semaphore protocol attribute.
*
* One particularly important use of this function is when a semaphore
* is used for inter-task communication like:
*
* TASK A TASK B
* sem_init(sem, 0, 0);
* sem_wait(sem);
* sem_post(sem);
* Awakens as holder
*
* In this case priority inheritance can interfere with the operation of
* the semaphore. The problem is that when TASK A is restarted it is a
* holder of the semaphore. However, it never calls sem_post(sem) so it
* becomes *permanently* a holder of the semaphore and may have its
* priority boosted when any other task tries to acquire the semaphore.
*
* The fix is to call sem_setprotocol(SEM_PRIO_NONE) immediately after
* the sem_init() call so that there will be no priority inheritance
* operations on this semaphore.
*
* Input Parameters:
* sem - A pointer to the semaphore whose attributes are to be
* modified
* protocol - The new protocol to use
*
* Returned Value:
* This function is exposed as a non-standard application interface. It
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
* the errno value is set appropriately.
*
****************************************************************************/
int sem_setprotocol(FAR sem_t *sem, int protocol);
/****************************************************************************
* Name: nxsem_wait_uninterruptible
*

View file

@ -30,6 +30,8 @@
#include <sys/types.h>
#include <stdint.h>
#include <nuttx/irq.h>
#ifndef CONFIG_SPINLOCK
typedef struct
{
@ -350,4 +352,79 @@ void spin_clrbit(FAR volatile cpu_set_t *set, unsigned int cpu,
#endif
#endif /* CONFIG_SPINLOCK */
/****************************************************************************
* Name: spin_lock_irqsave
*
* Description:
* If SMP is are enabled:
* If the argument lock is not specified (i.e. NULL),
* disable local interrupts and take the global spinlock (g_irq_spin)
* if the call counter (g_irq_spin_count[cpu]) equals to 0. Then the
* counter on the CPU is increment to allow nested call and return
* the interrupt state.
*
* If the argument lock is specified,
* disable local interrupts and take the lock spinlock and return
* the interrupt state.
*
* NOTE: This API is very simple to protect data (e.g. H/W register
* or internal data structure) in SMP mode. But do not use this API
* with kernel APIs which suspend a caller thread. (e.g. nxsem_wait)
*
* If SMP is not enabled:
* This function is equivalent to up_irq_save().
*
* Input Parameters:
* lock - Caller specific spinlock. If specified NULL, g_irq_spin is used
* and can be nested. Otherwise, nested call for the same lock
* would cause a deadlock
*
* Returned Value:
* An opaque, architecture-specific value that represents the state of
* the interrupts prior to the call to spin_lock_irqsave(lock);
*
****************************************************************************/
#if defined(CONFIG_SMP)
irqstate_t spin_lock_irqsave(spinlock_t *lock);
#else
# define spin_lock_irqsave(l) up_irq_save()
#endif
/****************************************************************************
* Name: spin_unlock_irqrestore
*
* Description:
* If SMP is enabled:
* If the argument lock is not specified (i.e. NULL),
* decrement the call counter (g_irq_spin_count[cpu]) and if it
* decrements to zero then release the spinlock (g_irq_spin) and
* restore the interrupt state as it was prior to the previous call to
* spin_lock_irqsave(NULL).
*
* If the argument lock is specified, release the the lock and
* restore the interrupt state as it was prior to the previous call to
* spin_lock_irqsave(lock).
*
* If SMP is not enabled:
* This function is equivalent to up_irq_restore().
*
* Input Parameters:
* lock - Caller specific spinlock. If specified NULL, g_irq_spin is used.
*
* flags - The architecture-specific value that represents the state of
* the interrupts prior to the call to spin_lock_irqsave(lock);
*
* Returned Value:
* None
*
****************************************************************************/
#if defined(CONFIG_SMP)
void spin_unlock_irqrestore(spinlock_t *lock, irqstate_t flags);
#else
# define spin_unlock_irqrestore(l, f) up_irq_restore(f)
#endif
#endif /* __INCLUDE_NUTTX_SPINLOCK_H */

View file

@ -36,8 +36,7 @@
#include <unistd.h> /* For getpid */
#include <signal.h> /* Needed for sigset_t, includes this file */
#include <time.h> /* Needed for struct timespec */
#include <nuttx/semaphore.h> /* For sem_t and SEM_PRIO_* defines */
#include <semaphore.h> /* For sem_t and SEM_PRIO_* defines */
#ifdef CONFIG_PTHREAD_SPINLOCKS
/* The architecture specific spinlock.h header file must provide the

View file

@ -31,10 +31,9 @@
#include <stdint.h>
#include <stdbool.h>
#include <strings.h>
#include <time.h>
#include "queue.h"
#include <nuttx/sched.h>
/********************************************************************************
* Pre-processor Definitions
********************************************************************************/

View file

@ -35,6 +35,12 @@
* Pre-processor Definitions
****************************************************************************/
/* Values for protocol attribute */
#define SEM_PRIO_NONE 0
#define SEM_PRIO_INHERIT 1
#define SEM_PRIO_PROTECT 2
/* Value returned by sem_open() in the event of a failure. */
#define SEM_FAILED ((FAR sem_t *)NULL)
@ -140,6 +146,66 @@ int sem_close(FAR sem_t *sem);
int sem_unlink(FAR const char *name);
#endif
/****************************************************************************
* Name: sem_setprotocol
*
* Description:
* Set semaphore protocol attribute.
*
* One particularly important use of this function is when a semaphore
* is used for inter-task communication like:
*
* TASK A TASK B
* sem_init(sem, 0, 0);
* sem_wait(sem);
* sem_post(sem);
* Awakens as holder
*
* In this case priority inheritance can interfere with the operation of
* the semaphore. The problem is that when TASK A is restarted it is a
* holder of the semaphore. However, it never calls sem_post(sem) so it
* becomes *permanently* a holder of the semaphore and may have its
* priority boosted when any other task tries to acquire the semaphore.
*
* The fix is to call sem_setprotocol(SEM_PRIO_NONE) immediately after
* the sem_init() call so that there will be no priority inheritance
* operations on this semaphore.
*
* Input Parameters:
* sem - A pointer to the semaphore whose attributes are to be
* modified
* protocol - The new protocol to use
*
* Returned Value:
* This function is exposed as a non-standard application interface. It
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
* the errno value is set appropriately.
*
****************************************************************************/
int sem_setprotocol(FAR sem_t *sem, int protocol);
/****************************************************************************
* Name: sem_getprotocol
*
* Description:
* Return the value of the semaphore protocol attribute.
*
* Input Parameters:
* sem - A pointer to the semaphore whose attributes are to be
* queried.
* protocol - The user provided location in which to store the protocol
* value.
*
* Returned Value:
* This function is exposed as a non-standard application interface. It
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
* the errno value is set appropriately.
*
****************************************************************************/
int sem_getprotocol(FAR sem_t *sem, FAR int *protocol);
#undef EXTERN
#ifdef __cplusplus
}

View file

@ -29,10 +29,10 @@
#include <sys/types.h>
#include <stdarg.h>
#include <sched.h>
#include <time.h>
#include <nuttx/fs/fs.h>
#include <nuttx/sched.h>
/****************************************************************************
* Pre-processor Definitions

View file

@ -24,7 +24,7 @@
#include <nuttx/config.h>
#include <debug.h>
#include <assert.h>
#include <nuttx/pthread.h>

View file

@ -27,19 +27,12 @@
#include <sys/types.h>
#include <sys/boardctl.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <pthread.h>
#include <sched.h>
/* The architecture specific spinlock.h header file must provide the
* following:
*
* SP_LOCKED - A definition of the locked state value (usually 1)
* SP_UNLOCKED - A definition of the unlocked state value (usually 0)
* spinlock_t - The type of a spinlock memory object (usually uint8_t).
*/
#include <arch/spinlock.h>
#ifdef CONFIG_PTHREAD_SPINLOCKS
/****************************************************************************

View file

@ -27,6 +27,7 @@
#include <sched.h>
#include <stdlib.h>
#include <assert.h>
#include <debug.h>
#ifndef CONFIG_BUILD_KERNEL

View file

@ -24,8 +24,7 @@
#include <nuttx/config.h>
#include <sched.h>
#include <nuttx/sched.h>
#include <nuttx/tls.h>
/****************************************************************************

View file

@ -24,8 +24,9 @@
#include <nuttx/config.h>
#include <sys/resource.h>
#include <sched.h>
#include <sched.h>
#include <unistd.h>
#include <errno.h>
/****************************************************************************

View file

@ -26,6 +26,7 @@
#include <sched.h>
#include <errno.h>
#include <unistd.h>
/****************************************************************************
* Public Functions

View file

@ -28,6 +28,8 @@
#include <assert.h>
#include <errno.h>
#include <nuttx/semaphore.h>
#include "wqueue/wqueue.h"
#if defined(CONFIG_LIB_USRWORK) && !defined(__KERNEL__)

View file

@ -27,6 +27,7 @@
#include <sys/socket.h>
#include <string.h>
#include <sched.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>

View file

@ -29,8 +29,10 @@
#include <assert.h>
#include <errno.h>
#include <nuttx/net/net.h>
#include <nuttx/semaphore.h>
#include "utils/utils.h"
#include "tcp/tcp.h"
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS) && defined(CONFIG_NET_TCP_NOTIFIER)

View file

@ -29,8 +29,10 @@
#include <assert.h>
#include <errno.h>
#include <nuttx/net/net.h>
#include <nuttx/semaphore.h>
#include "utils/utils.h"
#include "udp/udp.h"
#if defined(CONFIG_NET_UDP_WRITE_BUFFERS) && defined(CONFIG_NET_UDP_NOTIFIER)

View file

@ -30,8 +30,8 @@
#include <errno.h>
#include <debug.h>
#include <arch/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "clock/clock.h"
#ifdef CONFIG_CLOCK_TIMEKEEPING

View file

@ -28,7 +28,7 @@
#include <errno.h>
#include <nuttx/sched.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/binfmt/binfmt.h>
#include "sched/sched.h"

View file

@ -29,7 +29,7 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/tls.h>
#include "sched/sched.h"

View file

@ -28,7 +28,7 @@
#include <errno.h>
#include <assert.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/tls.h>
#include "sched/sched.h"

View file

@ -28,6 +28,7 @@
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/tls.h>
#include <arch/tls.h>

View file

@ -28,6 +28,7 @@
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/tls.h>
#include <arch/tls.h>

View file

@ -28,6 +28,7 @@
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/tls.h>
#include <arch/tls.h>

View file

@ -31,9 +31,10 @@
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <sched.h>
#include <nuttx/compiler.h>
#include <nuttx/semaphore.h>
#include <nuttx/sched.h>
/****************************************************************************
* Public Type Declarations

View file

@ -28,10 +28,10 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <nuttx/semaphore.h>
#include <nuttx/sched.h>
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
#include <queue.h>
/****************************************************************************

Some files were not shown because too many files have changed in this diff Show more