Forráskód Böngészése

add os used coroutine, tobe done

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 4 éve
szülő
commit
484ca2bf3f
2 módosított fájl, 21 hozzáadás és 0 törlés
  1. 1 0
      Applications/os/task.c
  2. 20 0
      Applications/os/task.h

+ 1 - 0
Applications/os/task.c

@@ -0,0 +1 @@
+

+ 20 - 0
Applications/os/task.h

@@ -0,0 +1,20 @@
+#ifndef _OS_TASK_H__
+#define _OS_TASK_H__
+/*
+Task如果没有调用task_yield/delay 永远执行下去
+*/
+typedef void (*task_func)(void *);
+
+typedef struct {
+	u32 regs[16];//save the context
+	u32 pstack; //stack addr
+	u16 stack_size; //stack size
+	u8  run_stat; //task stat, running, pending, blocked
+}tcb_t;
+
+void task_create(void *stack, u16 stack_size, task_func func, void *param);
+void task_delay(int ms); //task 延时
+void task_yield(void); //task 让出cpu
+void task_sched(void); //task开始调度
+#endif /*_OS_TASK_H__*/
+