2013年2月19日 星期二

volatile的用法



使用前提: 如果一個global變數宣告再某個地方, 但有可能又被另一個program作修改, 而compiler不知道的話, 那就需要加上volatile


Use

A variable should be declared volatile whenever its value could change unexpectedly. In practice, only three types of variables could change:

  • Memory-mapped peripheral registers
  • Global variables modified by an interrupt service routine
  • Global variables within a multi-threaded application

http://www.embedded.com/electronics-blogs/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword



沒有留言:

張貼留言