We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Dear all When I change the priority of job2 to 1 the job2 can get the mail, but when I increase its priority it cannot get the mail. Do you have any idea what’s wrong with my code?
#include <LPC17xx.H> #include <RTL.H> #include <string.h> int cnt1,cnt2; OS_TID tsk1,tsk2; static U64 stk1[400/8]; static U64 stk2[400/8]; static U64 stk3[400/8]; typedef struct { char msg[20]; }message; os_mbx_declare (MsgBox, 1); _declare_box(mpool,sizeof(message),1); __task void job1 (void); __task void job2 (void); __task void jobhigh (void); __task void jobhigh(void) { while(1) { os_dly_wait (1); } } __task void job1 (void) { message *mptr; mptr=_alloc_box (mpool); mptr->msg[0]='t'; mptr->msg[1]='e'; mptr->msg[2]='s'; mptr->msg[2]='t'; os_mbx_send (MsgBox, mptr, 0xffff); /* Send the message to the mailbox */ while (1) { os_evt_wait_or (0x0001, 5); cnt1++; } } __task void job2 (void) { message *rptr; os_mbx_wait (MsgBox, (void **)&rptr, 0xffff); /* wait for the message */ LPC_GPIO0->FIOPIN=rptr->msg[0]; _free_box (mpool, rptr); /* free memory allocated for message */ while (1) { os_evt_set (0x0001, tsk1); cnt2++; } } __task void init (void) { tsk1=os_tsk_create_user (job1, 1, &stk1, sizeof(stk1)); tsk2=os_tsk_create_user (job2, 2, &stk2, sizeof(stk2)); os_tsk_create_user(jobhigh,3,&stk3,sizeof(stk3)); //init box _init_box (mpool, sizeof (mpool), sizeof (message)); //init mail box os_mbx_init (MsgBox, sizeof (MsgBox)); os_tsk_delete_self (); } int main(void) { SystemInit(); os_sys_init(init); /* Initialize RTX and start init */ }