From: bernie Date: Fri, 29 Aug 2008 20:36:39 +0000 (+0000) Subject: preempt_forbid_cnt: make it of type cpuatomic_t X-Git-Tag: 2.0.0~174 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=1200cce6f786accd1e56bfe1982b3c58d297aee7;p=bertos.git preempt_forbid_cnt: make it of type cpuatomic_t 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 --- diff --git a/bertos/kern/preempt.c b/bertos/kern/preempt.c index 2c44373b..69b555a9 100644 --- a/bertos/kern/preempt.c +++ b/bertos/kern/preempt.c @@ -65,8 +65,8 @@ CONFIG_DEPEND(CONFIG_KERN_PREEMPT, CONFIG_KERN_SCHED && CONFIG_TIMER_EVENTS & MOD_DEFINE(preempt) -/** Global preemption disabling nesting counter */ -int _preempt_forbid_cnt; +/// Global preemption disabling nesting counter +cpuatomic_t _preempt_forbid_cnt; static Timer preempt_timer; diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 5c264652..4efdf9df 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -108,7 +108,7 @@ const char *proc_currentName(void); 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. @@ -156,7 +156,7 @@ INLINE void proc_permit(void) * 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; @@ -178,7 +178,7 @@ INLINE void proc_permit(void) 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;