11.07.2015 Views

Chapter 2 Real-Time Systems Concepts Foreground/Background ...

Chapter 2 Real-Time Systems Concepts Foreground/Background ...

Chapter 2 Real-Time Systems Concepts Foreground/Background ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• Disabling and enabling interruptsDisable interrupts;Access the resource (read/write from/to variables);Reenable interrupts;• uc/OS-II provides two macros to disable/enable interruptvoid Function (void){OS_ENTER_CRITICAL();.. /* You can access shared data in here */.OS_EXIT_CRITICAL();}• Not to disable interrupts for too long– Affect the response of your system to interrupts (interrupt latency)2-25• Test-and-Set (TAS)Disable interrupts;if (‘Access Variable ’ is 0) {Set variable to 1;Reenable interrupts;Access the resource;Disable interrupts;Set the ‘Access Variable’back to 0;Reenable interrupts;} else {Reenable interrupts;/* You don’t have access to the resource, try back later; */}• Some processor actually implement a TAS operation inhardware (e.g., 68000 family)2-26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!