Last change
on this file since daf4c89 was
1b34b87,
checked in by Peter A. Buhr <pabuhr@…>, 6 years ago
|
Lynn's GDB essay
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | _Task T { |
---|
2 | const int tid; |
---|
3 | std::string name; |
---|
4 | |
---|
5 | void f(int param) { |
---|
6 | if ( param != 0 ) f( param - 1 ); // recursion |
---|
7 | for ( volatile size_t i = 0; i < 100000000; i += 1 ); // delay |
---|
8 | int x = 3; |
---|
9 | std::string y = "example"; |
---|
10 | } // breakpoint |
---|
11 | void main() { |
---|
12 | if ( tid != 0 ) // T0 goes first |
---|
13 | for ( volatile size_t i = 0; i < 1000000000; i += 1 ) // delay |
---|
14 | if ( i % 10000000 == 0 ) yield(); // execute other tasks |
---|
15 | f(3); |
---|
16 | } |
---|
17 | public: |
---|
18 | T(const int tid) : tid( tid ) { |
---|
19 | name = "T" + std::to_string(tid); |
---|
20 | setName(name.c_str()); |
---|
21 | } |
---|
22 | }; |
---|
23 | int main() { |
---|
24 | uProcessor procs[3]; // extra processors |
---|
25 | const int numTasks = 10; |
---|
26 | T * tasks[numTasks]; // extra tasks |
---|
27 | // allocate tasks with different names |
---|
28 | for (int id = 0; id < numTasks; id += 1) { |
---|
29 | tasks[id] = new T(id); |
---|
30 | } |
---|
31 | // deallocate tasks |
---|
32 | for (int id = 0; id < numTasks; id += 1) { |
---|
33 | delete tasks[id]; |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | // Local Variables: // |
---|
38 | // compile-command: "u++-work test.cc -g -multi" // |
---|
39 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.