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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUF * BufReq(void){BUF *ptr;Acquire a semaphore;Disable interrupts;ptr = BufFreeList;BufFreeList = ptr->BufNext;Enable interrupts;return (ptr);}Counting semaphoreBufFreeListBufReq()Next Next Next 010BufRel()Buffer Managervoid BufRel(BUF *ptr){Disable interrupts;ptr->BufNext = BufFreeList;BufFreeList = ptr;Enable interrupts;Release semaphore;}Task1Task22-33Deadlock• To avoid a deadlock the tasks is– Acquire all resources before proceeding– Acquire the resources in the same order– Release the resources in the reverse order• Using timeout when acquiring a semaphore– When a timeout occur, a return error code prevents the task formthinking it has obtained the resource.• Deadlocks generally occur in large multitasking systems,not in embedded systems2-34

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

Saved successfully!

Ooh no, something went wrong!