Associated Name A Unique ID A Priority (If Part of A Pre-Emptive Scheduling Plan) A Task Control Block (TCB) A Stack and A Task Routine Task Objects
Associated Name A Unique ID A Priority (If Part of A Pre-Emptive Scheduling Plan) A Task Control Block (TCB) A Stack and A Task Routine Task Objects
ready state-the task is ready to run but cannot because a higher priority task is
executing.·
blocked state-the task has requested a resource that is not available, has requested
to wait until some event occurs, or has delayed itself for some duration.
running state-the task is the highest priority task and is running.
Some other states are
Suspended, Pended, and Delayed.
Pended and delayed are actually sub-states of
the blocked state.
A pended task is waiting for a resource that it
needs to be freed; a delayed task is waiting
for a timing delay to end.
The suspended state exists for debugging
purposes.
SEMAPHORES
Bounded count:
Count in which initial count set for counting
semaphore, determine when the semaphore
was first created acts as the maximum count
for the semaphore.
Unbounded count:
Allow counting semaphore to count beyond
the initial count to the maximum value that
can be held by the counter’s data type
Mutual Exclusion (Mutex) Semaphores
Implementation
* A lock countkeep track of
--Two states of a mutex
0 for unlocked and 1 for locked
And the number of timesit has been recursively locked
Lock count > 1
Implementation: a mutexmight maintain two counts
A binary value to track its state
A separate lock countto track the number of
times it has been acquired in the lock state
Implementation: a mutexmight maintain two counts
A binary valueto track its state
A separate lock countto track the number of times
it has been acquired in the lock state by the task
owns it
by the task owns it
Initializing Semaphores
The function SemCreate is used to initialize
the semaphore.
Semaphore must be initialized before
attempting to do any operation on it.
Reentrancy and Semaphore
In data sharing, the resources are protected
by semaphores.
The second task that calls the semaphore for
the second time will be blocked.
We can make the function reentrant.
The atomicity of operation of the function
will be protected by the semaphore.
Multiple Semaphore
RTOS allow us to have as many semaphores as we like.
Each call to the RTOS must identify the semaphore on
which to operate.
The semaphores are all independent of one another.
If one task take semaphore A another task can take
semaphore B without blocking.
Similarly if one task is waiting for semaphore
C that task will still be blocked even if some other task
releases semaphore D.