LWP state transition
Applications that have strict
fixed priority
constraints
may need to prevent processes
and
LWPs
from being swapped or paged out to secondary memory.
Here's a simplified overview of
UNIX
system
LWP
states
and the transitions between states:
LWP state transition diagram
An active
LWP
is normally in one of the five states in the diagram.
The arrows show how it changes states.
-
An
LWP
is running if it is assigned to a CPU.
An
LWP
is preempted--that is, removed from the running state--by
the scheduler if
an
LWP
with a higher priority becomes runnable.
An
LWP
is also preempted if it consumes its entire time slice
and
An
LWP
of equal priority is runnable.
-
An
LWP
is runnable in memory if it is in primary memory and ready to run,
but is not assigned to a CPU.
-
An
LWP
is sleeping in memory if it is in primary memory but is waiting
for a specific event before it can continue execution.
For example,
an
LWP
is sleeping if it is waiting for an I/O operation to complete,
for a locked resource to be unlocked, or for a timer to expire.
When the event occurs, the process is sent a wakeup;
if the reason for its sleep is gone,
the
LWP
becomes runnable.
-
An
LWP
is runnable and swapped if it is not waiting for a specific event
but has had its whole address space written to secondary memory to make room
in primary memory for other
LWPs.
-
An
LWP
is sleeping and swapped if it is both waiting for a specific event
and has had its whole address space written to secondary memory to make room
in primary memory for other
processes or
LWPs.
If a machine does not have enough primary memory to hold all its active
processes and
LWPs,
it must page or swap some address space to secondary memory:
-
When the system is short of primary memory,
it writes individual pages of some processes
and
LWPs
to secondary memory but leaves
those processes
and
LWPs
runnable.
When
an
LWP
runs, if it accesses those pages, it must sleep while
the pages are read back into primary memory.
-
When the system gets into a more serious shortage of primary memory,
it writes all the pages of some processes
and
LWPs
to secondary memory and marks those
processes
and
LWPs
as swapped.
Such processes
and
LWPs
get back into a schedulable state only by being chosen
by the system scheduler demon process, then read back into memory.
Both paging and swapping, and especially swapping,
introduce delay when a process
or
LWP
is ready to run again.
For processes
and
LWPs
that have strict timing requirements,
this delay can be unacceptable.
To avoid swapping delays,
fixed priority processes
and
LWPs
are never swapped,
though parts of them may be paged.
An application can prevent paging and swapping by locking
its text and data into primary memory.
For more information see
memcntl(S).
Of course, how much can be locked is limited by how much memory is configured.
Also, locking too much can cause intolerable delays to processes
and
LWPs
that do not
have their text and data locked into memory.
Tradeoffs between performance of
fixed priority processes
and
LWPs
and performance of other
processes
and
LWPs
depend on local needs.
On some systems, process locking may be required to guarantee
the necessary
fixed priority
response.
Next topic:
Software latencies
Previous topic:
Scheduler performance
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005