TAILIEUCHUNG - Program C Ansi Programming Embedded Systems in C and C++ phần 6

Tham khảo tài liệu 'program c ansi programming embedded systems in c and c++ phần 6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | state as volatile. Doing so would prevent the compiler from incorrectly assuming that the timer s state is either done or not done and optimizing away the while loop. 3 3 A word of caution about waitfor this implementation spins its wheels waiting for the software timer to change to the done state. This technique is called busy-waiting and it is neither elegant nor an efficient use of the processor. In Chapter 8 we ll see how the introduction of an operating system allows us to improve upon this implementation. The final method of the Timer class is used to cancel a running timer. This is easy to implement because we need only remove the timer from the timer list and change its state to Idle. The code that actually does this is shown here Method cancel Description Stop a running timer. Notes Returns None defined. void Timer cancel void Remove the timer from the timer list. if state Active this Reset the timer s state. state Idle cancel Of course there is also a destructor for the Timer class though I won t show the code here. Suffice it to say that it just checks to see if the software timer is active and if so removes it from the timer list. This prevents a periodic timer that has gone out of scope from remaining in the timer list indefinitely and any pointers to the dead timer from remaining in the system. For completeness it might be nice to add a public method perhaps called poll that allows users of the Timer class to test the state of a software timer without blocking. In the interest of space I have left this out of my implementation but it would be easy to add such a routine. It need only return the current value of the comparison state Done. However in order to do this some technique would need to be devised to restart periodic timers for which waitfor is never called. Watchdog Timers Another type of timer you might hear mentioned frequently in reference to embedded systems is a watchdog timer. This is a special piece of hardware that .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.