Files
genode/base-linux/src/core/platform_thread.cc
Norman Feske aee0a2061b Create entrypoint sockets in core only
This patch alleviates the need for any non-core process to create Unix
domain sockets locally. All sockets used for RPC communication are
created by core and subsequently passed to the other processes via RPC
or the parent interface. The immediate benefit is that no process other
than core needs to access the 'rpath' directory in order to communicate.
However, access to 'rpath' is still needed for accessing dataspaces.

Core creates one socket pair per thread on demand on the first call of
the 'Linux_cpu_session::server_sd()' or 'Linux_cpu_session::client_sd()'
functions. 'Linux_cpu_session' is a Linux-specific extension to the CPU
session interface. In addition to the socket accessors, the extension
provides a mechanism to register the PID/TID of a thread. Those
information were formerly propagated into core along with the thread
name as argument to 'create_thread()'.

Because core creates socket pairs for entrypoints, it needs to know all
threads that are potential entrypoints. For lx_hybrid programs, we
hadn't had propagated any thread information into core, yet. Hence, this
patch also contains the code for registering threads of hybrid
applications at core.
2012-11-05 17:31:04 +01:00

73 lines
1.3 KiB
C++

/*
* \brief Linux-specific platform thread implementation
* \author Norman Feske
* \date 2007-10-15
*/
/*
* Copyright (C) 2007-2012 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.
*/
/* Genode includes */
#include <util/token.h>
#include <util/misc_math.h>
#include <base/printf.h>
/* local includes */
#include "platform_thread.h"
/* Linux syscall helper */
#include <linux_syscalls.h>
#include <linux_socket.h>
using namespace Genode;
typedef Token<Scanner_policy_identifier_with_underline> Tid_token;
Platform_thread::Platform_thread(const char *name, unsigned, addr_t)
: _tid(-1), _pid(-1)
{
strncpy(_name, name, min(sizeof(_name), strlen(name)));
}
void Platform_thread::cancel_blocking()
{
PDBG("send cancel-blocking signal to %ld\n", _tid);
lx_tgkill(_pid, _tid, LX_SIGUSR1);
}
void Platform_thread::pause()
{
PDBG("not implemented");
}
void Platform_thread::resume()
{
PDBG("not implemented");
}
int Platform_thread::client_sd()
{
/* construct socket pair on first call */
if (_ncs.client_sd == -1)
_ncs = lx_server_socket_pair(_tid);
return _ncs.client_sd;
}
int Platform_thread::server_sd()
{
client_sd();
return _ncs.server_sd;
}