genode/base-pistachio/src/core/thread_start.cc
Martin Stein 0b64328944 base: setup thread object for main thread in CRT0
For a main thread a thread object is created by the CRT0 before _main gets
called so that _main can already run in a generic environment that, e.g.,
catches stack overflows as a page-fault instead of corrupting the BSS.
Additionally dynamic programs have only one CRT0 - the one of the LDSO -
which does the initialization for both LDSO and program.

ref #989
2014-02-25 14:58:05 +01:00

61 lines
1.2 KiB
C++

/*
* \brief Implementation of Thread API interface on top of Platform_thread
* \author Norman Feske
* \date 2006-05-03
*/
/*
* Copyright (C) 2006-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.
*/
/* Genode includes */
#include <base/thread.h>
#include <base/sleep.h>
/* core includes */
#include <platform.h>
#include <core_env.h>
using namespace Genode;
void Thread_base::_thread_start()
{
Thread_base::myself()->_thread_bootstrap();
Thread_base::myself()->entry();
Thread_base::myself()->_join_lock.unlock();
sleep_forever();
}
void Thread_base::start()
{
/* create and start platform thread */
_tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name);
platform_specific()->core_pd()->bind_thread(_tid.pt);
_tid.pt->pager(platform_specific()->core_pager());
_tid.l4id = _tid.pt->native_thread_id();
_tid.pt->start((void *)_thread_start, stack_top());
}
void Thread_base::cancel_blocking()
{
/*
* Within core, we never need to unblock threads
*/
}
void Thread_base::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), _tid.pt);
}