Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问Flash读写会不会有被中断打断的隐患 #141

Open
heluozhijian opened this issue Jun 17, 2022 · 9 comments
Open

请问Flash读写会不会有被中断打断的隐患 #141

heluozhijian opened this issue Jun 17, 2022 · 9 comments

Comments

@heluozhijian
Copy link

当有RTOS的情况下,lock和unlock通过信号量实现,请问会不会存在“flash_write”的时候被中断打断的隐患?

/**
 * lock the ENV ram cache
 */
void ef_port_env_lock(void) {
    rt_sem_take(&env_cache_lock, RT_WAITING_FOREVER);
}

/**
 * unlock the ENV ram cache
 */
void ef_port_env_unlock(void) {
    rt_sem_release(&env_cache_lock);
}
@armink
Copy link
Owner

armink commented Jun 17, 2022

如果你写 flash 时候中断是开的,肯定有这个可能

@heluozhijian
Copy link
Author

嗯,实际应用的时候一般都有中断,这里的信号量估计得用开关中断,或者进入临界区来保护

@armink
Copy link
Owner

armink commented Jun 18, 2022

为什么呢?你要在中断里使用 EasyFlash ?

@heluozhijian
Copy link
Author

那倒不是,我的意思在普通的任务中使用EasyFlash,那么EasyFlash在写入数据的时候,会不会被串口接收中断、脉冲捕获中断之类的干扰了?不是在中断服务函数里使用EasyFlash。

@heluozhijian
Copy link
Author

lock和unlock之间的代码会被别的中断打断吗

@armink
Copy link
Owner

armink commented Jun 18, 2022

lock 目的就是为了锁住上下文,如果你中断中不使用 EasyFlash 那就没事的

@heluozhijian
Copy link
Author

好的,谢谢你的回复和工作成果。准备在GD32+FreeRTOS项目中使用EasyFlash。

@armink
Copy link
Owner

armink commented Jun 18, 2022

@heluozhijian
Copy link
Author

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants