forked from heishv/vxworks-realtime-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_switch_test.c
48 lines (39 loc) · 995 Bytes
/
task_switch_test.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
/* Copyright (c) 2019, heishv
* All rights reserved.
*
* SPDX-License-Identifier: Apache License 2.0
*/
#include <vxWorks.h>
#include <errnoLib.h>
#include <hookLib.h>
#include <taskHookLib.h>
#include <private/taskLibP.h>
#include <private/kernelLibP.h>
#include <private/timerLibP.h> /* _func_clkTimer* */
#include <usrLib.h>
#include <strlib.h>
#include "realtime_debug_config.h"
#include "task_switch_trace.h"
SEM_ID tr_test_semId;
int tr_test_task1()
{
while(1) {
taskDelay(1);
semGive(tr_test_semId);
}
return OK;
}
int tr_test_task2()
{
while(1) {
semTake(tr_test_semId, WAIT_FOREVER);
}
return OK;
}
int tr_test()
{
tr_test_semId = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
taskSpawn("tr_test_give", 150, 0, 200000, tr_test_task1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
taskSpawn("tr_test_take", 150, 0, 200000, tr_test_task2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
return OK;
}