mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
nuttx/sched: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user