Monday, December 11th 2017, 1:06am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

gpontis

Beginner

Date of registration: Dec 18th 2007

Posts: 44

Location: California

1

Tuesday, December 15th 2009, 5:15pm

embOS 3.82b, IAR 5.40, ARM7: losing an event

I have an application running on an AT91SAM7S256 with 8 tasks. Normally the CPU utilization is very low, more than 95% idle. The highest priority task is implemented as an infinite loop, which waits for an OS_Event coming from the ISR for a timer tick. The event is signaled with a call to OS_EVENT_Pulse(). After the task sees the event it does some processing and then restarts the timer. If I do something to flood the system with work I can bring a couple of tasks up to 30% utiltization, and within seconds my hi pri task stops running. I put counters in to see how many times the event is signaled and how many times the wait succeeded in waking the task. The number of times signaled is one greater than the number of times that the tasks awakened. Since there are no other users of this event, and only one place in the code where the task waits on it, it looks like the event has been lost.
My quick and satisfactory fix for this is to just use a task event with OS_SignalEvent and OS_WaitSingleEvent. My counters remain equal so I know with this implementation that the task is waking up once for every time that it is signaled. I hesitate to call the problem with the other mechanism a bug since my application is still pretty green. However, I use OS events and OS_EVENT_Pulse elsewhere, and am wondering if there is something that I have missed about how they work.

mwb1100

Beginner

Date of registration: Sep 30th 2009

Posts: 27

2

Wednesday, December 16th 2009, 8:10pm

Is it possible that the missed event occurs when the task isn't actually waiting yet? If nothing is actually waiting on the event when OS_EVENT_Pulse() gets called, the event will never be 'seen'.

If the task is the only thing that will ever wait for the event, it might be better to simply use OS_EVENT_Set() rather than OS_EVENT_pulse() so the task waiting for the event will see it regardless if the event is set while it's waiting or not. Or use a OS_CSEMA counting semaphore if the task needs to account for each event.