关闭中断进行全局变量的访问
更多...
关闭中断进行全局变量的访问
源码
#include <rthw.h>
#include <rtthread.h>
#define THREAD_PRIORITY 20
#define THREAD_STACK_SIZE 512
#define THREAD_TIMESLICE 5
void thread_entry(void *parameter)
{
while (1)
{
cnt += no;
rt_kprintf(
"protect thread[%d]'s counter is %d\n", no, cnt);
}
}
int interrupt_sample(void)
{
THREAD_STACK_SIZE,
THREAD_PRIORITY, THREAD_TIMESLICE);
THREAD_STACK_SIZE,
THREAD_PRIORITY, THREAD_TIMESLICE);
return 0;
}