Priority Inversion
// Data acquisition thread
ImportantTask()
{
SSetPriority(HIGHEST)
While(TRUE)
{
//...
Sleep(1 second)
AcquireSemaphore(pDatabaseSem)
// ... work on database
ReleaseSemaphore(pDatabaseSem)
}
}
// Database statistics thread
MenialTask()
{
SetPriority(LOWEST)
While(TRUE)
{
//...
Sleep(5 minutes)
AcquireSemaphore(pDatabaseSem)
//... check database statistics
ReleaseSemaphore(pDatabaseSem)
}
}