mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
hw: differ ID allocators even with same size
Previously, if two ID allocators for different kernel objects had the same size, the kernel-object framework managed both objects types through the same allocator instance. This is caused by the use of unsynchronized singletons in the accessor functions and can be avoided by creating new types through inheritance instead of using typedefs. Anyways, this fix is a little bit ugly and should replaced by avoiding the use of unsynchronized singletons in the future. fix #906
This commit is contained in:
parent
a9651d1728
commit
c56927b76e
@ -102,13 +102,13 @@ namespace Kernel
|
||||
namespace Kernel
|
||||
{
|
||||
class Vm;
|
||||
typedef Id_allocator<MAX_VMS> Vm_ids;
|
||||
typedef Object_pool<Vm> Vm_pool;
|
||||
class Vm_ids : public Id_allocator<MAX_VMS> { };
|
||||
typedef Object_pool<Vm> Vm_pool;
|
||||
|
||||
Vm_ids * vm_ids();
|
||||
Vm_pool * vm_pool();
|
||||
|
||||
class Vm : public Object<Vm, MAX_VMS, vm_ids, vm_pool>,
|
||||
class Vm : public Object<Vm, MAX_VMS, Vm_ids, vm_ids, vm_pool>,
|
||||
public Execution_context
|
||||
{
|
||||
private:
|
||||
|
@ -52,10 +52,15 @@ namespace Kernel
|
||||
* \param MAX_INSTANCES max amount of coincidently living objects
|
||||
* \param ID_ALLOC accessor function of object-name allocator
|
||||
* \param POOL accessor function of object pool
|
||||
*
|
||||
* FIXME: Most of the bother with template parameters regarding ID
|
||||
* allocator and object pool is caused by the use of
|
||||
* unsynchronized singletons. By avoiding the use of
|
||||
* unsynchronized singletons one can at least remove
|
||||
* ID_ALLOC_T.
|
||||
*/
|
||||
template <typename T, unsigned MAX_INSTANCES,
|
||||
Id_allocator<MAX_INSTANCES> * (*ID_ALLOC)(),
|
||||
Kernel::Object_pool<T> * (* POOL)()>
|
||||
template <typename T, unsigned MAX_INSTANCES, typename ID_ALLOC_T,
|
||||
ID_ALLOC_T * (*ID_ALLOC)(), Kernel::Object_pool<T> * (* POOL)()>
|
||||
|
||||
class Object;
|
||||
}
|
||||
@ -198,9 +203,8 @@ class Kernel::Id_allocator
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, unsigned MAX_INSTANCES,
|
||||
Kernel::Id_allocator<MAX_INSTANCES> * (* ID_ALLOC)(),
|
||||
Kernel::Object_pool<T> * (* POOL)()>
|
||||
template <typename T, unsigned MAX_INSTANCES, typename ID_ALLOC_T,
|
||||
ID_ALLOC_T * (* ID_ALLOC)(), Kernel::Object_pool<T> * (* POOL)()>
|
||||
|
||||
class Kernel::Object : public Object_pool<T>::Item
|
||||
{
|
||||
|
@ -54,8 +54,8 @@ namespace Kernel
|
||||
*/
|
||||
class Pd;
|
||||
|
||||
typedef Id_allocator<MAX_PDS> Pd_ids;
|
||||
typedef Object_pool<Pd> Pd_pool;
|
||||
class Pd_ids : public Id_allocator<MAX_PDS> { };
|
||||
typedef Object_pool<Pd> Pd_pool;
|
||||
|
||||
Pd_ids * pd_ids();
|
||||
Pd_pool * pd_pool();
|
||||
@ -144,7 +144,7 @@ class Kernel::Mode_transition_control
|
||||
}
|
||||
};
|
||||
|
||||
class Kernel::Pd : public Object<Pd, MAX_PDS, pd_ids, pd_pool>
|
||||
class Kernel::Pd : public Object<Pd, MAX_PDS, Pd_ids, pd_ids, pd_pool>
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -49,10 +49,10 @@ namespace Kernel
|
||||
*/
|
||||
class Signal_receiver;
|
||||
|
||||
typedef Id_allocator<MAX_SIGNAL_CONTEXTS> Signal_context_ids;
|
||||
typedef Object_pool<Signal_context> Signal_context_pool;
|
||||
typedef Id_allocator<MAX_SIGNAL_RECEIVERS> Signal_receiver_ids;
|
||||
typedef Object_pool<Signal_receiver> Signal_receiver_pool;
|
||||
class Signal_context_ids : public Id_allocator<MAX_SIGNAL_CONTEXTS> { };
|
||||
class Signal_receiver_ids : public Id_allocator<MAX_SIGNAL_RECEIVERS> { };
|
||||
typedef Object_pool<Signal_context> Signal_context_pool;
|
||||
typedef Object_pool<Signal_receiver> Signal_receiver_pool;
|
||||
|
||||
Signal_context_ids * signal_context_ids();
|
||||
Signal_context_pool * signal_context_pool();
|
||||
@ -194,7 +194,7 @@ class Kernel::Signal_receiver_killer
|
||||
class Kernel::Signal_context
|
||||
:
|
||||
public Object<Signal_context, MAX_SIGNAL_CONTEXTS,
|
||||
signal_context_ids, signal_context_pool>
|
||||
Signal_context_ids, signal_context_ids, signal_context_pool>
|
||||
{
|
||||
friend class Signal_receiver;
|
||||
friend class Signal_context_killer;
|
||||
@ -313,7 +313,8 @@ class Kernel::Signal_context
|
||||
class Kernel::Signal_receiver
|
||||
:
|
||||
public Object<Signal_receiver, MAX_SIGNAL_RECEIVERS,
|
||||
signal_receiver_ids, signal_receiver_pool>,
|
||||
Signal_receiver_ids, signal_receiver_ids,
|
||||
signal_receiver_pool>,
|
||||
public Signal_context_killer
|
||||
{
|
||||
friend class Signal_context;
|
||||
|
@ -58,8 +58,8 @@ namespace Kernel
|
||||
*/
|
||||
class Thread;
|
||||
|
||||
typedef Id_allocator<MAX_THREADS> Thread_ids;
|
||||
typedef Object_pool<Thread> Thread_pool;
|
||||
class Thread_ids : public Id_allocator<MAX_THREADS> { };
|
||||
typedef Object_pool<Thread> Thread_pool;
|
||||
|
||||
Thread_ids * thread_ids();
|
||||
Thread_pool * thread_pool();
|
||||
@ -91,7 +91,7 @@ class Kernel::Execution_context : public Cpu_scheduler::Item
|
||||
class Kernel::Thread
|
||||
:
|
||||
public Cpu::User_context,
|
||||
public Object<Thread, MAX_THREADS, thread_ids, thread_pool>,
|
||||
public Object<Thread, MAX_THREADS, Thread_ids, thread_ids, thread_pool>,
|
||||
public Execution_context,
|
||||
public Ipc_node,
|
||||
public Irq_receiver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user