Professional Documents
Culture Documents
Module 4 - 3
Module 4 - 3
The three common model stratergies that a scheduler may adopt are:
An embedded system with a single CPU can run only one process at an
instance,process may be either ISR,Scheduler or task.
For designing the codes for synchronization between the
processes,the following fifteen points must be taken into account.
Contd…
1.Use appropriate precedence assignment stratergy
2.The ISR can only write the messages for an RTOS and parameters for the tasks. No
ISR instruction should not block any task apart from RTOS.The variables and task
switching flags must always be under the RTOS control.
3.The ISR coding should be like a reentrant function with no shared data problems.
The ISR should be short and execute the codes that should not wait for actions by
the RTOS and tasks.
4.A task should not call another task as each task has to be under the RTOS
control.Such an attempt should generate an error.
5.A task can get the messages and send the messages using the RTOS calls only.
Contd..
6.While executing the critical section codes,if possible,instead of
disabling the interrupts only the task switching flag changes should be
prevented.Disabling preemption may be better than disabling
interrupts.Howeever,both increase worst case interrupt latencies.
7. Resource locking using the mutex semaphores may be better than
disabling preemption or interrupts.
8.A task should take the semaphore only during a short period in which
critical section alone is executed.Disabling of running of other tasks for
a longer period increases the worst case interrupt latency periods for
all interrupts.
Contd..
9.Relative response times improve on multitasking but a limited number of
multiple tasks should be preferred.It reduces the context switching intervals
and stack needs.Otherwise,the response time advantages are lost and sum of
the stacks for each task needs a larger memory.
10.Get a semaphore takes the least CPU time.
11.Create a tasks at start-up only and avoid creating and deleting task
later.The only advantage of deleting is the availability of additional memory
space.
12.Semaphores,queues,and messages should not be globally shared
variables,and each should be shared between a set of tasks only and
encapsulated later.
Contd…
13.Use idle CPU time for internal functions.Often,the CPU may not be
running any task.All tasks may be waiting for preemption .The CPU at
that instant may associate the RTOS for the following .Read the internal
queue.Manage the memory.Search for a free block of memory.Delete
or dispatch a task.Perform the internal and inter process
communication functions.
14.If memory allocation and dellocation is done by the task the number
of RTOS functions is reduced.This reduces the interrupt-latency periods
as execution of these function takes significant time by the RTOS
whenever the RTOS preempts a task.
Contd…
13.Use idle CPU time for internal functions.Often,the CPU may not be
running any task.All tasks may be waiting for preemption .The CPU at
that instant may associate the RTOS for the following .Read or a free
block of memory.Delete or dispatch a task.Perform the internal and
inter process communication functions.
14.If memory allocation and dellocation is done by the task the number
of RTOS functions is reduced.This reduces the interrupt-latency periods
as execution of these function takes significant time by the RTOS
whenever the RTOS preempts a task.
Contd…
15.Use a configurable or hierarchial RTOS ,which can put only the
needed functions from the scheduler with the rest outside.