Microkernel Pattern
Microkernel Pattern
platform that the external server implements. Adapters also protect clients from the specific
implementation details of the microkernel.
When a client requests a service from an external service, the adapter forwards the call to the
appropriate server. The adapter uses the communication services provided by the microkernel.
Each client is associated with an adapter used as a bridge between the client and its external
server. Internal servers are only accessible by the microkernel component.
Class
Microkernel
Collaborators
Internal server
Responsibility
Provides core
mechanisms
Offers communication facilities
Encapsulates system dependencies
Manages and
controls resources
Class
External server
Class
Collaborators
Internal server Microkernel
Responsibility
Implements
additional services
Encapsulates
some system dependencies
Collaborators
Microkernel
Responsibility
Provides programming interfaces for
its clients.
Class
Client
Responsibility
Represents an
application
Collaborators
Adapter
Class
Adapter
Responsibility
Hides system dependencies such as
communication
facilities from the
client.
Invokes methods of
external servers on
behalf of clients
Collaborators
External server
Microkernel
External Server
receiveRequest
dispatchRequest
executeService
Microkernel
calls
Internal Server
executeMechanism
initCommunication
findReceiver
createHandle
sendMessage
callInternalServer
activates
receiveRequest
executeService
initializes
communication
Adapter
sends request
createRequest
callService
Client
calls service
doTask
Dynamics
The dynamic behavior depends on the functionality it provides for interprocess communication.
The scenarios assume the availability of remote procedure calls.
Implementation
Carry out the following steps:
1. Analyze the application domain. Perform domain analysis and identify the core functionality
necessary for implementing external servers. If you already knew the policies your external
servers need to offer, if you have a detailed knowledge about the external servers you are going to
implement, continue with step 2.
2. Analyze external servers. Analyze the policies the external servers are going to provide.
3. Categorize the services. Whenever possible, group all the functionality into semanticallyindependent categories.These categories are not directly related to the application domain. Rather
they are necessary to implement the system infrastructure. Some of these operations may be
candidates for migration to internal servers.
4. Partition the categories. Separate the categories into services that should be part of the
microkernel and those that should be available as internal servers. You need to establish criteria
for this separation. Time-critical, frequently-used, or hardware-dependent operations should be
implemented within the microkernel component.
5. Find a consistent and complete set of operations and abstractions for every category you
identified. Microkernel provides mechanisms, not policies. Each policy an external server
provides must be implemented through use of the services the microkernel offers through its
interfaces.
6. Determine strategies for request transmission and retrieval. Specify the facilities the
microkernel should provide for communication between components e.g., asynchronous,
synchronous. This depends on the requirements of the application domain. The relationship
between communicating components may be a 1-1, many-1, many-many relationship. If low-level
communication facilities are available, you can build more complex communication mechanisms
on top of them. See Forwarder-Receiver, Client-Dispatcher-Server. Other examples of
communication facilities are synchronous remote procedure calls and asynchronous mailboxes. A
mailbox is a message buffer where a set of components can read messages from the buffer and
another set of components has permission to write messages to it.
7. Structure the microkernel component. Design it using the Layers Pattern to separate systemspecific parts form system-independent parts of the microkernel. Places the services the
microkernel exposes to other components in the uppermost layer and use the lower layers to hide
system dependencies from higher layers.
8. To specify the programming interfaces of the microkernel, you need to decide how these
interfaces should be accessible externally. If in a module physically shared by other components,
use conventional method calls. If in a separate process, existing comm facilities are required for
transmitting requests from components to the microkernel. The kernel represents an exclusive
resource can be a bottleneck. Provide multiple threads within the kernel that wait for incoming
requests and use them to execute appropriate services. Ensure consistency of internal data.
9. The microkernel manages all system resources such as memory blocks, devices including
implementing strategies for sharing, locking, allocation and deallocation of the resources.
10. Design and implement the internal servers as separate processes or shared libraries. Do this in
parallel with steps 7 to 9. Some of the microkernel services need to access internal servers.
Distinguish between active (processes) and passive servers (shared libraries).
11. Implement the external servers. Each external server is implemented as a separate process that
provides its own service interface. Specify how external servers dispatch requests to their internal
procedures.
12. Implement the adapters. Decide whether one adapter is available for all clients or if every
client is associated with its own adapter (less memory contention vs. better response times).
Provide operations to the adapters clients that are forwarded to an external server. When the
client calls a function of the external server, the adapter packages relevant information into a
request and forwards the request to the appropriate external server. The adapter then waits for the
servers response and finally returns control to the client, using the facilities for inter-component
communication.
13. Develop client applications. Clients depend on the policies implemented by their external
server.
Variants Microkernel System with indirect Client-Server connections. A Client and Server
communicate with each other indirectly using the microkernel as a message backbone. All
requests pass through the microkernel. Useful when security requirements force the system to
control all communication between participants.
Distributed Microkernel System. A microkernel acts as a messaging backbone responsible for
sending messages to remote machines or receiving messages from them. Every machine in the
distributed system uses its own microkernel implementation. From the users viewpoint, the whole
system appears as a single Microkernel system distribution is transparent. A Distributed
Microkernel System allows you to distribute servers and clients across a network of machines or
microprocessors. To achieve this, the microkernels in a distributed implementation must include
additional services for communicating with each other.
Examples Windows NT offers 3 external servers: OS/2 1.x server, POSIX server, and Win32
server. POSA 1 describes four others. Douglass says that an RTOS (real-time operating system) is
a common subsystem example. The core set of services include create a task, delete a task,
allocate and deallocate memory, provide task event and message queues, and schedule/execute a
task set. On top of those services, a developer can link in additional components to provide more
services. Common service components for RTOS include bus communications, file services,
networking services, and middleware services. Thus an RTOS becomes usable in a much wider set
of application problems from tiny, highly memory-constrained systems to systems consisting of
sets of high-powered networked CPUs.
Consequences
The Microkernel pattern offers some important benefits: portability, flexibility and extensibility,
separation of policy and mechanism, scalability, reliability, transparency. See POSA 1 for
explanations.
The Microkernel architectural framework also has liabilities: performance, complexity of design
and implementation.
See also the Broker pattern for distributed software systems consisting of interacting and
decoupled components; the Reflection pattern which provides a two-tiered architecture a base
level corresponds to a combination of microkernel and internal servers and a meta level enables the
behavior of base-level functionality to be changed dynamically. The meta level allows integration
of customer-specific extensions to the base-level services. This corresponds to the provision of
external servers in a microkernel architecture. Per Douglass, the Component-Based Architecture
Pattern is a more general pattern that permits the addition of components at run-time. The Layers
Pattern is more general still.