nuttx/sched: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()

This commit is contained in:
Gregory Nutt
2016-02-14 08:17:46 -06:00
parent 2244ed46bc
commit 6e3107650d
69 changed files with 368 additions and 819 deletions
+3 -3
View File
@@ -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
+3 -3
View File
@@ -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,
+3 -6
View File
@@ -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 */
+4 -7
View File
@@ -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;
}
+7 -10
View File
@@ -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
+8 -27
View File
@@ -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
+4 -11
View File
@@ -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
+6 -5
View File
@@ -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);
}
}
}
+3 -3
View File
@@ -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;
}
+7 -26
View File
@@ -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
+5 -24
View File
@@ -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 */
+6 -24
View File
@@ -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:
+6 -25
View File
@@ -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
+10 -29
View File
@@ -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;
}
+9 -24
View File
@@ -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:
+12 -27
View File
@@ -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;
+5 -24
View File
@@ -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);
}
+8 -23
View File
@@ -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). */
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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;
}
+6 -3
View File
@@ -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);
}
+6 -33
View File
@@ -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
{
+6 -21
View File
@@ -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.
+2 -2
View File
@@ -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.
*
+2 -1
View File
@@ -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.
*
+4 -3
View File
@@ -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;
+5 -3
View File
@@ -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;
}
+6 -5
View File
@@ -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
+3 -2
View File
@@ -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;
+6 -24
View File
@@ -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;
+4 -27
View File
@@ -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);
}
+3 -2
View File
@@ -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;
+5 -4
View File
@@ -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;
+3 -3
View File
@@ -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);
}
+6 -4
View File
@@ -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;
+6 -4
View File
@@ -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;
+6 -4
View File
@@ -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);
}
+1
View File
@@ -43,6 +43,7 @@
#include <assert.h>
#include <nuttx/spinlock.h>
#include <arch/irq.h>
#include "sched/sched.h"
+5 -3
View File
@@ -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
+6 -24
View File
@@ -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. */
+8 -26
View File
@@ -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 */
+20 -35
View File
@@ -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
+4 -4
View File
@@ -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);
+6 -4
View File
@@ -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;
}
+5 -4
View File
@@ -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 */
+8 -26
View File
@@ -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
+7 -26
View File
@@ -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
+5 -24
View File
@@ -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;
}
+6 -5
View File
@@ -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

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