SchedulerTest.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:3k
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef TEST_HARNASS // for test only.
- #include <embedded.h>
- #include "IncludeSysDefs.h"
- #include "PlaycoreCoremaincoremain.h"
- #include "KerneluITRONrtos.h"
- //#include "Decoderlow_leveli44_api.h"
- #include "PlaycoreSAMPschedulerSAMPScheduler.h"
- #ifdef tr_printf
- #undef tr_printf
- #define tr_printf(sMsg) (printf ## sMsg)
- #endif
- //scheduler test code
- void task0 (void);
- void task1 (void);
- void task2 (void);
- void task3 (void);
- void task4 (void);
- void task5 (void);
- IDENT mid0,mid1,mid2,mid3,mid4,mid5;
- IDENT tid0,tid1,tid2,tid3,tid4,tid5;
- IDENT sid0,sid1,sid2,sid3,sid4,sid5,sid6,sid7,sid8,sid9;
- void task0 (void)
- {
- char buffer[1500] = "Mess 0";
- tr_printf (("Task 0 startn"));
- SAMP(OS_TaskCreate) (3,1500,task2,&tid2);
- SAMP(OS_TaskCreate) (4,1500,task1,&tid1);
- SAMP(OS_SemCreate) (1,&sid0);
- SAMP(OS_MboxCreate) (20,&mid0);
- while (1)
- {
- SAMP(OS_SemP) (sid0,1);
- SAMP(OS_SendMsg) (mid0,buffer,strlen(buffer));
- }
- }
- void task1 (void)
- {
- size_t size;
- char buffer[1500];
- tr_printf (("Task 1 startn"));
- SAMP(OS_TaskCreate) (0,1500,task5,&tid5);
- SAMP(OS_MboxCreate) (20,&mid1);
- while (1)
- {
- SAMP(OS_RecvMsg) (mid0,1,buffer,12,&size);
- tr_printf (("Message 0: %sn",buffer));
- }
- }
- void task2 (void)
- {
- size_t size;
- char buffer[1500];
- tr_printf (("Task 2 startn"));
- SAMP(OS_TaskCreate) (2,1500,task3,&tid3);
- SAMP(OS_TaskCreate) (1,1500,task4,&tid4);
- SAMP(OS_MboxCreate) (20,&mid2);
- SAMP(OS_MboxCreate) (20,&mid3);
- SAMP(OS_MboxCreate) (20,&mid4);
- SAMP(OS_MboxCreate) (20,&mid5);
- SAMP(OS_SemCreate) (1,&sid1);
- SAMP(OS_SemCreate) (1,&sid2);
- SAMP(OS_SemCreate) (1,&sid3);
- SAMP(OS_SemCreate) (0,&sid4);
- SAMP(OS_SemCreate) (0,&sid5);
- SAMP(OS_SemCreate) (0,&sid6);
- SAMP(OS_SemCreate) (0,&sid7);
- SAMP(OS_SemCreate) (0,&sid8);
- SAMP(OS_SemCreate) (0,&sid9);
- while (1)
- {
- SAMP(OS_SemV)(sid0);
- SAMP(OS_RecvMsg) (mid1,1,buffer,12,&size);
- tr_printf (("Message 1: %sn",buffer));
- SAMP(OS_SemV)(sid4);
- }
- }
- void task3 (void)
- {
- char buffer[1500] = "Mess 2";
- tr_printf (("Task 3 startn"));
- while (1)
- {
- SAMP(OS_SemP) (sid4,1);
- SAMP(OS_SemP) (sid1,1);
- SAMP(OS_SendMsg) (mid2,buffer,7);
- SAMP(OS_SemV) (sid1);
- SAMP(OS_SemP) (sid2,1);
- SAMP(OS_SendMsg) (mid3,"Mess 3",7);
- SAMP(OS_SemV) (sid2);
- SAMP(OS_SemP) (sid3,1);
- SAMP(OS_SendMsg) (mid4,"Mess 4",7);
- SAMP(OS_SemV) (sid3);
- }
- }
- void task4 (void)
- {
- size_t size;
- char buffer[1500];
- tr_printf (("Task 4 startn"));
- while (1)
- {
- SAMP(OS_RecvMsg) (mid2,1,buffer,12,&size);
- tr_printf (("Message 2: %sn",buffer));
- SAMP(OS_RecvMsg) (mid3,1,buffer,12,&size);
- tr_printf (("Message 3: %sn",buffer));
- }
- }
- void task5 (void)
- {
- size_t size;
- char buffer[12];
- tr_printf (("Task 5 startn"));
- while (1)
- {
- SAMP(OS_RecvMsg) (mid4,1,buffer,12,&size);
- tr_printf (("Message 4: %sn",buffer));
- }
- }
- #endif