SST/macro
threading_ucontext.h
Go to the documentation of this file.
1 
2 /*
3  * This file is part of SST/macroscale:
4  * The macroscale architecture simulator from the SST suite.
5  * Copyright (c) 2009 Sandia Corporation.
6  * This software is distributed under the BSD License.
7  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8  * the U.S. Government retains certain rights in this software.
9  * For more information, see the LICENSE file in the top
10  * SST/macroscale directory.
11  */
12 
13 #ifndef SSTMAC_SOFTWARE_THREADING_THREADING_UCONTEXT_H_INCLUDED
14 #define SSTMAC_SOFTWARE_THREADING_THREADING_UCONTEXT_H_INCLUDED
15 
17 
18 #ifdef SSTMAC_HAVE_UCONTEXT
19 
20 #include <ucontext.h>
22 
23 #endif
24 
25 namespace sstmac {
26 namespace sw {
27 
28 #ifdef SSTMAC_HAVE_UCONTEXT
29 
30 class threading_ucontext : public threading_interface
31 {
32  private:
33  ucontext_t context_;
34 
35  public:
36 
37  /// Initializing a context.
38  virtual void
39  init_context();
40 
41  virtual
42  threading_interface* copy() {
43  return new threading_ucontext();
44  }
45 
46 
47  virtual void
48  destroy_context() {
49  }
50 
51  /// Start a new context.
52  virtual void
53  start_context(int physical_thread_id, void *stack, size_t stacksize, void
54  (*func)(void*), void *args, threading_interface *yield_to);
55 
56  /// Swap context.
57  virtual void
58  swap_context(threading_interface *to);
59 
60  /// This is called when we have completed running the thread. It is
61  /// called in the from context.
62  inline void
63  complete_context(threading_interface *to) {
64  swap_context(to);
65  }
66 
67 };
68 
69 #endif
70 
71 }
72 } // end of namespace sstmac
73 #endif
74 
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...