geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
geopm::BatchServer Class Referenceabstract

#include <BatchServer.hpp>

Inheritance diagram for geopm::BatchServer:
Inheritance graph
[legend]

Public Member Functions

 BatchServer ()=default
 Interface called by geopmd to create the server for batch commands. More...
 
virtual ~BatchServer ()=default
 
virtual int server_pid (void) const =0
 
virtual std::string server_key (void) const =0
 
virtual void stop_batch (void)=0
 Supports the D-Bus interface for stopping a batch server. More...
 
virtual bool is_active (void)=0
 Returns true if the batch server is running. More...
 

Static Public Member Functions

static std::unique_ptr< BatchServermake_unique (int client_pid, const std::vector< geopm_request_s > &signal_config, const std::vector< geopm_request_s > &control_config)
 Supports the D-Bus interface for starting a batch server. More...
 
static std::string get_signal_shmem_key (const std::string &server_key)
 
static std::string get_control_shmem_key (const std::string &server_key)
 

Static Protected Attributes

static constexpr const char * M_SHMEM_PREFIX
 

Constructor & Destructor Documentation

◆ BatchServer()

geopm::BatchServer::BatchServer ( )
default

Interface called by geopmd to create the server for batch commands.

◆ ~BatchServer()

virtual geopm::BatchServer::~BatchServer ( )
virtualdefault

Member Function Documentation

◆ get_control_shmem_key()

std::string geopm::BatchServer::get_control_shmem_key ( const std::string &  server_key)
static
Returns
The shm key to use for the control shared memory region.

◆ get_signal_shmem_key()

std::string geopm::BatchServer::get_signal_shmem_key ( const std::string &  server_key)
static
Returns
The shm key to use for the signal shared memory region.

◆ is_active()

virtual bool geopm::BatchServer::is_active ( void  )
pure virtual

Returns true if the batch server is running.

Implemented in geopm::BatchServerImp.

◆ make_unique()

std::unique_ptr< BatchServer > geopm::BatchServer::make_unique ( int  client_pid,
const std::vector< geopm_request_s > &  signal_config,
const std::vector< geopm_request_s > &  control_config 
)
static

Supports the D-Bus interface for starting a batch server.

This function is called directly by geopmd in order to fork a new process that will support calls within the client_pid to read_batch_client() and write_batch_client(). The client initiates the server by calling start_batch_client() within the client_pid which make the request through D-Bus to start the server. The server_pid and server_key are stored by the client to enable interactions with the server while the batch session is open.

The method will return after the shared memory regions supporting the service have been created and the child thread that updates those regions is waiting for a signal. Access is provided through the SharedMemory interface with two shm file descriptors created, one for signals and one for controls. The shm keys created will be of the form:

"<prefix>/geopm-service-batch-buffer-<KEY>-signals"
"<prefix>/geopm-service-batch-buffer-<KEY>-controls"

where <KEY> is the "server_key". This key is used by the client side with the SharedMemory::make_unique_user() as the shm_key parameter.

Parameters
[in]client_pidThe Unix process ID of the client process that is initiating the batch server.
[in]signal_configA vector of requests for signals to be sampled.
[in]control_configAvector of requests for controls to be adjusted.

◆ server_key()

virtual std::string geopm::BatchServer::server_key ( void  ) const
pure virtual
Returns
The key used to identify the server connection: a substring in interprocess shared memory keys used for communication.

Implemented in geopm::BatchServerImp.

◆ server_pid()

virtual int geopm::BatchServer::server_pid ( void  ) const
pure virtual
Returns
The Unix process ID of the server process created.

Implemented in geopm::BatchServerImp.

◆ stop_batch()

virtual void geopm::BatchServer::stop_batch ( void  )
pure virtual

Supports the D-Bus interface for stopping a batch server.

This function is called directly by geopmd in order to end a batch session and kill the batch server process created by start_batch_server().

Implemented in geopm::BatchServerImp.

Member Data Documentation

◆ M_SHMEM_PREFIX

constexpr const char* geopm::BatchServer::M_SHMEM_PREFIX
staticconstexprprotected
Initial value:
=
"/run/geopm/batch-buffer-"

The documentation for this class was generated from the following files: