-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserLevelThread.cpp
More file actions
54 lines (45 loc) · 1.81 KB
/
Copy pathUserLevelThread.cpp
File metadata and controls
54 lines (45 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
// UserLevelThread.cpp : Defines the entry point for the console application.
//
#include <Windows.h>
#include <stdio.h>
#include "Thread.h"
struct Test
{
Thread* t;
void __stdcall TestFunc()
{
for (;;)
{
printf("test\n");
yield(t, ThreadStatus::READY);
}
}
};
struct Test2
{
Thread* t;
void __stdcall TestFunc2()
{
for (;;)
{
printf("test2\n");
yield(t, ThreadStatus::READY);
}
}
};
int main()
{
Scheduler scheduler;
// runze added
// int tickets = 10;
// int strides = 2;
// Test test;
// test.t = scheduler.CreateThread(Scheduler::Convert(&Test::TestFunc), &test, tickets, strides);
// runze added
Test test;
Test2 test2;
test.t = scheduler.CreateThread(Scheduler::Convert(&Test::TestFunc), &test);
test2.t = scheduler.CreateThread(Scheduler::Convert(&Test2::TestFunc2), &test2);
scheduler.Loop();
return 0;
}