2016-12-13 17:09:35 +01:00
|
|
|
/*
|
|
|
|
* \brief Libc-internal kernel API
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \author Emery Hemingway
|
|
|
|
* \date 2016-12-14
|
|
|
|
*
|
|
|
|
* TODO document libc tasking including
|
|
|
|
* - the initial thread (which is neither component nor pthread)
|
|
|
|
* - processes incoming signals and forwards to entrypoint
|
|
|
|
* - the main thread (which is the kernel and the main user context)
|
|
|
|
* - pthreads (which are pthread user contexts only)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2017 Genode Labs GmbH
|
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2016-12-13 17:09:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LIBC__TASK_H_
|
|
|
|
#define _LIBC__TASK_H_
|
|
|
|
|
2019-01-03 18:01:49 +01:00
|
|
|
#include <base/duration.h>
|
2018-07-16 17:00:30 +02:00
|
|
|
#include <util/xml_node.h>
|
|
|
|
|
2016-12-13 17:09:35 +01:00
|
|
|
namespace Libc {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume all user contexts
|
|
|
|
*
|
|
|
|
* This resumes the main user context as well as any pthread context.
|
|
|
|
*/
|
|
|
|
void resume_all();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suspend the execution of the calling user context
|
|
|
|
*
|
2018-12-03 14:37:54 +01:00
|
|
|
* \param timeout_ms maximum time to stay suspended in milliseconds,
|
|
|
|
* 0 for infinite suspend
|
2016-12-13 17:09:35 +01:00
|
|
|
*
|
2018-12-03 14:37:54 +01:00
|
|
|
* \return remaining duration until timeout,
|
|
|
|
* 0 if the timeout expired
|
2016-12-13 17:09:35 +01:00
|
|
|
*
|
|
|
|
* The context could be running on the component entrypoint as main context
|
|
|
|
* or as separate pthread. This function returns after the libc kernel
|
|
|
|
* resumed the user context execution.
|
|
|
|
*/
|
2017-02-20 13:30:36 +01:00
|
|
|
struct Suspend_functor { virtual bool suspend() = 0; };
|
2019-04-09 15:46:36 +02:00
|
|
|
Genode::uint64_t suspend(Suspend_functor &, Genode::uint64_t timeout_ms = 0);
|
2016-12-13 17:09:35 +01:00
|
|
|
|
2017-05-18 16:04:21 +02:00
|
|
|
void dispatch_pending_io_signals();
|
|
|
|
|
2017-02-10 22:38:37 +01:00
|
|
|
/**
|
|
|
|
* Get time since startup in ms
|
|
|
|
*/
|
2018-10-19 15:38:46 +02:00
|
|
|
Genode::Duration current_time();
|
2017-02-10 22:38:37 +01:00
|
|
|
|
2016-12-13 17:09:35 +01:00
|
|
|
/**
|
|
|
|
* Suspend main user context and the component entrypoint
|
|
|
|
*
|
|
|
|
* This interface is solely used by the implementation of fork().
|
|
|
|
*/
|
|
|
|
void schedule_suspend(void (*suspended) ());
|
|
|
|
|
2017-02-14 22:26:03 +01:00
|
|
|
struct Select_handler_base;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule select handler that is deblocked by ready fd sets
|
|
|
|
*/
|
|
|
|
void schedule_select(Select_handler_base *);
|
2018-07-16 17:00:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Access libc configuration Xml_node.
|
|
|
|
*/
|
|
|
|
Genode::Xml_node libc_config();
|
2016-12-13 17:09:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _LIBC__TASK_H_ */
|