SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_join.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_join.h -- Join Process Synchronization Definition
23
24 Original Author: Andy Goodrich, Forte Design Systems, 5 May 2003
25
26 CHANGE LOG AT THE END OF THE FILE
27 *****************************************************************************/
28
29// $Log: sc_join.h,v $
30// Revision 1.8 2011/08/26 21:45:00 acg
31// Andy Goodrich: fix internal event naming.
32//
33// Revision 1.7 2011/08/26 20:46:09 acg
34// Andy Goodrich: moved the modification log to the end of the file to
35// eliminate source line number skew when check-ins are done.
36//
37
38#ifndef SC_JOIN_H
39#define SC_JOIN_H
40
42#include "sysc/kernel/sc_wait.h"
43
44namespace sc_core {
45
46//==============================================================================
47// CLASS sc_join
48//
49// This class provides a way of waiting for a set of threads to complete their
50// execution. The threads whose completion is to be monitored are registered,
51// and upon their completion an event notification will occur.
52//==============================================================================
54 friend class sc_process_b;
55 friend class sc_process_handle;
56 public:
58 void add_process( sc_process_handle process_h );
59 inline int process_count();
60 virtual void signal(sc_thread_handle thread_p, int type);
61 inline void wait();
62 inline void wait_clocked();
63
64 protected:
65 void add_process( sc_process_b* process_p );
66
67 protected:
68 sc_event m_join_event; // Event to notify when all threads have reported.
69 int m_threads_n; // # of threads still need to wait for.
70
71 private:
72 sc_join( const sc_join& );
73 sc_join& operator = ( const sc_join& );
74};
75
77
78// suspend a thread that does not have a sensitivity list:
79
81
82// suspend a thread that has a sensitivity list:
83
85{
86 do { ::sc_core::wait(); } while (m_threads_n != 0);
87}
88
89#define SC_CJOIN \
90 }; \
91 sc_core::sc_join join; \
92 for ( unsigned int i = 0; \
93 i < sizeof(forkees)/sizeof(sc_core::sc_process_handle); \
94 i++ ) \
95 join.add_process(forkees[i]); \
96 join.wait_clocked(); \
97}
98
99#define SC_FORK \
100{ \
101 sc_core::sc_process_handle forkees[] = {
102
103#define SC_JOIN \
104 }; \
105 sc_core::sc_join join; \
106 for ( unsigned int i = 0; \
107 i < sizeof(forkees)/sizeof(sc_core::sc_process_handle); \
108 i++ ) \
109 join.add_process(forkees[i]); \
110 join.wait(); \
111}
112
113} // namespace sc_core
114
115// Revision 1.6 2011/08/24 22:05:50 acg
116// Torsten Maehne: initialization changes to remove warnings.
117//
118// Revision 1.5 2011/02/18 20:27:14 acg
119// Andy Goodrich: Updated Copyrights.
120//
121// Revision 1.4 2011/02/13 21:47:37 acg
122// Andy Goodrich: update copyright notice.
123//
124// Revision 1.3 2009/07/28 01:10:53 acg
125// Andy Goodrich: updates for 2.3 release candidate.
126//
127// Revision 1.2 2008/05/22 17:06:25 acg
128// Andy Goodrich: updated copyright notice to include 2008.
129//
130// Revision 1.1.1.1 2006/12/15 20:20:05 acg
131// SystemC 2.3
132//
133// Revision 1.5 2006/04/28 21:38:27 acg
134// Andy Goodrich: fixed loop constraint that was using sizeof(sc_thread_handle)
135// rather than sizeof(sc_process_handle).
136//
137// Revision 1.4 2006/01/13 18:44:29 acg
138// Added $Log to record CVS changes into the source.
139
140#endif // SC_JOIN_H
#define SC_API
Definition: sc_cmnhdr.h:148
SC_API void wait(int, sc_simcontext *)
class sc_thread_process * sc_thread_handle
Definition: sc_process.h:62
int process_count()
Definition: sc_join.h:76
void wait()
Definition: sc_join.h:80
void add_process(sc_process_handle process_h)
virtual void signal(sc_thread_handle thread_p, int type)
void wait_clocked()
Definition: sc_join.h:84
sc_event m_join_event
Definition: sc_join.h:68
void add_process(sc_process_b *process_p)