#if (INCLUDE__UBINOS__UBIK_TEST == 1)
#if !(UBINOS__UBIK_TEST__EXCLUDE_MUTEXTESTSET == 1)
#include <stdio.h>
#define TASKBUSYWAITCOUNT 1
#define TASKLOOPCOUNT 10000
static int _g_data = 0;
static void mutextest00_subtest1_task1func(void * arg) {
unsigned int i;
int temp;
for (i=0; i<TASKLOOPCOUNT; i++) {
temp = _g_data;
temp = temp + 1;
_g_data = temp;
}
}
static void mutextest00_subtest1_task2func(void * arg) {
unsigned int i;
int temp;
for (i=0; i<TASKLOOPCOUNT; i++) {
temp = _g_data;
temp = temp - 1;
_g_data = temp;
}
}
static int ubik_test_mutextest00_subtest1(void) {
int r;
int r2;
_g_data = 0;
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end0;
}
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end1;
}
r = 0;
end1:
if (0 != r2) {
printf("fail at task_join_and_delete(), err=%d\n", r2);
r = -1;
}
end0:
printf("data (none mutual exclusive use) : %d\n", _g_data);
return r;
}
static void mutextest00_subtest2_task1func(void * arg) {
unsigned int i;
int temp;
for (i=0; i<TASKLOOPCOUNT; i++) {
temp = _g_data;
temp = temp + 1;
_g_data = temp;
}
}
static void mutextest00_subtest2_task2func(void * arg) {
unsigned int i;
int temp;
for (i=0; i<TASKLOOPCOUNT; i++) {
temp = _g_data;
temp = temp - 1;
_g_data = temp;
}
}
static int ubik_test_mutextest00_subtest2(void) {
int r;
int r2;
if (0 != r) {
printf("fail at mutex_create(), err=%d\n", r);
r = -1;
goto end0;
}
_g_data = 0;
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end1;
}
if (0 != r) {
printf("fail at task_create_noautodel(), err=%d\n", r);
r = -1;
goto end2;
}
r = 0;
end2:
if (0 != r2) {
printf("fail at task_join_and_delete(), err=%d\n", r2);
r = -1;
}
end1:
if (0 != r2) {
printf("fail at mutex_delete(), err=%d\n", r2);
r = -1;
}
end0:
printf("data (mutual exclusive use) : %d\n", _g_data);
return r;
}
int r;
r = ubik_test_mutextest00_subtest1();
if (0 != r) {
printf("fail at ubik_test_mutextest00_subtest1(), err=%d\n", r);
r = -1;
goto end0;
}
r = ubik_test_mutextest00_subtest2();
if (0 != r) {
printf("fail at ubik_test_mutextest00_subtest2(), err=%d\n", r);
r = -1;
goto end0;
}
r = 0;
end0:
return r;
}
#endif
#endif
void bsp_busywait(unsigned int count)
int mutex_unlock(mutex_pt mutex)
int mutex_create(mutex_pt *mutex_p)
int mutex_delete(mutex_pt *mutex_p)
int mutex_lock(mutex_pt mutex)
stdlib (Standard Library) API
int task_create_noautodel(task_pt *task_p, taskfunc_ft func, void *arg, int priority, unsigned int stackdepth, const char *name)
int task_join_and_delete(task_pt *task_p, int *result_p, int count)
int task_getpriority(task_pt task)
#define NULL
Definition: type.h:42
int ubik_test_mutextest00(void)
Simple mutex example.