Preemptive Kernel

November 2, 2001, 12:00 AM —  ITworld — 

Preemption 101
"Preemption" basically means that a running task can be suspended while
another task takes its place as the currently running process. Once a
task has consumed its allotted quantum, or CPU time slice, the
scheduler will suspend it and run the next task in the queue. In
practice, the scheduling algorithm is more complicated because of
different process priorities.

User vs. Kernel Preemption
You might get the impression that the scheduler can preempt a running
process at any given time. That's not entirely correct. Linux supports
only user-level preemption, which allows the scheduler to suspend a
process as long it's running in user mode. It will not suspend a
running process that is in kernel mode, though (read more on kernel
mode vs. user mode here: http://www.itworld.com/nl/lnx_tip/06082001).

Kernel Preemption Pros and Cons
By contrast, a preemptive kernel may suspend a running task even if
it's in kernel mode. This is necessary in hard-core, real-time
applications that must meet very rigid time constraints. Under the user
preemption model, syscalls present a challenge in this regard. Although
their execution time is very short, it isn't constant. For instance,
the time needed to complete a malloc() call depends on heap
fragmentation, the size of the requested memory block, and the system's
load. Thus, one call may take 10 milliseconds to complete whereas
another might take 50. A task that must terminate within 40
milliseconds might not finish on time if another process calls malloc()
in between.

By contrast, the scheduler could preempt the malloc() call and enable
the real-time task to always finish on time under a preemptive kernel.
Kernel preemption can also improve the responsiveness of some notorious
applications that cause the system to freeze up for a short while
during certain activities.

Kernel preemption exacts a price, though. Many applications aren't
ready to deal with the possibility of a preempted syscall. Preemption
also will require a kernel overhaul and complicate the kernel's code.
Is it really worth the trouble? For most everyday uses, the answer
is "no". That said, with Linux becoming the OS of choice in embedded
and real-time environments, the demand to add kernel preemption is
constantly increasing. Presently, several preemptive kernel patches are
available such as Robert Love's patch: http://www.tech9.net/rml/linux/
For benchmark results, visit the Linux kernel preemption project:
http://kpreempt.sourceforge.net/

» posted by ITworld staff

ITworld

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Free books

Essential JavaFX
Get started building rich Web apps quickly with an introduction to the power of JavaFX key features -- scene node graphs, nodes as components, the coordinate system, layout options, colors and gradients, custom classes with inheritance, animation, binding, and event handlers.Enter now!

The Nomadic Developer
Consulting can be hugely rewarding, but it's easy to fail if you are unprepared. To succeed, you need a mentor who knows the lay of the land. Aaron Erickson is your mentor, and this is your guidebook. Enter now!

Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

Marketplace