<s>
A	O
real-time	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
(	O
RTOS	B-Operating_System
)	O
is	O
an	O
operating	B-General_Concept
system	I-General_Concept
(	O
OS	O
)	O
for	O
real-time	B-General_Concept
computing	I-General_Concept
applications	O
that	O
processes	O
data	O
and	O
events	O
that	O
have	O
critically	O
defined	O
time	O
constraints	O
.	O
</s>
<s>
An	O
RTOS	B-Operating_System
is	O
distinct	O
from	O
a	O
time-sharing	B-General_Concept
operating	I-General_Concept
system	I-General_Concept
,	O
such	O
as	O
Unix	B-Application
,	O
which	O
manages	O
the	O
sharing	O
of	O
system	O
resources	O
with	O
a	O
scheduler	O
,	O
data	O
buffers	O
,	O
or	O
fixed	O
task	B-General_Concept
prioritization	O
in	O
a	O
multitasking	B-Operating_System
or	O
multiprogramming	O
environment	O
.	O
</s>
<s>
Real-time	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
are	O
event-driven	B-Application
and	O
preemptive	B-Operating_System
,	O
meaning	O
the	O
OS	O
can	O
monitor	O
the	O
relevant	O
priority	O
of	O
competing	O
tasks	O
,	O
and	O
make	O
changes	O
to	O
the	O
task	B-General_Concept
priority	O
.	O
</s>
<s>
Event-driven	B-Application
systems	O
switch	O
between	O
tasks	O
based	O
on	O
their	O
priorities	O
,	O
while	O
time-sharing	B-General_Concept
systems	I-General_Concept
switch	O
the	O
task	B-General_Concept
based	O
on	O
clock	O
interrupts	B-Application
.	O
</s>
<s>
A	O
key	O
characteristic	O
of	O
an	O
RTOS	B-Operating_System
is	O
the	O
level	O
of	O
its	O
consistency	O
concerning	O
the	O
amount	O
of	O
time	O
it	O
takes	O
to	O
accept	O
and	O
complete	O
an	O
application	O
's	O
task	B-General_Concept
;	O
the	O
variability	O
is	O
'	O
jitter	O
 '	O
.	O
</s>
<s>
A	O
'	O
hard	O
 '	O
real-time	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
(	O
hard	O
RTOS	B-Operating_System
)	O
has	O
less	O
jitter	O
than	O
a	O
'	O
soft	O
 '	O
