1

I will try my best to explain my problem.

I am currently programming a very basic OS for an ARM. I have a problem where a new struct of the type msg have the same (location?) value as a struct of type listobj.

typedef struct msgobj {
    char            *pData;
    exception       Status;
    struct l_obj    *pBlock;
    struct msgobj   *pPrevious;
    struct msgobj   *pNext;
} msg;

typedef struct l_obj {
     TCB            *pTask;
     uint           nTCnt;
     msg            *pMessage;
     struct l_obj   *pPrevious;
     struct l_obj   *pNext;
} listobj;

The listobjs are used to in different linked lists to control the data in the OS. While the msg's are used to save data to a mailbox simply explained. While trying the OS and the lists have formed I have a list with listobj linked doubly and correctly.

Later I make a new msg to be inserted in the mailbox,

msg* message = (msg*)malloc(sizeof(msg))

Now the problem is that the value of this struct is the same as a listobj struct in one of the lists. (value is viewed by the live watch in IAR) When I try linking the msg to a maibox (FIFO) using the pNext and pPrevious. I am changing the pNext and pPrevious of the listobj. (the pNext and pPrevious is of different types)

Is there an explaination to this? Or a way to avoid it? At the moment it seem that this is the final bug to finish the project.

It is worth mentioning that the code uses context switches and simulated in IAR. The code for the context switches is not made by me but by my professor.

I apologize for bad grammar, and thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
F. Rosberg
  • 11
  • 4

0 Answers0