2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Thread facility
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2009-10-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2009-2013 Genode Labs GmbH
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_
|
|
|
|
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/pager.h>
|
|
|
|
#include <base/thread_state.h>
|
|
|
|
#include <base/native_types.h>
|
|
|
|
|
2013-03-08 11:54:12 +01:00
|
|
|
/* core includes */
|
|
|
|
#include <address_space.h>
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
class Platform_pd;
|
|
|
|
class Platform_thread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum { THREAD_INVALID = -1 }; /* invalid thread number */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
Platform_thread(const char *name = 0, unsigned priority = 0,
|
2012-05-28 16:57:09 +02:00
|
|
|
addr_t utcb = 0, int thread_id = THREAD_INVALID);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
~Platform_thread();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start thread
|
|
|
|
*
|
|
|
|
* \param ip instruction pointer to start at
|
|
|
|
* \param sp stack pointer to use
|
|
|
|
* \param cpu_no target cpu
|
|
|
|
*
|
|
|
|
* \retval 0 successful
|
|
|
|
* \retval -1 thread could not be started
|
|
|
|
*/
|
|
|
|
int start(void *ip, void *sp, unsigned int cpu_no = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause this thread
|
|
|
|
*/
|
|
|
|
void pause();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume this thread
|
|
|
|
*/
|
|
|
|
void resume();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel currently blocking operation
|
|
|
|
*/
|
|
|
|
void cancel_blocking();
|
|
|
|
|
|
|
|
/**
|
2012-11-12 17:48:18 +01:00
|
|
|
* Override thread state with 's'
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
2012-11-12 17:48:18 +01:00
|
|
|
* \throw Cpu_session::State_access_failed
|
|
|
|
*/
|
|
|
|
void state(Thread_state s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read thread state
|
2011-12-22 16:19:25 +01:00
|
|
|
*
|
2012-11-12 17:48:18 +01:00
|
|
|
* \throw Cpu_session::State_access_failed
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
2012-11-12 17:48:18 +01:00
|
|
|
Thread_state state();
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2013-03-08 11:54:12 +01:00
|
|
|
/**
|
|
|
|
* Return the address space to which the thread is bound
|
|
|
|
*/
|
|
|
|
Weak_ptr<Address_space> address_space();
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/************************
|
|
|
|
** Accessor functions **
|
|
|
|
************************/
|
|
|
|
|
|
|
|
/**
|
2013-02-14 11:03:46 +01:00
|
|
|
* Set/get pager
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
void pager(Pager_object *pager) { }
|
2013-02-14 11:03:46 +01:00
|
|
|
Pager_object *pager() const { return 0; }
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return identification of thread when faulting
|
|
|
|
*/
|
|
|
|
unsigned long pager_object_badge() const;
|
|
|
|
|
|
|
|
/**
|
2012-09-04 17:32:55 +02:00
|
|
|
* Set the executing CPU for this thread
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
2012-09-04 17:32:55 +02:00
|
|
|
void affinity(unsigned cpu);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get thread name
|
|
|
|
*/
|
|
|
|
const char *name() const { return "noname"; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */
|