real-time	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
(	O
soft	O
RTOS	B-Operating_System
)	O
.	O
</s>
<s>
A	O
late	O
answer	O
is	O
a	O
wrong	O
answer	O
in	O
a	O
hard	O
RTOS	B-Operating_System
while	O
a	O
late	O
answer	O
is	O
acceptable	O
in	O
a	O
soft	O
RTOS	B-Operating_System
.	O
</s>
<s>
An	O
RTOS	B-Operating_System
that	O
can	O
usually	O
or	O
generally	O
meet	O
a	O
deadline	O
is	O
a	O
soft	O
real-time	B-Operating_System
OS	I-Operating_System
,	O
but	O
if	O
it	O
can	O
meet	O
a	O
deadline	O
deterministically	B-General_Concept
it	O
is	O
a	O
hard	O
real-time	B-Operating_System
OS	I-Operating_System
.	O
</s>
<s>
An	O
RTOS	B-Operating_System
has	O
an	O
advanced	O
algorithm	O
for	O
scheduling	O
.	O
</s>
<s>
Scheduler	O
flexibility	O
enables	O
a	O
wider	O
,	O
computer-system	O
orchestration	O
of	O
process	O
priorities	O
,	O
but	O
a	O
real-time	B-Operating_System
OS	I-Operating_System
is	O
more	O
frequently	O
dedicated	O
to	O
a	O
narrow	O
set	O
of	O
applications	O
.	O
</s>
<s>
Key	O
factors	O
in	O
a	O
real-time	B-Operating_System
OS	I-Operating_System
are	O
minimal	O
interrupt	B-General_Concept
latency	I-General_Concept
and	O
minimal	O
thread	B-Operating_System
switching	O
latency	O
;	O
a	O
real-time	B-Operating_System
OS	I-Operating_System
is	O
valued	O
more	O
for	O
how	O
quickly	O
or	O
how	O
predictably	O
it	O
can	O
respond	O
than	O
for	O
the	O
amount	O
of	O
work	O
it	O
can	O
perform	O
in	O
a	O
given	O
period	O
of	O
time	O
.	O
</s>
<s>
See	O
the	O
comparison	B-Operating_System
of	I-Operating_System
real-time	I-Operating_System
operating	I-Operating_System
systems	I-Operating_System
for	O
a	O
comprehensive	O
list	O
.	O
</s>
<s>
Also	O
,	O
see	O
the	O
list	B-Operating_System
of	I-Operating_System
operating	I-Operating_System
systems	I-Operating_System
for	O
all	O
types	O
of	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
An	O
RTOS	B-Operating_System
is	O
an	O
operating	B-General_Concept
system	I-General_Concept
in	O
which	O
the	O
time	O
taken	O
to	O
process	O
an	O
input	O
stimulus	O
is	O
less	O
than	O
the	O
time	O
lapsed	O
until	O
the	O
next	O
input	O
stimulus	O
of	O
the	O
same	O
type	O
.	O
</s>
<s>
Event-driven	B-Application
–	O
switches	B-Operating_System
tasks	I-Operating_System
only	O
when	O
an	O
event	O
of	O
higher	O
priority	O
needs	O
servicing	O
;	O
called	O
preemptive	B-Operating_System
priority	I-Operating_System
,	O
or	O
priority	O
scheduling	O
.	O
</s>
<s>
Time-sharing	B-General_Concept
–	O
switches	B-Operating_System
tasks	I-Operating_System
on	O
a	O
regular	O
clocked	O
interrupt	B-Application
,	O
and	O
on	O
events	O
;	O
called	O
round	B-Algorithm
robin	I-Algorithm
.	O
</s>
<s>
Time	B-General_Concept
sharing	I-General_Concept
designs	O
switch	O
tasks	O
more	O
often	O
than	O
strictly	O
needed	O
,	O
but	O
give	O
smoother	O
multitasking	B-Operating_System
,	O
giving	O
the	O
illusion	O
that	O
a	O
process	O
or	O
user	O
has	O
sole	O
use	O
of	O
a	O
machine	O
.	O
</s>
<s>
Early	O
CPU	B-General_Concept
designs	I-General_Concept
needed	O
many	O
cycles	O
to	O
switch	O
tasks	O
during	O
which	O
the	O
CPU	B-General_Concept
could	O
do	O
nothing	O
else	O
useful	O
.	O
</s>
<s>
Because	O
switching	O
took	O
so	O
long	O
,	O
early	O
OSes	O
tried	O
to	O
minimize	O
wasting	O
CPU	B-General_Concept
time	O
by	O
avoiding	O
unnecessary	O
task	B-General_Concept
switching	O
.	O
</s>
<s>
In	O
typical	O
designs	O
,	O
a	O
task	B-General_Concept
has	O
three	O
states	O
:	O
</s>
<s>
Running	O
(	O
executing	O
on	O
the	O
CPU	B-General_Concept
)	O
;	O
</s>
<s>
Most	O
tasks	O
are	O
blocked	O
or	O
ready	O
most	O
of	O
the	O
time	O
because	O
generally	O
only	O
one	O
task	B-General_Concept
can	O
run	O
at	O
a	O
time	O
per	O
CPU	B-General_Concept
.	O
</s>
<s>
On	O
simpler	O
non-preemptive	O
but	O
still	O
multitasking	B-Operating_System
systems	O
,	O
a	O
task	B-General_Concept
has	O
to	O
give	O
up	O
its	O
time	O
on	O
the	O
CPU	B-General_Concept
to	O
other	O
tasks	O
,	O
which	O
can	O
cause	O
the	O
ready	O
queue	O
to	O
have	O
a	O
greater	O
number	O
of	O
overall	O
tasks	O
in	O
the	O
ready	O
to	O
be	O
executed	O
state	O
(	O
resource	B-Operating_System
starvation	I-Operating_System
)	O
.	O
</s>
<s>
Usually	O
,	O
the	O
data	O
structure	O
of	O
the	O
ready	O
list	O
in	O
the	O
scheduler	O
is	O
designed	O
to	O
minimize	O
the	O
worst-case	O
length	O
of	O
time	O
spent	O
in	O
the	O
scheduler	O
's	O
critical	B-Operating_System
section	I-Operating_System
,	O
during	O
which	O
preemption	B-Operating_System
is	O
inhibited	O
,	O
and	O
,	O
in	O
some	O
cases	O
,	O
all	O
interrupts	B-Application
are	O
disabled	O
,	O
but	O
the	O
choice	O
of	O
data	O
structure	O
depends	O
also	O
on	O
the	O
maximum	O
number	O
of	O
tasks	O
that	O
can	O
be	O
on	O
the	O
ready	O
list	O
.	O
</s>
<s>
If	O
there	O
are	O
never	O
more	O
than	O
a	O
few	O
tasks	O
on	O
the	O
ready	O
list	O
,	O
then	O
a	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
of	O
ready	O
tasks	O
is	O
likely	O
optimal	O
.	O
</s>
<s>
That	O
way	O
,	O
finding	O
the	O
highest	O
priority	O
task	B-General_Concept
to	O
run	O
does	O
not	O
require	O
iterating	O
through	O
the	O
entire	O
list	O
.	O
</s>
<s>
Inserting	O
a	O
task	B-General_Concept
then	O
requires	O
walking	O
the	O
ready	O
list	O
until	O
reaching	O
either	O
the	O
end	O
of	O
the	O
list	O
,	O
or	O
a	O
task	B-General_Concept
of	O
lower	O
priority	O
than	O
that	O
of	O
the	O
task	B-General_Concept
being	O
inserted	O
.	O
</s>
<s>
Care	O
must	O
be	O
taken	O
not	O
to	O
inhibit	O
preemption	B-Operating_System
during	O
this	O
search	O
.	O
</s>
<s>
Longer	O
critical	B-Operating_System
sections	I-Operating_System
should	O
be	O
divided	O
into	O
small	O
pieces	O
.	O
</s>
<s>
If	O
an	O
interrupt	B-Application
occurs	O
that	O
makes	O
a	O
high	O
priority	O
task	B-General_Concept
ready	O
during	O
the	O
insertion	O
of	O
a	O
low	O
priority	O
task	B-General_Concept
,	O
that	O
high	O
priority	O
task	B-General_Concept
can	O
be	O
inserted	O
and	O
run	O
immediately	O
before	O
the	O
low	O
priority	O
task	B-General_Concept
is	O
inserted	O
.	O
</s>
<s>
The	O
critical	O
response	O
time	O
,	O
sometimes	O
called	O
the	O
flyback	O
time	O
,	O
is	O
the	O
time	O
it	O
takes	O
to	O
queue	O
a	O
new	O
ready	O
task	B-General_Concept
and	O
restore	O
the	O
state	O
of	O
the	O
highest	O
priority	O
task	B-General_Concept
to	O
running	O
.	O
</s>
<s>
In	O
a	O
well-designed	O
RTOS	B-Operating_System
,	O
readying	O
a	O
new	O
task	B-General_Concept
will	O
take	O
3	O
to	O
20	O
instructions	O
per	O
ready-queue	O
entry	O
,	O
and	O
restoration	O
of	O
the	O
highest-priority	O
ready	O
task	B-General_Concept
will	O
take	O
5	O
to	O
30	O
instructions	O
.	O
</s>
<s>
Some	O
commonly	O
used	O
RTOS	B-Operating_System
scheduling	O
algorithms	O
are	O
:	O
</s>
<s>
A	O
multitasking	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
like	O
Unix	B-Application
is	O
poor	O
at	O
real-time	O
tasks	O
.	O
</s>
<s>
Multitasking	B-Operating_System
systems	O
must	O
manage	O
sharing	O
data	O
and	O
hardware	O
resources	O
among	O
multiple	O
tasks	O
.	O
</s>
<s>
General-purpose	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
usually	O
do	O
not	O
allow	O
user	O
programs	O
to	O
mask	O
(	O
disable	O
)	O
interrupts	B-Application
,	O
because	O
the	O
user	O
program	O
could	O
control	O
the	O
CPU	B-General_Concept
for	O
as	O
long	O
as	O
it	O
is	O
made	O
to	O
.	O
</s>
<s>
Some	O
modern	O
CPUs	O
do	O
not	O
allow	O
user	B-Operating_System
mode	I-Operating_System
code	O
to	O
disable	O
interrupts	B-Application
as	O
such	O
control	O
is	O
considered	O
a	O
key	O
operating	B-General_Concept
system	I-General_Concept
resource	O
.	O
</s>
<s>
Many	O
embedded	B-Architecture
systems	I-Architecture
and	O
RTOSs	O
,	O
however	O
,	O
allow	O
the	O
application	O
itself	O
to	O
run	O
in	O
kernel	O
mode	O
for	O
greater	O
system	B-Operating_System
call	I-Operating_System
efficiency	O
and	O
also	O
to	O
permit	O
the	O
application	O
to	O
have	O
greater	O
control	O
of	O
the	O
operating	O
environment	O
without	O
requiring	O
OS	O
intervention	O
.	O
</s>
<s>
On	O
single-processor	O
systems	O
,	O
an	O
application	O
running	O
in	O
kernel	O
mode	O
and	O
masking	O
interrupts	B-Application
is	O
the	O
lowest	O
overhead	O
method	O
to	O
prevent	O
simultaneous	O
access	O
to	O
a	O
shared	O
resource	O
.	O
</s>
<s>
While	O
interrupts	B-Application
are	O
masked	O
and	O
the	O
current	O
task	B-General_Concept
does	O
not	O
make	O
a	O
blocking	O
OS	O
call	O
,	O
the	O
current	O
task	B-General_Concept
has	O
exclusive	O
use	O
of	O
the	O
CPU	B-General_Concept
since	O
no	O
other	O
task	B-General_Concept
or	O
interrupt	B-Application
can	O
take	O
control	O
,	O
so	O
the	O
critical	B-Operating_System
section	I-Operating_System
is	O
protected	O
.	O
</s>
<s>
When	O
the	O
task	B-General_Concept
exits	O
its	O
critical	B-Operating_System
section	I-Operating_System
,	O
it	O
must	O
unmask	O
interrupts	B-Application
;	O
pending	O
interrupts	B-Application
,	O
if	O
any	O
,	O
will	O
then	O
execute	O
.	O
</s>
<s>
Temporarily	O
masking	O
interrupts	B-Application
should	O
only	O
be	O
done	O
when	O
the	O
longest	O
path	O
through	O
the	O
critical	B-Operating_System
section	I-Operating_System
is	O
shorter	O
than	O
the	O
desired	O
maximum	O
interrupt	B-General_Concept
latency	I-General_Concept
.	O
</s>
<s>
Typically	O
this	O
method	O
of	O
protection	O
is	O
used	O
only	O
when	O
the	O
critical	B-Operating_System
section	I-Operating_System
is	O
just	O
a	O
few	O
instructions	O
and	O
contains	O
no	O
loops	O
.	O
</s>
<s>
When	O
the	O
shared	O
resource	O
must	O
be	O
reserved	O
without	O
blocking	O
all	O
other	O
tasks	O
(	O
such	O
as	O
waiting	O
for	O
Flash	O
memory	O
to	O
be	O
written	O
)	O
,	O
it	O
is	O
better	O
to	O
use	O
mechanisms	O
also	O
available	O
on	O
general-purpose	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
,	O
such	O
as	O
a	O
mutex	B-Operating_System
and	O
OS-supervised	O
interprocess	O
messaging	O
.	O
</s>
<s>
Such	O
mechanisms	O
involve	O
system	B-Operating_System
calls	I-Operating_System
,	O
and	O
usually	O
invoke	O
the	O
OS	O
's	O
dispatcher	O
code	O
on	O
exit	O
,	O
so	O
they	O
typically	O
take	O
hundreds	O
of	O
CPU	B-General_Concept
instructions	O
to	O
execute	O
,	O
while	O
masking	O
interrupts	B-Application
may	O
take	O
as	O
few	O
as	O
one	O
instruction	O
on	O
some	O
processors	O
.	O
</s>
<s>
A	O
(	O
non-recursive	O
)	O
mutex	B-Operating_System
is	O
either	O
locked	O
or	O
unlocked	O
.	O
</s>
<s>
When	O
a	O
task	B-General_Concept
has	O
locked	O
the	O
mutex	B-Operating_System
,	O
all	O
other	O
tasks	O
must	O
wait	O
for	O
the	O
mutex	B-Operating_System
to	O
be	O
unlocked	O
by	O
its	O
owner	O
-	O
the	O
original	O
thread	B-Operating_System
.	O
</s>
<s>
A	O
task	B-General_Concept
may	O
set	O
a	O
timeout	O
on	O
its	O
wait	O
for	O
a	O
mutex	B-Operating_System
.	O
</s>
<s>
There	O
are	O
several	O
well-known	O
problems	O
with	O
mutex	B-Operating_System
based	O
designs	O
such	O
as	O
priority	B-Operating_System
inversion	I-Operating_System
and	O
deadlocks	B-Operating_System
.	O
</s>
<s>
In	O
priority	B-Operating_System
inversion	I-Operating_System
a	O
high	O
priority	O
task	B-General_Concept
waits	O
because	O
a	O
low	O
priority	O
task	B-General_Concept
has	O
a	O
mutex	B-Operating_System
,	O
but	O
the	O
lower	O
priority	O
task	B-General_Concept
is	O
not	O
given	O
CPU	B-General_Concept
time	O
to	O
finish	O
its	O
work	O
.	O
</s>
<s>
A	O
typical	O
solution	O
is	O
to	O
have	O
the	O
task	B-General_Concept
that	O
owns	O
a	O
mutex	B-Operating_System
'	O
inherit	O
 '	O
