replace multiple instructions with macro SAVE_CONTEXT and RESTORE_CONTEXT

This commit is contained in:
acezhao
2019-09-14 22:15:09 +08:00
parent ad72fb73d2
commit de43d4ef0e
10 changed files with 342 additions and 502 deletions

View File

@@ -0,0 +1,62 @@
/*
* main.c
*
* Created on: Sep 13, 2019
* Author: ace
*/
#include "tos.h"
#define TASK_SIZE 512
k_task_t k_task_task1;
k_task_t k_task_task2;
uint8_t k_task1_stk[TASK_SIZE];
uint8_t k_task2_stk[TASK_SIZE];
int share = 123;
void task1(void *pdata)
{
int t1 = 0;
while(1)
{
t1++;
share++;
//k_tick_t delay = tos_millisec2tick(10);
//tos_task_delay(delay);
tos_task_yield();
//osDelay(10);
//asm("wfi;");
}
}
void task2(void *pdata)
{
int t2 = 0;
while(1)
{
t2--;
share--;
//tos_task_delay(10);
tos_task_yield();
asm("wfi;");
}
}
int main(void)
{
tos_knl_init();
tos_task_create(&k_task_task1, "task1", task1, NULL, 3, k_task1_stk, TASK_SIZE, 0);
tos_task_create(&k_task_task2, "task2", task2, NULL, 3, k_task2_stk, TASK_SIZE, 0);
tos_knl_start();
int c = 0;
while(1)
{
c++;
asm("wfi;");
}
}