mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-22 04:52:56 +01:00
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
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
/*
|
|
* \brief Implementation of the core-internal Thread API via Linux threads
|
|
* \author Norman Feske
|
|
* \date 2006-06-13
|
|
*/
|
|
|
|
/*
|
|
* 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>
|
|
|
|
/* Linux syscall bindings */
|
|
#include <linux_syscalls.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
static void empty_signal_handler(int) { }
|
|
|
|
|
|
void Thread_base::_thread_start()
|
|
{
|
|
/*
|
|
* Set signal handler such that canceled system calls get not transparently
|
|
* retried after a signal gets received.
|
|
*/
|
|
lx_sigaction(LX_SIGUSR1, empty_signal_handler);
|
|
|
|
/*
|
|
* Deliver SIGCHLD signals to no thread other than the main thread. Core's
|
|
* main thread will handle the signals while executing the 'wait_for_exit'
|
|
* function, which is known to not hold any locks that would interfere with
|
|
* the handling of the signal.
|
|
*/
|
|
lx_sigsetmask(LX_SIGCHLD, false);
|
|
|
|
Thread_base::myself()->entry();
|
|
Thread_base::myself()->_join_lock.unlock();
|
|
sleep_forever();
|
|
}
|
|
|
|
|
|
void Thread_base::_init_platform_thread(Type) { }
|
|
|
|
|
|
void Thread_base::_deinit_platform_thread() { }
|
|
|
|
|
|
void Thread_base::start()
|
|
{
|
|
_tid.tid = lx_create_thread(Thread_base::_thread_start, stack_top(), this);
|
|
_tid.pid = lx_getpid();
|
|
}
|
|
|
|
|
|
void Thread_base::cancel_blocking() { }
|