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
+4 -3
View File
@@ -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;
}
+6 -9
View File
@@ -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 */
+5 -6
View File
@@ -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 */
+3 -2
View File
@@ -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);
}
/****************************************************************************