-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_kill0.c
50 lines (41 loc) · 1.21 KB
/
test_kill0.c
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
#include "test.h"
//-----------------------------------------------------------------
// Defines:
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Locals:
//-----------------------------------------------------------------
THREAD_DECL(thread0, 8192);
THREAD_DECL(thread1, 8192);
static volatile int _flag = 0;
//-----------------------------------------------------------------
// thread_func
//-----------------------------------------------------------------
static void* thread_func(void *arg)
{
if (arg == (void*)0)
thread_sleep(5);
else
{
_flag = 1;
thread_sleep(10);
_flag = 2;
}
return NULL;
}
//-----------------------------------------------------------------
// Test Thread Function:
//-----------------------------------------------------------------
void testcase(void * a)
{
THREAD_INIT(thread0, "thread0", thread_func, 0, 0);
THREAD_INIT(thread1, "thread1", thread_func, 1, 0);
thread_sleep(1);
OS_ASSERT(_flag == 1);
thread_kill(&thread_thread0);
thread_sleep(7);
OS_ASSERT(_flag == 1);
thread_sleep(4);
OS_ASSERT(_flag == 2);
exit(0);
}