6d837c9e26
This patch extends the 'Parent::session()' and 'Root::session()' functions with an additional 'affinity' parameter, which is inteded to express the preferred affinity of the new session. For CPU sessions provided by core, the values will be used to select the set of CPUs assigned to the CPU session. For other services, the session affinity information can be utilized to optimize the locality of the server thread with the client. For example, to enable the IRQ session to route an IRQ to the CPU core on which the corresponding device driver (the IRQ client) is running.
81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
/*
|
|
* \brief Terminal root
|
|
* \author Christian Prochaska
|
|
* \date 2012-05-16
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
|
|
#ifndef _TERMINAL_ROOT_H_
|
|
#define _TERMINAL_ROOT_H_
|
|
|
|
/* Genode includes */
|
|
#include <cap_session/cap_session.h>
|
|
#include <root/component.h>
|
|
|
|
/* local includes */
|
|
#include "terminal_session_component.h"
|
|
|
|
|
|
namespace Terminal {
|
|
|
|
using namespace Genode;
|
|
|
|
class Root : public Rpc_object<Typed_root<Session> >
|
|
{
|
|
private:
|
|
|
|
Session_component _session_component1, _session_component2;
|
|
|
|
enum Session_state {
|
|
FIRST_SESSION_OPEN = 1 << 0,
|
|
SECOND_SESSION_OPEN = 1 << 1
|
|
};
|
|
|
|
int _session_state;
|
|
|
|
public:
|
|
|
|
Session_capability session(Root::Session_args const &args,
|
|
Genode::Affinity const &)
|
|
{
|
|
if (!(_session_state & FIRST_SESSION_OPEN)) {
|
|
_session_state |= FIRST_SESSION_OPEN;
|
|
return _session_component1.cap();
|
|
} else if (!(_session_state & SECOND_SESSION_OPEN)) {
|
|
_session_state |= SECOND_SESSION_OPEN;
|
|
return _session_component2.cap();
|
|
}
|
|
|
|
return Session_capability();
|
|
}
|
|
|
|
void upgrade(Genode::Session_capability, Root::Upgrade_args const &) { }
|
|
|
|
void close(Genode::Session_capability session)
|
|
{
|
|
if (_session_component1.belongs_to(session))
|
|
_session_state &= ~FIRST_SESSION_OPEN;
|
|
else
|
|
_session_state &= ~SECOND_SESSION_OPEN;
|
|
}
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
Root(Rpc_entrypoint *ep, Allocator *md_alloc,
|
|
Cap_session &cap_session)
|
|
: _session_component1(_session_component2, cap_session, "terminal_ep1"),
|
|
_session_component2(_session_component1, cap_session, "terminal_ep2"),
|
|
_session_state(0)
|
|
{ }
|
|
};
|
|
}
|
|
|
|
#endif /* _TERMINAL_ROOT_H_ */
|