L4Re - L4 Runtime Environment
thread
Go to the documentation of this file.
1 /**
2  * \file
3  * \brief Thread implementation
4  */
5 /*
6  * (c) 2004-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
7  * economic rights: Technische Universit├Ąt Dresden (Germany)
8  * This file is part of TUD:OS and distributed under the terms of the
9  * GNU Lesser General Public License 2.1.
10  * Please see the COPYING-LGPL-2.1 file for details.
11  */
12 
13 #ifndef CXX_THREAD_H__
14 #define CXX_THREAD_H__
15 
16 #include <l4/sys/capability>
17 #include <l4/sys/types.h>
18 
19 namespace cxx {
20 
21  class Thread
22  {
23  public:
24 
25  enum State
26  {
27  Dead = 0,
28  Running = 1,
29  Stopped = 2,
30  };
31 
32  Thread(bool initiate);
33  Thread(void *stack);
34  Thread(void *stack, L4::Cap<L4::Thread> const &cap);
35  virtual ~Thread();
36  void execute() asm ("L4_Thread_execute");
37  virtual void run() = 0;
38  virtual void shutdown() asm ("L4_Thread_shutdown");
39  void start();
40  void stop();
41 
42  L4::Cap<L4::Thread> self() const throw()
43  { return _cap; }
44 
45  State state() const
46  { return _state; }
47 
48  static void start_cxx_thread(Thread *_this)
49  asm ("L4_Thread_start_cxx_thread");
50 
51  static void kill_cxx_thread(Thread *_this)
52  asm ("L4_Thread_kill_cxx_thread");
53 
54  static void set_pager(L4::Cap<void>const &p) throw()
55  { _pager = p; }
56 
57  private:
58  int create();
59 
60  L4::Cap<L4::Thread> _cap;
61  State _state;
62 
63  protected:
64  void *_stack;
65 
66  private:
67  static L4::Cap<void> _pager;
68  static L4::Cap<void> _master;
69  };
70 
71 };
72 
73 #endif /* CXX_THREAD_H__ */
74