Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
97 lines (84 loc) · 1.81 KB
/
Copy pathmain.cpp
File metadata and controls
97 lines (84 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// Created by qywoe on 03/04/2022.
//
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <deque>
#include <list>
#include <assert.h>
#include "uthreads.h"
//#include "libuthread.a"
#include <iostream>
#include <vector>
using namespace std;
void f (void)
{
while(1);
}
int main(void) {
std::vector<int> v = {7, 5, 16, 8};
auto b = v;
b.push_back(20);
int q[2] = {10, 20};
if (uthread_init(10) == -1) {
return 0;
}
for (int i = 0; i < 90; i++)
cout << uthread_spawn(f) << endl;
uthread_terminate(10);
uthread_terminate(5);
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
uthread_terminate(15);
uthread_terminate(25);
uthread_terminate(35);
uthread_terminate(45);
uthread_terminate(55);
uthread_terminate(65);
uthread_terminate(75);
uthread_terminate(85);
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
cout << uthread_spawn(f) << endl;
uthread_terminate(0);
printf("");
return 0;
}
//#include <iostream>
//#include "uthreads.h"
//
//#include <memory>
//
//class foo {
//public:
// foo(int a, int b) : a(a), b(b) {}
//
//public:
// int a, b;
//};
//
//int main() {
// uthread_init(2);
// for (int i = 0; i < 10; ++i) {
// uthread_spawn(nullptr);
// }
// for (int i = 0; i < 10; ++i) {
// uthread_terminate(i);
//
// }
// for (int i = 0; i < 10; ++i) {
// uthread_spawn(nullptr);
// }
// printf("hello");
// return 0;
//}