In my application I create a semaphore to control access to a global structure which holds the acual time, which is beeing read out a RTC in a task. In another task I create log entrys, including the time. In both tasks, the access to the structure is protected by the semaphore. I initialize the "time reading task" before the log task, so the time should be read out before any log entry is created. Even so the first log entrys contain a wrong time. How is this possible. As long as the time reading task holds the semaphore the log task should not be able to access the time keeping structure. Unfortunately my debugger (using IAR Embedded Workbench) is not able to debug this, I get a message stating "simulating illegal code condition". Now I am wondering how this is possible. Preemption is enabled and both tasks have the same priority. But this should not be important as I am using the semaphore. Has anyone an idea on this?