genode/repos/base/src/core/include/signal_context_slab.h
Norman Feske 963a6c37a0 core: equip signal-context slab with initial block
By supplying a statically allocated initial block to the slab allocator
for signal contexts, we become able to construct a 'Signal_broker' (the
back end for the PD's signalling API) without any dynamic memory
allocation. This is a precondition for using the PD as meta-data
allocator for its contained signal broker (meta data allocations must
not happen before the PD construction is complete).

Issue #2407
2017-05-31 13:16:13 +02:00

50 lines
1.3 KiB
C++

/*
* \brief Slab allocator for signal contexts
* \author Norman Feske
* \date 2017-05-10
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _CORE__INCLUDE__SIGNAL_CONTEXT_SLAB_H_
#define _CORE__INCLUDE__SIGNAL_CONTEXT_SLAB_H_
/* Genode includes */
#include <base/slab.h>
/* core-local includes */
#include <signal_source_component.h>
namespace Genode { struct Signal_context_slab; }
/**
* Slab allocator for signal contexts
*
* We define an initial slab block to prevent a dynamic slab-block allocation
* via '_md_alloc' at the slab's construction time. This would be a problem
* because the '_md_alloc' supplied by the 'Pd_session_component' constructor
* uses the PD session itself as backing store (which would be in the middle of
* construction).
*/
struct Genode::Signal_context_slab : Slab
{
static constexpr size_t SBS = 960*sizeof(long);
uint8_t _initial_sb[SBS];
Signal_context_slab(Allocator &md_alloc)
: Slab(sizeof(Signal_context_component), SBS, _initial_sb, &md_alloc) { }
Signal_context_component *any_signal_context()
{
return (Signal_context_component *)Slab::any_used_elem();
}
};
#endif /* _CORE__INCLUDE__SIGNAL_CONTEXT_SLAB_H_ */