the	O
priority	O
of	O
the	O
highest	O
waiting	O
task	B-General_Concept
.	O
</s>
<s>
But	O
this	O
simple	O
approach	O
gets	O
more	O
complex	O
when	O
there	O
are	O
multiple	O
levels	O
of	O
waiting	O
:	O
task	B-General_Concept
A	O
waits	O
for	O
a	O
mutex	B-Operating_System
locked	O
by	O
task	B-General_Concept
B	O
,	O
which	O
waits	O
for	O
a	O
mutex	B-Operating_System
locked	O
by	O
task	B-General_Concept
C	O
.	O
Handling	O
multiple	O
levels	O
of	O
inheritance	O
causes	O
other	O
code	O
to	O
run	O
in	O
high	O
priority	O
context	O
and	O
thus	O
can	O
cause	O
starvation	B-Operating_System
of	O
medium-priority	O
threads	B-Operating_System
.	O
</s>
<s>
In	O
a	O
deadlock	B-Operating_System
,	O
two	O
or	O
more	O
tasks	O
lock	O
mutex	B-Operating_System
without	O
timeouts	O
and	O
then	O
wait	O
forever	O
for	O
the	O
other	O
task	B-General_Concept
's	O
mutex	B-Operating_System
,	O
creating	O
a	O
cyclic	O
dependency	O
.	O
</s>
<s>
The	O
simplest	O
deadlock	B-Operating_System
scenario	O
occurs	O
when	O
two	O
tasks	O
alternately	O
lock	O
two	O
mutex	B-Operating_System
,	O
but	O
in	O
the	O
opposite	O
order	O
.	O
</s>
<s>
Deadlock	B-Operating_System
is	O
prevented	O
by	O
careful	O
design	O
.	O
</s>
<s>
The	O
other	O
approach	O
to	O
resource	O
sharing	O
is	O
for	O
tasks	O
to	O
send	O
messages	O
in	O
an	O
organized	O
message	B-Architecture
passing	I-Architecture
scheme	O
.	O
</s>
<s>
In	O
this	O
paradigm	O
,	O
the	O
resource	O
is	O
managed	O
directly	O
by	O
only	O
one	O
task	B-General_Concept
.	O
</s>
<s>
When	O
another	O
task	B-General_Concept
wants	O
to	O
interrogate	O
or	O
manipulate	O
the	O
resource	O
,	O
it	O
sends	O
a	O
message	O
to	O
the	O
managing	O
task	B-General_Concept
.	O
</s>
<s>
Although	O
their	O
real-time	O
behavior	O
is	O
less	O
crisp	O
than	O
semaphore	B-Operating_System
systems	O
,	O
simple	O
message-based	B-Architecture
systems	O
avoid	O
most	O
protocol	O
deadlock	B-Operating_System
hazards	O
,	O
and	O
are	O
generally	O
better-behaved	O
than	O
semaphore	B-Operating_System
systems	O
.	O
</s>
<s>
However	O
,	O
problems	O
like	O
those	O
of	O
semaphores	B-Operating_System
are	O
possible	O
.	O
</s>
<s>
Priority	B-Operating_System
inversion	I-Operating_System
can	O
occur	O
when	O
a	O
task	B-General_Concept
is	O
working	O
on	O
a	O
low-priority	O
message	O
and	O
ignores	O
a	O
higher-priority	O
message	O
(	O
or	O
a	O
message	O
originating	O
indirectly	O
from	O
a	O
high	O
priority	O
task	B-General_Concept
)	O
in	O
its	O
incoming	O
message	O
queue	O
.	O
</s>
<s>
Protocol	O
deadlocks	B-Operating_System
can	O
occur	O
when	O
two	O
or	O
more	O
tasks	O
wait	O
for	O
each	O
other	O
to	O
send	O
response	O
messages	O
.	O
</s>
<s>
Since	O
an	O
interrupt	B-Application
handler	O
blocks	O
the	O
highest	O
priority	O
task	B-General_Concept
from	O
running	O
,	O
and	O
since	O
real-time	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
are	O
designed	O
to	O
keep	O
thread	B-Operating_System
latency	O
to	O
a	O
minimum	O
,	O
interrupt	B-Application
handlers	O
are	O
typically	O
kept	O
as	O
short	O
as	O
possible	O
.	O
</s>
<s>
The	O
interrupt	B-Application
handler	O
defers	O
all	O
interaction	O
with	O
the	O
hardware	O
if	O
possible	O
;	O
typically	O
all	O
that	O
is	O
necessary	O
is	O
to	O
acknowledge	O
or	O
disable	O
the	O
interrupt	B-Application
(	O
so	O
that	O
it	O
wo	O
n't	O
occur	O
again	O
when	O
the	O
interrupt	B-Application
handler	O
returns	O
)	O
and	O
notify	O
a	O
task	B-General_Concept
that	O
work	O
needs	O
to	O
be	O
done	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
by	O
unblocking	O
a	O
driver	O
task	B-General_Concept
through	O
releasing	O
a	O
semaphore	B-Operating_System
,	O
setting	O
a	O
flag	O
or	O
sending	O
a	O
message	O
.	O
</s>
<s>
A	O
scheduler	O
often	O
provides	O
the	O
ability	O
to	O
unblock	O
a	O
task	B-General_Concept
from	O
interrupt	B-Application
handler	O
context	O
.	O
</s>
<s>
An	O
OS	O
maintains	O
catalogues	O
of	O
objects	O
it	O
manages	O
such	O
as	O
threads	B-Operating_System
,	O
mutexes	B-Operating_System
,	O
memory	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
it	O
can	O
be	O
problematic	O
when	O
an	O
interrupt	B-Application
handler	O
calls	O
an	O
OS	O
function	O
while	O
the	O
application	O
is	O
in	O
the	O
act	O
of	O
also	O
doing	O
so	O
.	O
</s>
<s>
The	O
OS	O
function	O
called	O
from	O
an	O
interrupt	B-Application
handler	O
could	O
find	O
the	O
object	O
database	O
to	O
be	O
in	O
an	O
inconsistent	O
state	O
because	O
of	O
the	O
application	O
's	O
update	O
.	O
</s>
<s>
RTOSs	O
implementing	O
the	O
unified	O
architecture	O
solve	O
the	O
problem	O
by	O
simply	O
disabling	O
interrupts	B-Application
while	O
the	O
internal	O
catalogue	O
is	O
updated	O
.	O
</s>
<s>
The	O
downside	O
of	O
this	O
is	O
that	O
interrupt	B-General_Concept
latency	I-General_Concept
increases	O
,	O
potentially	O
losing	O
interrupts	B-Application
.	O
</s>
<s>
This	O
handler	O
runs	O
at	O
a	O
higher	O
priority	O
than	O
any	O
thread	B-Operating_System
but	O
lower	O
than	O
the	O
interrupt	B-Application
handlers	O
.	O
</s>
<s>
The	O
advantage	O
of	O
this	O
architecture	O
is	O
that	O
it	O
adds	O
very	O
few	O
cycles	O
to	O
interrupt	B-General_Concept
latency	I-General_Concept
.	O
</s>
<s>
As	O
a	O
result	O
,	O
OSes	O
which	O
implement	O
the	O
segmented	O
architecture	O
are	O
more	O
predictable	O
and	O
can	O
deal	O
with	O
higher	O
interrupt	B-Application
rates	O
compared	O
to	O
the	O
unified	O
architecture	O
.	O
</s>
<s>
Similarly	O
,	O
the	O
System	B-Architecture
Management	I-Architecture
Mode	I-Architecture
on	O
x86	O
compatible	O
Hardware	O
can	O
take	O
a	O
lot	O
of	O
time	O
before	O
it	O
returns	O
control	O
to	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Memory	B-General_Concept
allocation	I-General_Concept
is	O
more	O
critical	O
in	O
a	O
real-time	B-Operating_System
operating	I-Operating_System
system	I-Operating_System
than	O
in	O
other	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
First	O
,	O
for	O
stability	O
there	O
cannot	O
be	O
memory	B-Error_Name
leaks	I-Error_Name
(	O
memory	O
that	O
is	O
allocated	O
but	O
not	O
freed	O
after	O
use	O
)	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
dynamic	B-General_Concept
memory	I-General_Concept
allocation	I-General_Concept
is	O
frowned	O
upon	O
.	O
</s>
<s>
Whenever	O
possible	O
,	O
all	O
required	O
memory	B-General_Concept
allocation	I-General_Concept
is	O
specified	O
statically	O
at	O
compile	O
time	O
.	O
</s>
<s>
Another	O
reason	O
to	O
avoid	O
dynamic	B-General_Concept
memory	I-General_Concept
allocation	I-General_Concept
is	O
memory	O
fragmentation	O
.	O
</s>
<s>
With	O
frequent	O
allocation	O
and	O
releasing	O
of	O
small	O
chunks	O
of	O
memory	O
,	O
a	O
situation	O
may	O
occur	O
where	O
available	O
memory	O
is	O
divided	O
into	O
several	O
sections	O
and	O
the	O
RTOS	B-Operating_System
cannot	O
allocate	O
a	O
large	O
enough	O
continuous	O
block	O
of	O
memory	O
,	O
although	O
there	O
is	O
enough	O
free	O
memory	O
.	O
</s>
<s>
A	O
standard	O
memory	B-General_Concept
allocation	I-General_Concept
scheme	O
scans	O
a	O
linked	O
list	O
of	O
indeterminate	O
length	O
to	O
find	O
a	O
suitable	O
free	O
memory	O
block	O
,	O
which	O
is	O
unacceptable	O
in	O
an	O
RTOS	B-Operating_System
since	O
memory	B-General_Concept
allocation	I-General_Concept
has	O
to	O
occur	O
within	O
a	O
certain	O
amount	O
of	O
time	O
.	O
</s>
<s>
The	O
simple	O
fixed-size-blocks	O
algorithm	O
works	O
quite	O
well	O
for	O
simple	O
embedded	B-Architecture
systems	I-Architecture
because	O
of	O
its	O
low	O
overhead	O
.	O
</s>
