A service that is registered by one process can be accessed by other processes in the system. Services can be transparently replaced at run-time.
A service has an interface that callers use to access the service's functions. This interface typically is defined in a header file that is included by all users of the service. A service interface is defined with the SERVICE_INTERFACE() macro.
A service implementation is declared with the SERVICE() macro. The SERVICE() statement specifies the actual functions that are used to implement the service.
Every service has a controlling process. The controlling process registers the service with the system when it starts, and is also notified if the service is removed or replaced. A process may register any number of services.
Service registration is done with a SERVICE_REGISTER() statement. If a service with the same name is already registered, this is removed before the new service is registered.
The SERVICE_CALL() macro is used to call a service. If the service to be called is not registered, the SERVICE_CALL() statement does nothing. The SERVICE_FIND() function can be used to check if a particular service exists before calling SERVICE_CALL().
Files | |
file | service.h |
Header file for the Contiki service mechanism. | |
file | service.c |
Implementation of the Contiki service mechanism. | |
Data Structures | |
struct | service |
Functions | |
void | service_register (struct service *s) |
void | service_remove (struct service *s) |
service * | service_find (const char *name) |