This takes care of archs such as the AVR, where int is bigger than the
word size, and updating preempt_forbid_cnt might actually result in two
independent writes.
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1760
38d2e660-2303-0410-9eaa-
f027e97ec537
-/** Global preemption disabling nesting counter */
-int _preempt_forbid_cnt;
+/// Global preemption disabling nesting counter
+cpuatomic_t _preempt_forbid_cnt;
static Timer preempt_timer;
static Timer preempt_timer;
INLINE void proc_forbid(void)
{
#if CONFIG_KERN_PREEMPT
INLINE void proc_forbid(void)
{
#if CONFIG_KERN_PREEMPT
- extern int _preempt_forbid_cnt;
+ extern cpuatomic_t _preempt_forbid_cnt;
/*
* We don't need to protect the counter against other processes.
* The reason why is a bit subtle.
/*
* We don't need to protect the counter against other processes.
* The reason why is a bit subtle.
* flushed to memory before task switching is re-enabled.
*/
MEMORY_BARRIER;
* flushed to memory before task switching is re-enabled.
*/
MEMORY_BARRIER;
- extern int _preempt_forbid_cnt;
+ extern cpuatomic_t _preempt_forbid_cnt;
/* No need to protect against interrupts here. */
ASSERT(_preempt_forbid_cnt != 0);
--_preempt_forbid_cnt;
/* No need to protect against interrupts here. */
ASSERT(_preempt_forbid_cnt != 0);
--_preempt_forbid_cnt;
INLINE bool proc_allowed(void)
{
#if CONFIG_KERN_PREEMPT
INLINE bool proc_allowed(void)
{
#if CONFIG_KERN_PREEMPT
- extern int _preempt_forbid_cnt;
+ extern cpuatomic_t _preempt_forbid_cnt;
return (_preempt_forbid_cnt == 0);
#else
return true;
return (_preempt_forbid_cnt == 0);
#else
return true;