forked from nuttx/nuttx-update
nuttx/sched: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
parent
2244ed46bc
commit
6e3107650d
69 changed files with 368 additions and 819 deletions
|
@ -46,7 +46,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#ifdef CONFIG_RTC
|
||||
# include <arch/irq.h>
|
||||
# include <nuttx/irq.h>
|
||||
#endif
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
@ -256,9 +256,9 @@ void clock_synchronize(void)
|
|||
|
||||
/* Re-initialize the time value to match the RTC */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
clock_inittime();
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
|
||||
|
@ -109,7 +109,7 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
|||
* possible.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the elapsed time since power up (in milliseconds). This is a
|
||||
* bias value that we need to use to correct the base time.
|
||||
|
@ -146,7 +146,7 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
|||
up_rtc_settime(tp);
|
||||
}
|
||||
#endif
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
sdbg("basetime=(%ld,%lu) bias=(%ld,%lu)\n",
|
||||
(long)g_basetime.tv_sec, (unsigned long)g_basetime.tv_nsec,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
|
@ -53,10 +54,6 @@
|
|||
|
||||
#undef clock_systimer
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -115,9 +112,9 @@ systime_t clock_systimer(void)
|
|||
|
||||
/* 64-bit accesses are not atomic on most architectures. */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sample = g_system_timer;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return sample;
|
||||
|
||||
# else /* CONFIG_SYSTEM_TIME64 */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/group/group_addrenv.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -48,10 +49,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
@ -138,7 +135,7 @@ int group_addrenv(FAR struct tcb_s *tcb)
|
|||
|
||||
/* Are we going to change address environments? */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (gid != g_gid_current)
|
||||
{
|
||||
/* Yes.. Is there a current address environment in place? */
|
||||
|
@ -178,7 +175,7 @@ int group_addrenv(FAR struct tcb_s *tcb)
|
|||
g_gid_current = gid;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/group/group_create.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "environ/environ.h"
|
||||
|
@ -58,10 +59,6 @@
|
|||
|
||||
#define GROUP_INITIAL_MEMBERS 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -119,7 +116,7 @@ static void group_assigngid(FAR struct task_group_s *group)
|
|||
{
|
||||
/* Increment the ID counter. This is global data so be extra paranoid. */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
gid = ++g_gidcounter;
|
||||
|
||||
/* Check for overflow */
|
||||
|
@ -127,13 +124,13 @@ static void group_assigngid(FAR struct task_group_s *group)
|
|||
if (gid <= 0)
|
||||
{
|
||||
g_gidcounter = 1;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Does a task group with this ID already exist? */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
if (group_findbygid(gid) == NULL)
|
||||
{
|
||||
/* Now assign this ID to the group and return */
|
||||
|
@ -309,10 +306,10 @@ int group_initialize(FAR struct task_tcb_s *tcb)
|
|||
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)
|
||||
/* Add the initialized entry to the list of groups */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
group->flink = g_grouphead;
|
||||
g_grouphead = group;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/group/group_find.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "group/group.h"
|
||||
|
@ -51,26 +52,6 @@
|
|||
|
||||
#ifdef HAVE_TASK_GROUP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -107,17 +88,17 @@ FAR struct task_group_s *group_findbygid(gid_t gid)
|
|||
|
||||
/* Find the status structure with the matching GID */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (group = g_grouphead; group; group = group->flink)
|
||||
{
|
||||
if (group->tg_gid == gid)
|
||||
{
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -153,17 +134,17 @@ FAR struct task_group_s *group_findbypid(pid_t pid)
|
|||
|
||||
/* Find the status structure with the matching PID */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (group = g_grouphead; group; group = group->flink)
|
||||
{
|
||||
if (group->tg_task == pid)
|
||||
{
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/group/group_join.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -59,14 +60,6 @@
|
|||
|
||||
#define GROUP_REALLOC_MEMBERS 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -126,10 +119,10 @@ static inline int group_addmember(FAR struct task_group_s *group, pid_t pid)
|
|||
* may be traversed from an interrupt handler (read-only).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
group->tg_members = newmembers;
|
||||
group->tg_mxmembers = newmax;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Assign this new pid to the group; group->tg_nmembers will be incremented
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/group/group_leave.c
|
||||
*
|
||||
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/lib.h>
|
||||
|
@ -89,7 +90,7 @@ static void group_remove(FAR struct task_group_s *group)
|
|||
* This is probably un-necessary.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Find the task group structure */
|
||||
|
||||
|
@ -115,7 +116,7 @@ static void group_remove(FAR struct task_group_s *group)
|
|||
curr->flink = NULL;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -320,10 +321,10 @@ static inline void group_removemember(FAR struct task_group_s *group, pid_t pid)
|
|||
* interrupt handlers (read-only).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
group->tg_members[i] = group->tg_members[group->tg_nmembers - 1];
|
||||
group->tg_nmembers--;
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,14 +83,14 @@ int irq_attach(int irq, xcpt_t isr)
|
|||
|
||||
if ((unsigned)irq < NR_IRQS)
|
||||
{
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* If the new ISR is NULL, then the ISR is being detached.
|
||||
* In this case, disable the ISR and direct any interrupts
|
||||
* to the unexpected interrupt handler.
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (isr == NULL)
|
||||
{
|
||||
/* Disable the interrupt if we can before detaching it. We might
|
||||
|
@ -116,7 +116,7 @@ int irq_attach(int irq, xcpt_t isr)
|
|||
/* Save the new ISR in the table. */
|
||||
|
||||
g_irqvector[irq] = isr;
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_msgfree.c
|
||||
*
|
||||
* Copyright (C) 2007, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,31 +41,12 @@
|
|||
|
||||
#include <queue.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -88,7 +69,7 @@
|
|||
|
||||
void mq_msgfree(FAR struct mqueue_msg_s *mqmsg)
|
||||
{
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* If this is a generally available pre-allocated message,
|
||||
* then just put it back in the free list.
|
||||
|
@ -100,9 +81,9 @@ void mq_msgfree(FAR struct mqueue_msg_s *mqmsg)
|
|||
* list from interrupt handlers.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)mqmsg, &g_msgfree);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* If this is a message pre-allocated for interrupts,
|
||||
|
@ -115,9 +96,9 @@ void mq_msgfree(FAR struct mqueue_msg_s *mqmsg)
|
|||
* list from interrupt handlers.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)mqmsg, &g_msgfreeirq);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Otherwise, deallocate it. Note: interrupt handlers
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_rcvinternal.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008, 2012-2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -48,31 +48,12 @@
|
|||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -249,7 +230,7 @@ ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
|||
FAR char *ubuffer, int *prio)
|
||||
{
|
||||
FAR struct tcb_s *btcb;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
ssize_t rcvmsglen;
|
||||
|
||||
|
@ -283,7 +264,7 @@ ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
|||
* messages can be sent from interrupt handlers.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (btcb = (FAR struct tcb_s *)g_waitingformqnotfull.head;
|
||||
btcb && btcb->msgwaitq != msgq;
|
||||
btcb = btcb->flink);
|
||||
|
@ -299,7 +280,7 @@ ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
|||
msgq->nwaitnotfull--;
|
||||
up_unblock_task(btcb);
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Return the length of the message transferred to the user buffer */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_receive.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,30 +44,12 @@
|
|||
#include <errno.h>
|
||||
#include <mqueue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -116,7 +98,7 @@ ssize_t mq_receive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
FAR int *prio)
|
||||
{
|
||||
FAR struct mqueue_msg_s *mqmsg;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
ssize_t ret = ERROR;
|
||||
|
||||
DEBUGASSERT(up_interrupt_context() == false);
|
||||
|
@ -143,12 +125,12 @@ ssize_t mq_receive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
* because messages can be sent from interrupt level.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the message from the message queue */
|
||||
|
||||
mqmsg = mq_waitreceive(mqdes);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Check if we got a message from the message queue. We might
|
||||
* not have a message if:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_send.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,30 +44,11 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -119,7 +100,7 @@ int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
|||
{
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct mqueue_msg_s *mqmsg = NULL;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Verify the input parameters -- setting errno appropriately
|
||||
|
@ -143,14 +124,14 @@ int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
|||
* non-FULL. This would fail with EAGAIN, EINTR, or ETIMEOUT.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (up_interrupt_context() || /* In an interrupt handler */
|
||||
msgq->nmsgs < msgq->maxmsgs || /* OR Message queue not full */
|
||||
mq_waitsend(mqdes) == OK) /* OR Successfully waited for mq not full */
|
||||
{
|
||||
/* Allocate the message */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
mqmsg = mq_msgalloc();
|
||||
}
|
||||
else
|
||||
|
@ -162,7 +143,7 @@ int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
|||
* - When we tried waiting, the wait was unsuccessful.
|
||||
*/
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Check if we were able to get a message structure -- this can fail
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_send.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -48,6 +48,7 @@
|
|||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
@ -59,26 +60,6 @@
|
|||
#endif
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -165,7 +146,7 @@ int mq_verifysend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
|||
FAR struct mqueue_msg_s *mq_msgalloc(void)
|
||||
{
|
||||
FAR struct mqueue_msg_s *mqmsg;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* If we were called from an interrupt handler, then try to get the message
|
||||
* from generally available list of messages. If this fails, then try the
|
||||
|
@ -193,9 +174,9 @@ FAR struct mqueue_msg_s *mq_msgalloc(void)
|
|||
* Disable interrupts -- we might be called from an interrupt handler.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
mqmsg = (FAR struct mqueue_msg_s *)sq_remfirst(&g_msgfree);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* If we cannot a message from the free list, then we will have to allocate one. */
|
||||
|
||||
|
@ -334,7 +315,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
|||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct mqueue_msg_s *next;
|
||||
FAR struct mqueue_msg_s *prev;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Get a pointer to the message queue */
|
||||
|
||||
|
@ -352,7 +333,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
|||
|
||||
/* Insert the new message in the message queue */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Search the message list to find the location to insert the new
|
||||
* message. Each is list is maintained in ascending priority order.
|
||||
|
@ -377,7 +358,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
|||
/* Increment the count of messages in the queue */
|
||||
|
||||
msgq->nmsgs++;
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Check if we need to notify any tasks that are attached to the
|
||||
* message queue
|
||||
|
@ -429,7 +410,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
|||
|
||||
/* Check if any tasks are waiting for the MQ not empty event. */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (msgq->nwaitnotempty > 0)
|
||||
{
|
||||
/* Find the highest priority task that is waiting for
|
||||
|
@ -451,7 +432,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
|||
up_unblock_task(btcb);
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
sched_unlock();
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_timedreceive.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <mqueue.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -54,22 +55,6 @@
|
|||
#include "clock/clock.h"
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -95,13 +80,13 @@
|
|||
static void mq_rcvtimeout(int argc, wdparm_t pid)
|
||||
{
|
||||
FAR struct tcb_s *wtcb;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
||||
* attempt to send a message while we are doing this.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the TCB associated with this pid. It is possible that task may no
|
||||
* longer be active when this watchdog goes off.
|
||||
|
@ -122,7 +107,7 @@ static void mq_rcvtimeout(int argc, wdparm_t pid)
|
|||
|
||||
/* Interrupts may now be re-enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -184,7 +169,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
{
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
FAR struct mqueue_msg_s *mqmsg;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
DEBUGASSERT(up_interrupt_context() == false && rtcb->waitdog == NULL);
|
||||
|
@ -229,7 +214,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
* because messages can be sent from interrupt level.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if the message queue is empty. If it is NOT empty, then we
|
||||
* will not need to start timer.
|
||||
|
@ -258,7 +243,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
|
||||
if (result != OK)
|
||||
{
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
sched_unlock();
|
||||
|
||||
wd_delete(rtcb->waitdog);
|
||||
|
@ -285,7 +270,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
|||
|
||||
/* We can now restore interrupts */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Check if we got a message from the message queue. We might
|
||||
* not have a message if:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_timedsend.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -54,22 +55,6 @@
|
|||
#include "sched/sched.h"
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -95,13 +80,13 @@
|
|||
static void mq_sndtimeout(int argc, wdparm_t pid)
|
||||
{
|
||||
FAR struct tcb_s *wtcb;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
||||
* attempt to send a message while we are doing this.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the TCB associated with this pid. It is possible that task may no
|
||||
* longer be active when this watchdog goes off.
|
||||
|
@ -122,7 +107,7 @@ static void mq_sndtimeout(int argc, wdparm_t pid)
|
|||
|
||||
/* Interrupts may now be re-enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -186,7 +171,7 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
|||
FAR struct tcb_s *rtcb = this_task();
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct mqueue_msg_s *mqmsg = NULL;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ticks;
|
||||
int result;
|
||||
int ret = ERROR;
|
||||
|
@ -274,7 +259,7 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
|||
* disabled here so that this time stays valid until the wait begins.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
result = clock_abstime2ticks(CLOCK_REALTIME, abstime, &ticks);
|
||||
|
||||
/* If the time has already expired and the message queue is empty,
|
||||
|
@ -290,7 +275,7 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
|||
|
||||
if (result != OK)
|
||||
{
|
||||
goto errout_with_irqsave;
|
||||
goto errout_in_critical_section;
|
||||
}
|
||||
|
||||
/* Start the watchdog and begin the wait for MQ not full */
|
||||
|
@ -314,12 +299,12 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
|||
/* mq_waitsend() will set the errno, but the error exit will reset it */
|
||||
|
||||
result = get_errno();
|
||||
goto errout_with_irqsave;
|
||||
goto errout_in_critical_section;
|
||||
}
|
||||
|
||||
/* That is the end of the atomic operations */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* If any of the above failed, set the errno. Otherwise, there should
|
||||
* be space for another message in the message queue. NOW we can allocate
|
||||
|
@ -340,8 +325,8 @@ int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
|||
* 'result'
|
||||
*/
|
||||
|
||||
errout_with_irqsave:
|
||||
irqrestore(saved_state);
|
||||
errout_in_critical_section:
|
||||
leave_critical_section(flags);
|
||||
wd_delete(rtcb->waitdog);
|
||||
rtcb->waitdog = NULL;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/mqueue/mq_waitirq.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,31 +42,12 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/mqueue.h>
|
||||
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -93,13 +74,13 @@
|
|||
void mq_waitirq(FAR struct tcb_s *wtcb, int errcode)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts. This is necessary because an interrupt handler may
|
||||
* attempt to send a message while we are doing this.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* It is possible that an interrupt/context switch beat us to the punch and
|
||||
* already changed the task's state. NOTE: The operations within the if
|
||||
|
@ -141,5 +122,5 @@ void mq_waitirq(FAR struct tcb_s *wtcb, int errcode)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/pthread/pthread_condtimedwait.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -56,22 +57,6 @@
|
|||
#include "clock/clock.h"
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -185,7 +170,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
FAR struct tcb_s *rtcb = this_task();
|
||||
int ticks;
|
||||
int mypid = (int)getpid();
|
||||
irqstate_t int_state;
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
int status;
|
||||
|
||||
|
@ -236,7 +221,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
*/
|
||||
|
||||
sched_lock();
|
||||
int_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Convert the timespec to clock ticks. We must disable pre-emption
|
||||
* here so that this time stays valid until the wait begins.
|
||||
|
@ -249,7 +234,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
* we fall through the if/then/else
|
||||
*/
|
||||
|
||||
irqrestore(int_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -264,7 +249,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
* if/then/else
|
||||
*/
|
||||
|
||||
irqrestore(int_state);
|
||||
leave_critical_section(flags);
|
||||
ret = ETIMEDOUT;
|
||||
}
|
||||
else
|
||||
|
@ -279,7 +264,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
* we fall through the if/then/else)
|
||||
*/
|
||||
|
||||
irqrestore(int_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -322,7 +307,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
|
|||
* handling! (bad)
|
||||
*/
|
||||
|
||||
irqrestore(int_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Reacquire the mutex (retaining the ret). */
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
* Assumptions:
|
||||
* - The caller has established a critical section before
|
||||
* calling this function (calling sched_lock() first is NOT
|
||||
* a good idea -- use irqsave()).
|
||||
* a good idea -- use enter_critical_section()).
|
||||
* - The caller has already removed the input tcb from
|
||||
* whatever list it was in.
|
||||
* - The caller handles the condition that occurs if the
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
* Assumptions:
|
||||
* - The caller has established a critical section before calling this
|
||||
* function (calling sched_lock() first is NOT a good idea -- use
|
||||
* irqsave()).
|
||||
* enter_critical_section()).
|
||||
* - The caller has already removed the input rtcb from whatever list it
|
||||
* was in.
|
||||
* - The caller handles the condition that occurs if the head of the
|
||||
|
@ -156,7 +156,7 @@ bool sched_addreadytorun(FAR struct tcb_s *btcb)
|
|||
* Assumptions:
|
||||
* - The caller has established a critical section before calling this
|
||||
* function (calling sched_lock() first is NOT a good idea -- use
|
||||
* irqsave()).
|
||||
* enter_critical_section()).
|
||||
* - The caller has already removed the input rtcb from whatever list it
|
||||
* was in.
|
||||
* - The caller handles the condition that occurs if the head of the
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
|
@ -183,7 +183,7 @@ int clock_cpuload(int pid, FAR struct cpuload_s *cpuload)
|
|||
* synchronized when read.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Make sure that the entry is valid (TCB field is not NULL) and matches
|
||||
* the requested PID. The first check is needed if the thread has exited.
|
||||
|
@ -205,7 +205,7 @@ int clock_cpuload(int pid, FAR struct cpuload_s *cpuload)
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/sched/sched_foreach.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -38,6 +38,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -65,7 +68,7 @@
|
|||
|
||||
void sched_foreach(sched_foreach_t handler, FAR void *arg)
|
||||
{
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
int ndx;
|
||||
|
||||
/* Vist each active task */
|
||||
|
@ -78,7 +81,7 @@ void sched_foreach(sched_foreach_t handler, FAR void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/sched/sched_free.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2012-2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -33,53 +33,26 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <queue.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sched_ufree and sched_kfree
|
||||
*
|
||||
|
@ -119,7 +92,7 @@ void sched_ufree(FAR void *address)
|
|||
* using the user deallocator.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \
|
||||
defined(CONFIG_MM_KERNEL_HEAP)
|
||||
DEBUGASSERT(!kmm_heapmember(address));
|
||||
|
@ -135,7 +108,7 @@ void sched_ufree(FAR void *address)
|
|||
#ifdef CONFIG_SCHED_WORKQUEUE
|
||||
work_signal(LPWORK);
|
||||
#endif
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -163,7 +136,7 @@ void sched_kfree(FAR void *address)
|
|||
* using the kernel deallocator.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
DEBUGASSERT(kmm_heapmember(address));
|
||||
|
||||
/* Delay the deallocation until a more appropriate time. */
|
||||
|
@ -176,7 +149,7 @@ void sched_kfree(FAR void *address)
|
|||
#ifdef CONFIG_SCHED_WORKQUEUE
|
||||
work_signal(LPWORK);
|
||||
#endif
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/sched/sched_garbage.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2011, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -38,26 +38,11 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -101,9 +86,9 @@ static inline void sched_kucleanup(void)
|
|||
* we must disable interrupts around the queue operation.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
address = (FAR void *)sq_remfirst((FAR sq_queue_t *)&g_delayed_kufree);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* The address should always be non-NULL since that was checked in the
|
||||
* 'while' condition above.
|
||||
|
@ -150,9 +135,9 @@ static inline void sched_kcleanup(void)
|
|||
* we must disable interrupts around the queue operation.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
address = (FAR void *)sq_remfirst((FAR sq_queue_t *)&g_delayed_kfree);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* The address should always be non-NULL since that was checked in the
|
||||
* 'while' condition above.
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
* Assumptions:
|
||||
* - The caller has established a critical section before
|
||||
* calling this function (calling sched_lock() first is NOT
|
||||
* a good idea -- use irqsave()).
|
||||
* a good idea -- use enter_critical_section()).
|
||||
* - The caller handles the condition that occurs if the
|
||||
* the head of the sched_mergTSTATE_TASK_PENDINGs is changed.
|
||||
*
|
||||
|
@ -177,7 +177,7 @@ bool sched_mergepending(void)
|
|||
* Assumptions:
|
||||
* - The caller has established a critical section before
|
||||
* calling this function (calling sched_lock() first is NOT
|
||||
* a good idea -- use irqsave()).
|
||||
* a good idea -- use enter_critical_section()).
|
||||
* - The caller handles the condition that occurs if the
|
||||
* the head of the sched_mergTSTATE_TASK_PENDINGs is changed.
|
||||
*
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
*
|
||||
* Assumptions:
|
||||
* - The caller has established a critical section before calling this
|
||||
* function (calling sched_lock() first is NOT a good idea -- use irqsave()).
|
||||
* function (calling sched_lock() first is NOT a good idea -- use
|
||||
* enter_critical_section()).
|
||||
* - The caller handles the condition that occurs if the head of the
|
||||
* ready-to-run list is changed.
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/sched/sched_setparam.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
|
@ -179,7 +180,7 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param)
|
|||
|
||||
/* Stop/reset current sporadic scheduling */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
ret = sched_sporadic_reset(tcb);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -205,7 +206,7 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param)
|
|||
|
||||
/* Restore interrupts and handler errors */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <stdint.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -82,7 +84,7 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority)
|
|||
FAR struct tcb_s *rtcb = this_task();
|
||||
FAR dq_queue_t *tasklist;
|
||||
tstate_t task_state;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Verify that the requested priority is in the valid range */
|
||||
|
||||
|
@ -97,7 +99,7 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority)
|
|||
* performing the following.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* There are four cases that must be considered: */
|
||||
|
||||
|
@ -209,6 +211,6 @@ int sched_setpriority(FAR struct tcb_s *tcb, int sched_priority)
|
|||
break;
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/sched/sched_setscheduler.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2012, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -86,7 +87,7 @@ int sched_setscheduler(pid_t pid, int policy,
|
|||
FAR const struct sched_param *param)
|
||||
{
|
||||
FAR struct tcb_s *tcb;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
#ifdef CONFIG_SCHED_SPORADIC
|
||||
int errcode;
|
||||
#endif
|
||||
|
@ -131,7 +132,7 @@ int sched_setscheduler(pid_t pid, int policy,
|
|||
|
||||
/* Further, disable timer interrupts while we set up scheduling policy. */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
tcb->flags &= ~TCB_FLAG_POLICY_MASK;
|
||||
switch (policy)
|
||||
{
|
||||
|
@ -273,7 +274,7 @@ int sched_setscheduler(pid_t pid, int policy,
|
|||
#endif
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Set the new priority */
|
||||
|
||||
|
@ -284,7 +285,7 @@ int sched_setscheduler(pid_t pid, int policy,
|
|||
#ifdef CONFIG_SCHED_SPORADIC
|
||||
errout_with_irq:
|
||||
set_errno(errcode);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
sched_unlock();
|
||||
return ERROR;
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
|
@ -74,7 +75,7 @@ int sched_unlock(void)
|
|||
{
|
||||
/* Prevent context switches throughout the following */
|
||||
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
/* Decrement the preemption lock counter */
|
||||
|
||||
|
@ -183,7 +184,7 @@ int sched_unlock(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_post.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2012-2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,31 +42,13 @@
|
|||
#include <limits.h>
|
||||
#include <semaphore.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "semaphore/semaphore.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -101,7 +83,7 @@
|
|||
int sem_post(FAR sem_t *sem)
|
||||
{
|
||||
FAR struct tcb_s *stcb = NULL;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Make sure we were supplied with a valid semaphore. */
|
||||
|
@ -113,7 +95,7 @@ int sem_post(FAR sem_t *sem)
|
|||
* handler.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Perform the semaphore unlock operation. */
|
||||
|
||||
|
@ -173,7 +155,7 @@ int sem_post(FAR sem_t *sem)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_recover.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -39,35 +39,12 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "semaphore/semaphore.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -115,7 +92,7 @@ void sem_recover(FAR struct tcb_s *tcb)
|
|||
* enforce that here).
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (tcb->task_state == TSTATE_WAIT_SEM)
|
||||
{
|
||||
sem_t *sem = tcb->waitsem;
|
||||
|
@ -144,5 +121,5 @@ void sem_recover(FAR struct tcb_s *tcb)
|
|||
tcb->waitsem = NULL;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
@ -109,7 +110,7 @@ int sem_tickwait(FAR sem_t *sem, systime_t start, uint32_t delay)
|
|||
* enabled while we are blocked waiting for the semaphore.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Try to take the semaphore without waiting. */
|
||||
|
||||
|
@ -172,7 +173,7 @@ success_with_irqdisabled:
|
|||
/* Error exits */
|
||||
|
||||
errout_with_irqdisabled:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
wd_delete(rtcb->waitdog);
|
||||
rtcb->waitdog = NULL;
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_timedwait.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -134,7 +135,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime)
|
|||
* enabled while we are blocked waiting for the semaphore.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Try to take the semaphore without waiting. */
|
||||
|
||||
|
@ -205,7 +206,7 @@ int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime)
|
|||
/* Success exits */
|
||||
|
||||
success_with_irqdisabled:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
wd_delete(rtcb->waitdog);
|
||||
rtcb->waitdog = NULL;
|
||||
return OK;
|
||||
|
@ -213,7 +214,7 @@ success_with_irqdisabled:
|
|||
/* Error exits */
|
||||
|
||||
errout_with_irqdisabled:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
wd_delete(rtcb->waitdog);
|
||||
rtcb->waitdog = NULL;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <nuttx/sched.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "semaphore/semaphore.h"
|
||||
|
||||
|
@ -78,7 +78,7 @@ void sem_timeout(int argc, wdparm_t pid)
|
|||
|
||||
/* Disable interrupts to avoid race conditions */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the TCB associated with this PID. It is possible that
|
||||
* task may no longer be active when this watchdog goes off.
|
||||
|
@ -99,5 +99,5 @@ void sem_timeout(int argc, wdparm_t pid)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_trywait.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -43,6 +43,8 @@
|
|||
#include <semaphore.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -77,7 +79,7 @@
|
|||
int sem_trywait(FAR sem_t *sem)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
/* This API should not be called from interrupt handlers */
|
||||
|
@ -94,7 +96,7 @@ int sem_trywait(FAR sem_t *sem)
|
|||
* because sem_post() may be called from an interrupt handler.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Any further errors could only occurr because the semaphore is not
|
||||
* available.
|
||||
|
@ -115,7 +117,7 @@ int sem_trywait(FAR sem_t *sem)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_wait.c
|
||||
*
|
||||
* Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -43,6 +43,8 @@
|
|||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -77,7 +79,7 @@
|
|||
int sem_wait(FAR sem_t *sem)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
/* This API should not be called from interrupt handlers */
|
||||
|
@ -95,7 +97,7 @@ int sem_wait(FAR sem_t *sem)
|
|||
* handler.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if the lock is available */
|
||||
|
||||
|
@ -186,7 +188,7 @@ int sem_wait(FAR sem_t *sem)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/semaphore/sem_waitirq.c
|
||||
*
|
||||
* Copyright (C) 2007-2010, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2010, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,6 +41,8 @@
|
|||
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "semaphore/semaphore.h"
|
||||
|
@ -77,14 +79,14 @@
|
|||
|
||||
void sem_waitirq(FAR struct tcb_s *wtcb, int errcode)
|
||||
{
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts. This is necessary (unfortunately) because an
|
||||
* interrupt handler may attempt to post the semaphore while we are
|
||||
* doing this.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* It is possible that an interrupt/context switch beat us to the punch
|
||||
* and already changed the task's state.
|
||||
|
@ -124,5 +126,5 @@ void sem_waitirq(FAR struct tcb_s *wtcb, int errcode)
|
|||
|
||||
/* Interrupts may now be enabled. */
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_action.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -45,6 +45,8 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "signal/signal.h"
|
||||
|
@ -219,7 +221,7 @@ int sigaction(int signo, FAR const struct sigaction *act, FAR struct sigaction *
|
|||
* can be modified by the child thread.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Mark that status should be not be retained */
|
||||
|
||||
|
@ -228,7 +230,7 @@ int sigaction(int signo, FAR const struct sigaction *act, FAR struct sigaction *
|
|||
/* Free all pending exit status */
|
||||
|
||||
group_removechildren(rtcb->group);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_allocatependingsigaction.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,30 +41,12 @@
|
|||
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -80,7 +62,7 @@
|
|||
FAR sigq_t *sig_allocatependingsigaction(void)
|
||||
{
|
||||
FAR sigq_t *sigq;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Check if we were called from an interrupt handler. */
|
||||
|
||||
|
@ -107,9 +89,9 @@ FAR sigq_t *sig_allocatependingsigaction(void)
|
|||
{
|
||||
/* Try to get the pending signal action structure from the free list */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sigq = (FAR sigq_t *)sq_remfirst(&g_sigpendingaction);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Check if we got one. */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_deliver.c
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008, 2012-2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -45,31 +45,13 @@
|
|||
#include <sched.h>
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "semaphore/semaphore.h"
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -88,7 +70,7 @@ void sig_deliver(FAR struct tcb_s *stcb)
|
|||
FAR sigq_t *sigq;
|
||||
FAR sigq_t *next;
|
||||
sigset_t savesigprocmask;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int saved_errno;
|
||||
|
||||
sched_lock();
|
||||
|
@ -111,10 +93,10 @@ void sig_deliver(FAR struct tcb_s *stcb)
|
|||
* time, there should never be more than one signal in the sigpostedq
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_rem((FAR sq_entry_t *)sigq, &(stcb->sigpendactionq));
|
||||
sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpostedq));
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Call the signal handler (unless the signal was cancelled)
|
||||
*
|
||||
|
@ -172,9 +154,9 @@ void sig_deliver(FAR struct tcb_s *stcb)
|
|||
|
||||
/* Remove the signal from the sigpostedq */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_rem((FAR sq_entry_t *)sigq, &(stcb->sigpostedq));
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Then deallocate it */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_dispatch.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2011, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -54,22 +55,6 @@
|
|||
#include "signal/signal.h"
|
||||
#include "mqueue/mqueue.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -89,7 +74,7 @@ static int sig_queueaction(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
{
|
||||
FAR sigactq_t *sigact;
|
||||
FAR sigq_t *sigq;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
|
||||
sched_lock();
|
||||
|
@ -123,9 +108,9 @@ static int sig_queueaction(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
|
||||
/* Put it at the end of the pending signals list */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpendactionq));
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +129,7 @@ static int sig_queueaction(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
static FAR sigpendq_t *sig_allocatependingsignal(void)
|
||||
{
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Check if we were called from an interrupt handler. */
|
||||
|
||||
|
@ -172,9 +157,9 @@ static FAR sigpendq_t *sig_allocatependingsignal(void)
|
|||
{
|
||||
/* Try to get the pending signal structure from the free list */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sigpend = (FAR sigpendq_t *)sq_remfirst(&g_sigpendingsignal);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Check if we got one. */
|
||||
|
||||
|
@ -211,13 +196,13 @@ static FAR sigpendq_t *sig_findpendingsignal(FAR struct task_group_s *group,
|
|||
int signo)
|
||||
{
|
||||
FAR sigpendq_t *sigpend = NULL;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(group);
|
||||
|
||||
/* Pending sigals can be added from interrupt level. */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Seach the list for a sigpendion on this signal */
|
||||
|
||||
|
@ -225,7 +210,7 @@ static FAR sigpendq_t *sig_findpendingsignal(FAR struct task_group_s *group,
|
|||
(sigpend && sigpend->info.si_signo != signo);
|
||||
sigpend = sigpend->flink);
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
return sigpend;
|
||||
}
|
||||
|
||||
|
@ -245,7 +230,7 @@ static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb,
|
|||
{
|
||||
FAR struct task_group_s *group = stcb->group;
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(group);
|
||||
|
||||
|
@ -274,9 +259,9 @@ static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb,
|
|||
|
||||
/* Add the structure to the pending signal list */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigpend, &group->sigpendingq);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +296,7 @@ static FAR sigpendq_t *sig_addpendingsignal(FAR struct tcb_s *stcb,
|
|||
|
||||
int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
||||
{
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
|
||||
sdbg("TCB=0x%08x signo=%d code=%d value=%d mask=%08x\n",
|
||||
|
@ -333,14 +318,14 @@ int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
* from the interrupt level.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (stcb->task_state == TSTATE_WAIT_SIG &&
|
||||
sigismember(&stcb->sigwaitmask, info->si_signo))
|
||||
{
|
||||
memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
|
||||
stcb->sigwaitmask = NULL_SIGNAL_SET;
|
||||
up_unblock_task(stcb);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Its not one we are waiting for... Add it to the list of pending
|
||||
|
@ -349,7 +334,7 @@ int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
|
||||
else
|
||||
{
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
ASSERT(sig_addpendingsignal(stcb, info));
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +358,7 @@ int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
* signals can be queued from the interrupt level.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (stcb->task_state == TSTATE_WAIT_SIG)
|
||||
{
|
||||
memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
|
||||
|
@ -381,7 +366,7 @@ int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
|||
up_unblock_task(stcb);
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* If the task neither was waiting for the signal nor had a signal
|
||||
* handler attached to the signal, then the default action is
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
|
||||
|
@ -143,7 +143,7 @@ int nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp)
|
|||
* after the wait.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
starttick = clock_systimer();
|
||||
|
||||
/* Set up for the sleep. Using the empty set means that we are not
|
||||
|
@ -173,7 +173,7 @@ int nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp)
|
|||
{
|
||||
/* The timeout "error" is the normal, successful result */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ int nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp)
|
|||
(void)clock_ticks2time((int)remaining, rmtp);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
errout:
|
||||
set_errno(errval);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_pending.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,6 +42,8 @@
|
|||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "signal/signal.h"
|
||||
|
||||
|
@ -94,20 +96,20 @@ sigset_t sig_pendingset(FAR struct tcb_s *stcb)
|
|||
FAR struct task_group_s *group = stcb->group;
|
||||
sigset_t sigpendset;
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(group);
|
||||
|
||||
sigpendset = NULL_SIGNAL_SET;
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (sigpend = (FAR sigpendq_t *)group->sigpendingq.head;
|
||||
(sigpend); sigpend = sigpend->flink)
|
||||
{
|
||||
sigaddset(&sigpendset, sigpend->info.si_signo);
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
return sigpendset;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_procmask.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
@ -95,7 +96,7 @@ int sigprocmask(int how, FAR const sigset_t *set, FAR sigset_t *oset)
|
|||
{
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
sigset_t oldsigprocmask;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
|
||||
sched_lock();
|
||||
|
@ -116,7 +117,7 @@ int sigprocmask(int how, FAR const sigset_t *set, FAR sigset_t *oset)
|
|||
* ourselves from attempts to process signals from interrupts
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Okay, determine what we are supposed to do */
|
||||
|
||||
|
@ -149,7 +150,7 @@ int sigprocmask(int how, FAR const sigset_t *set, FAR sigset_t *oset)
|
|||
break;
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Now, process any pending signals that were just unmasked */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_releasependingsigaction.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,28 +41,10 @@
|
|||
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -77,7 +59,7 @@
|
|||
|
||||
void sig_releasependingsigaction(FAR sigq_t *sigq)
|
||||
{
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* If this is a generally available pre-allocated structyre,
|
||||
* then just put it back in the free list.
|
||||
|
@ -88,9 +70,9 @@ void sig_releasependingsigaction(FAR sigq_t *sigq)
|
|||
/* Make sure we avoid concurrent access to the free
|
||||
* list from interrupt handlers. */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigq, &g_sigpendingaction);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* If this is a message pre-allocated for interrupts,
|
||||
|
@ -102,9 +84,9 @@ void sig_releasependingsigaction(FAR sigq_t *sigq)
|
|||
/* Make sure we avoid concurrent access to the free
|
||||
* list from interrupt handlers. */
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigq, &g_sigpendingirqaction);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Otherwise, deallocate it. Note: interrupt handlers
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_releasependingsignal.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,32 +46,13 @@
|
|||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -86,7 +67,7 @@
|
|||
|
||||
void sig_releasependingsignal(FAR sigpendq_t *sigpend)
|
||||
{
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* If this is a generally available pre-allocated structyre,
|
||||
* then just put it back in the free list.
|
||||
|
@ -98,9 +79,9 @@ void sig_releasependingsignal(FAR sigpendq_t *sigpend)
|
|||
* list from interrupt handlers.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigpend, &g_sigpendingsignal);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* If this is a message pre-allocated for interrupts,
|
||||
|
@ -113,9 +94,9 @@ void sig_releasependingsignal(FAR sigpendq_t *sigpend)
|
|||
* list from interrupt handlers.
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigpend, &g_sigpendingirqsignal);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Otherwise, deallocate it. Note: interrupt handlers
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_removependingsignal.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2013-2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,32 +46,13 @@
|
|||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "signal/signal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -89,11 +70,11 @@ FAR sigpendq_t *sig_removependingsignal(FAR struct tcb_s *stcb, int signo)
|
|||
FAR struct task_group_s *group = stcb->group;
|
||||
FAR sigpendq_t *currsig;
|
||||
FAR sigpendq_t *prevsig;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(group);
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
for (prevsig = NULL, currsig = (FAR sigpendq_t *)group->sigpendingq.head;
|
||||
(currsig && currsig->info.si_signo != signo);
|
||||
|
@ -111,7 +92,7 @@ FAR sigpendq_t *sig_removependingsignal(FAR struct tcb_s *stcb, int signo)
|
|||
}
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
return currsig;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_suspend.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -94,7 +95,7 @@ int sigsuspend(FAR const sigset_t *set)
|
|||
sigset_t intersection;
|
||||
sigset_t saved_sigprocmask;
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int unblocksigno;
|
||||
|
||||
/* Several operations must be performed below: We must determine if any
|
||||
|
@ -104,7 +105,7 @@ int sigsuspend(FAR const sigset_t *set)
|
|||
*/
|
||||
|
||||
sched_lock(); /* Not necessary */
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if there is a pending signal corresponding to one of the
|
||||
* signals that will be unblocked by the new sigprocmask.
|
||||
|
@ -123,7 +124,7 @@ int sigsuspend(FAR const sigset_t *set)
|
|||
ASSERT(sigpend);
|
||||
|
||||
sig_releasependingsignal(sigpend);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -142,7 +143,7 @@ int sigsuspend(FAR const sigset_t *set)
|
|||
/* We are running again, restore the original sigprocmask */
|
||||
|
||||
rtcb->sigprocmask = saved_sigprocmask;
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Now, handle the (rare?) case where (a) a blocked signal was received
|
||||
* while the task was suspended but (b) restoring the original
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/signal/sig_timedwait.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2012-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -166,7 +167,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
FAR struct tcb_s *rtcb = this_task();
|
||||
sigset_t intersection;
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
int32_t waitticks;
|
||||
int ret = ERROR;
|
||||
|
||||
|
@ -180,7 +181,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
* can only be eliminated by disabling interrupts!
|
||||
*/
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if there is a pending signal corresponding to one of the
|
||||
* signals in the pending signal set argument.
|
||||
|
@ -207,7 +208,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
/* Then dispose of the pending signal structure properly */
|
||||
|
||||
sig_releasependingsignal(sigpend);
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* The return value is the number of the signal that awakened us */
|
||||
|
||||
|
@ -338,7 +339,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
|
||||
}
|
||||
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/task/task_activate.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,32 +42,9 @@
|
|||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -89,7 +66,7 @@
|
|||
|
||||
int task_activate(FAR struct tcb_s *tcb)
|
||||
{
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
||||
|
||||
|
@ -112,6 +89,6 @@ int task_activate(FAR struct tcb_s *tcb)
|
|||
#endif
|
||||
|
||||
up_unblock_task(tcb);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/task/task_reparent.c
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,16 +41,14 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "group/group.h"
|
||||
#include "task/task.h"
|
||||
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -90,7 +88,7 @@ int task_reparent(pid_t ppid, pid_t chpid)
|
|||
* the three task: Child, current parent, and new parent.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the child tasks task group */
|
||||
|
||||
|
@ -202,7 +200,7 @@ int task_reparent(pid_t ppid, pid_t chpid)
|
|||
#endif /* CONFIG_SCHED_CHILD_STATUS */
|
||||
|
||||
errout_with_ints:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
|
@ -222,7 +220,7 @@ int task_reparent(pid_t ppid, pid_t chpid)
|
|||
* the three task: Child, current parent, and new parent.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the child tasks TCB (chtcb) */
|
||||
|
||||
|
@ -314,7 +312,7 @@ int task_reparent(pid_t ppid, pid_t chpid)
|
|||
#endif /* CONFIG_SCHED_CHILD_STATUS */
|
||||
|
||||
errout_with_ints:
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -81,7 +82,7 @@ int task_restart(pid_t pid)
|
|||
FAR struct tcb_s *rtcb;
|
||||
FAR struct task_tcb_s *tcb;
|
||||
FAR dq_queue_t *tasklist;
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
int status;
|
||||
|
||||
/* Make sure this task does not become ready-to-run while
|
||||
|
@ -156,10 +157,10 @@ int task_restart(pid_t pid)
|
|||
tasklist = TLIST_HEAD(tcb->cmn.task_state);
|
||||
#endif
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
dq_rem((FAR dq_entry_t *)tcb, tasklist);
|
||||
tcb->cmn.task_state = TSTATE_TASK_INVALID;
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Deallocate anything left in the TCB's queues */
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
|
@ -101,7 +101,7 @@ int task_terminate(pid_t pid, bool nonblocking)
|
|||
{
|
||||
FAR struct tcb_s *dtcb;
|
||||
FAR dq_queue_t *tasklist;
|
||||
irqstate_t saved_state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Make sure the task does not become ready-to-run while we are futzing with
|
||||
* its TCB by locking ourselves as the executing task.
|
||||
|
@ -158,10 +158,10 @@ int task_terminate(pid_t pid, bool nonblocking)
|
|||
tasklist = TLIST_HEAD(dtcb->task_state);
|
||||
#endif
|
||||
|
||||
saved_state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
dq_rem((FAR dq_entry_t *)dtcb, tasklist);
|
||||
dtcb->task_state = TSTATE_TASK_INVALID;
|
||||
irqrestore(saved_state);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* At this point, the TCB should no longer be accessible to the system */
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
|
@ -73,9 +74,9 @@ static FAR struct posix_timer_s *timer_allocate(void)
|
|||
/* Try to get a preallocated timer from the free list */
|
||||
|
||||
#if CONFIG_PREALLOC_TIMERS > 0
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
ret = (FAR struct posix_timer_s *)sq_remfirst((FAR sq_queue_t *)&g_freetimers);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Did we get one? */
|
||||
|
||||
|
@ -103,9 +104,9 @@ static FAR struct posix_timer_s *timer_allocate(void)
|
|||
|
||||
/* And add it to the end of the list of allocated timers */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)ret, (FAR sq_queue_t *)&g_alloctimers);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <queue.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "timer/timer.h"
|
||||
|
||||
|
@ -155,7 +155,7 @@ void weak_function timer_deleteall(pid_t pid)
|
|||
FAR struct posix_timer_s *next;
|
||||
irqstate_t flags;
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next)
|
||||
{
|
||||
next = timer->flink;
|
||||
|
@ -165,7 +165,7 @@ void weak_function timer_deleteall(pid_t pid)
|
|||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_POSIX_TIMERS */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* 2. Redistributions i, 2016n binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include <queue.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "timer/timer.h"
|
||||
|
@ -68,7 +69,7 @@ static inline void timer_free(struct posix_timer_s *timer)
|
|||
|
||||
/* Remove the timer from the allocated list */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sq_rem((FAR sq_entry_t *)timer, (FAR sq_queue_t *)&g_alloctimers);
|
||||
|
||||
/* Return it to the free list if it is one of the preallocated timers */
|
||||
|
@ -77,14 +78,14 @@ static inline void timer_free(struct posix_timer_s *timer)
|
|||
if ((timer->pt_flags & PT_FLAGS_PREALLOCATED) != 0)
|
||||
{
|
||||
sq_addlast((FAR sq_entry_t *)timer, (FAR sq_queue_t *)&g_freetimers);
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Otherwise, return it to the heap */
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
sched_kfree(timer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/********************************************************************************
|
||||
* sched/timer/timer_settime.c
|
||||
*
|
||||
* Copyright (C) 2007-2010, 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2010, 2013-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
|
@ -52,18 +53,6 @@
|
|||
|
||||
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
||||
|
||||
/********************************************************************************
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Data
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Data
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Function Prototypes
|
||||
********************************************************************************/
|
||||
|
@ -310,7 +299,7 @@ int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value
|
|||
FAR struct itimerspec *ovalue)
|
||||
{
|
||||
FAR struct posix_timer_s *timer = (FAR struct posix_timer_s *)timerid;
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
int delay;
|
||||
int ret = OK;
|
||||
|
||||
|
@ -350,7 +339,7 @@ int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value
|
|||
* that the system timer is stable.
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if abstime is selected */
|
||||
|
||||
|
@ -392,7 +381,7 @@ int timer_settime(timer_t timerid, int flags, FAR const struct itimerspec *value
|
|||
1, (uint32_t)((wdparm_t)timer));
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wdog/wd_cancel.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -93,14 +94,14 @@ int wd_cancel(WDOG_ID wdog)
|
|||
{
|
||||
FAR struct wdog_s *curr;
|
||||
FAR struct wdog_s *prev;
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Prohibit timer interactions with the timer queue until the
|
||||
* cancellation is complete
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Make sure that the watchdog is initialized (non-NULL) and is still
|
||||
* active.
|
||||
|
@ -168,6 +169,6 @@ int wd_cancel(WDOG_ID wdog)
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wdog/wd_create.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,7 +42,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <queue.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
|
@ -93,14 +94,14 @@
|
|||
WDOG_ID wd_create (void)
|
||||
{
|
||||
FAR struct wdog_s *wdog;
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
|
||||
/* These actions must be atomic with respect to other tasks and also with
|
||||
* respect to interrupt handlers that may be allocating or freeing watchdog
|
||||
* timers.
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* If we are in an interrupt handler -OR- if the number of pre-allocated
|
||||
* timer structures exceeds the reserve, then take the the next timer from
|
||||
|
@ -136,7 +137,7 @@ WDOG_ID wd_create (void)
|
|||
DEBUGASSERT(g_wdnfree == 0);
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* We are in a normal tasking context AND there are not enough unreserved,
|
||||
|
@ -148,7 +149,7 @@ WDOG_ID wd_create (void)
|
|||
{
|
||||
/* We do not require that interrupts be disabled to do this. */
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
wdog = (FAR struct wdog_s *)kmm_malloc(sizeof(struct wdog_s));
|
||||
|
||||
/* Did we get one? */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wdog/wd_delete.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -43,32 +43,13 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "wdog/wdog.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -95,7 +76,7 @@
|
|||
|
||||
int wd_delete(WDOG_ID wdog)
|
||||
{
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(wdog);
|
||||
|
||||
|
@ -103,7 +84,7 @@ int wd_delete(WDOG_ID wdog)
|
|||
* it is being deallocated.
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if the watchdog has been started. */
|
||||
|
||||
|
@ -128,7 +109,7 @@ int wd_delete(WDOG_ID wdog)
|
|||
* We don't need interrupts disabled to do this.
|
||||
*/
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
sched_kfree(wdog);
|
||||
}
|
||||
|
||||
|
@ -145,7 +126,7 @@ int wd_delete(WDOG_ID wdog)
|
|||
sq_addlast((FAR sq_entry_t *)wdog, &g_wdfreelist);
|
||||
g_wdnfree++;
|
||||
DEBUGASSERT(g_wdnfree <= CONFIG_PREALLOC_WDOGS);
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/********************************************************************************
|
||||
* sched/wdog/wd_gettime.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,30 +40,10 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/wdog.h>
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include "wdog/wdog.h"
|
||||
|
||||
/********************************************************************************
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Types
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Data
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Variables
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Private Functions
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Public Functions
|
||||
********************************************************************************/
|
||||
|
@ -92,7 +72,7 @@ int wd_gettime(WDOG_ID wdog)
|
|||
|
||||
/* Verify the wdog */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (wdog && WDOG_ISACTIVE(wdog))
|
||||
{
|
||||
/* Traverse the watchdog list accumulating lag times until we find the wdog
|
||||
|
@ -107,12 +87,12 @@ int wd_gettime(WDOG_ID wdog)
|
|||
delay += curr->lag;
|
||||
if (curr == wdog)
|
||||
{
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wdog/wdog_recover.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -39,36 +39,13 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "wdog/wdog.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -103,7 +80,7 @@ void wd_recover(FAR struct tcb_s *tcb)
|
|||
* the future.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (tcb->waitdog)
|
||||
{
|
||||
(void)wd_cancel(tcb->waitdog);
|
||||
|
@ -111,5 +88,5 @@ void wd_recover(FAR struct tcb_s *tcb)
|
|||
tcb->waitdog = NULL;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wdog/wd_start.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2012, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
|
||||
|
@ -232,7 +233,7 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...)
|
|||
FAR struct wdog_s *prev;
|
||||
FAR struct wdog_s *next;
|
||||
int32_t now;
|
||||
irqstate_t state;
|
||||
irqstate_t flags;
|
||||
int i;
|
||||
|
||||
/* Verify the wdog */
|
||||
|
@ -249,7 +250,7 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...)
|
|||
* the critical section is established.
|
||||
*/
|
||||
|
||||
state = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (WDOG_ISACTIVE(wdog))
|
||||
{
|
||||
wd_cancel(wdog);
|
||||
|
@ -394,7 +395,7 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...)
|
|||
sched_timer_resume();
|
||||
#endif
|
||||
|
||||
irqrestore(state);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/wqueue/kwork_cancel.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -43,6 +43,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
|
@ -104,7 +105,7 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
|
|||
* new work is typically added to the work queue from interrupt handlers.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
if (work->worker != NULL)
|
||||
{
|
||||
/* A little test of the integrity of the work queue */
|
||||
|
@ -123,7 +124,7 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
|
|||
ret = OK;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* sched/work/work_inherit.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -49,10 +50,6 @@
|
|||
#if defined(CONFIG_SCHED_WORKQUEUE) && defined(CONFIG_SCHED_LPWORK) && \
|
||||
defined(CONFIG_PRIORITY_INHERITANCE)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -333,7 +330,7 @@ void lpwork_boostpriority(uint8_t reqprio)
|
|||
|
||||
/* Prevent context switches until we get the priorities right */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sched_lock();
|
||||
|
||||
/* Adjust the priority of every worker thread */
|
||||
|
@ -344,7 +341,7 @@ void lpwork_boostpriority(uint8_t reqprio)
|
|||
}
|
||||
|
||||
sched_unlock();
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -379,7 +376,7 @@ void lpwork_restorepriority(uint8_t reqprio)
|
|||
|
||||
/* Prevent context switches until we get the priorities right */
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
sched_lock();
|
||||
|
||||
/* Adjust the priority of every worker thread */
|
||||
|
@ -390,7 +387,7 @@ void lpwork_restorepriority(uint8_t reqprio)
|
|||
}
|
||||
|
||||
sched_unlock();
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_WORKQUEUE && CONFIG_SCHED_LPWORK && CONFIG_PRIORITY_INHERITANCE */
|
||||
|
|
|
@ -45,11 +45,10 @@
|
|||
#include <assert.h>
|
||||
#include <queue.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "wqueue/wqueue.h"
|
||||
|
||||
#ifdef CONFIG_SCHED_WORKQUEUE
|
||||
|
@ -110,7 +109,7 @@ void work_process(FAR struct kwork_wqueue_s *wqueue, systime_t period, int wndx)
|
|||
*/
|
||||
|
||||
next = period;
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the time that we started this polling cycle in clock ticks. */
|
||||
|
||||
|
@ -162,7 +161,7 @@ void work_process(FAR struct kwork_wqueue_s *wqueue, systime_t period, int wndx)
|
|||
* performed... we don't have any idea how long this will take!
|
||||
*/
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
worker(arg);
|
||||
|
||||
/* Now, unfortunately, since we re-enabled interrupts we don't
|
||||
|
@ -170,7 +169,7 @@ void work_process(FAR struct kwork_wqueue_s *wqueue, systime_t period, int wndx)
|
|||
* back at the head of the list.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
work = (FAR struct work_s *)wqueue->q.head;
|
||||
}
|
||||
else
|
||||
|
@ -264,7 +263,7 @@ void work_process(FAR struct kwork_wqueue_s *wqueue, systime_t period, int wndx)
|
|||
}
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_WORKQUEUE */
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
@ -98,7 +99,7 @@ static void work_qqueue(FAR struct kwork_wqueue_s *wqueue,
|
|||
* or interrupt handlers.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
flags = enter_critical_section();
|
||||
work->worker = worker; /* Work callback. non-NULL means queued */
|
||||
work->arg = arg; /* Callback argument */
|
||||
work->delay = delay; /* Delay until work performed */
|
||||
|
@ -109,7 +110,7 @@ static void work_qqueue(FAR struct kwork_wqueue_s *wqueue,
|
|||
|
||||
dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
|
||||
|
||||
irqrestore(flags);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
Loading…
Reference in a new issue